From: Ivan Maidanski Date: Thu, 5 Jul 2018 17:00:49 +0000 (+0300) Subject: Remove PUSH_OBJ multi-line macro X-Git-Tag: v8.0.0~84 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aefc738c17164e4756abe2152ba8728ea722837d;p=platform%2Fupstream%2Flibgc.git Remove PUSH_OBJ multi-line macro (code refactoring) * finalize.c (GC_normal_finalize_mark_proc): Call GC_push_obj instead of PUSH_OBJ. * include/private/gc_pmark.h (PUSH_CONTENTS_HDR): Likewise. * mark.c (GC_push_marked): Likewise. * mark.c [ENABLE_DISCLAIM] (GC_push_unconditionally): Likewise. * finalize.c (GC_normal_finalize_mark_proc): Remove hhdr local variable. * include/private/gc_pmark.h (PUSH_OBJ): Transform macro to inline function; rename to GC_push_obj; update comment; return mark_stack_top. --- diff --git a/finalize.c b/finalize.c index 59d0375..64a0ec2 100644 --- a/finalize.c +++ b/finalize.c @@ -634,10 +634,8 @@ GC_API GC_await_finalize_proc GC_CALL GC_get_await_finalize_proc(void) /* overflow is handled by the caller, and is not a disaster. */ STATIC void GC_normal_finalize_mark_proc(ptr_t p) { - hdr * hhdr = HDR(p); - - PUSH_OBJ(p, hhdr, GC_mark_stack_top, - &(GC_mark_stack[GC_mark_stack_size])); + GC_mark_stack_top = GC_push_obj(p, HDR(p), GC_mark_stack_top, + GC_mark_stack + GC_mark_stack_size); } /* This only pays very partial attention to the mark descriptor. */ diff --git a/include/private/gc_pmark.h b/include/private/gc_pmark.h index 8cd61b1..30e7eef 100644 --- a/include/private/gc_pmark.h +++ b/include/private/gc_pmark.h @@ -121,20 +121,23 @@ GC_EXTERN size_t GC_mark_stack_size; GC_INNER mse * GC_signal_mark_stack_overflow(mse *msp); /* Push the object obj with corresponding heap block header hhdr onto */ -/* the mark stack. */ -#define PUSH_OBJ(obj, hhdr, mark_stack_top, mark_stack_limit) \ - do { \ - word _descr = (hhdr) -> hb_descr; \ - GC_ASSERT(!HBLK_IS_FREE(hhdr)); \ - if (_descr != 0) { \ - mark_stack_top++; \ - if ((word)mark_stack_top >= (word)(mark_stack_limit)) { \ - mark_stack_top = GC_signal_mark_stack_overflow(mark_stack_top); \ - } \ - mark_stack_top -> mse_start = (obj); \ - mark_stack_top -> mse_descr.w = _descr; \ - } \ - } while (0) +/* the mark stack. Returns the updated mark_stack_top value. */ +GC_INLINE mse * GC_push_obj(ptr_t obj, hdr * hhdr, mse * mark_stack_top, + mse * mark_stack_limit) +{ + word descr = hhdr -> hb_descr; + + GC_ASSERT(!HBLK_IS_FREE(hhdr)); + if (descr != 0) { + mark_stack_top++; + if ((word)mark_stack_top >= (word)mark_stack_limit) { + mark_stack_top = GC_signal_mark_stack_overflow(mark_stack_top); + } + mark_stack_top -> mse_start = obj; + mark_stack_top -> mse_descr.w = descr; + } + return mark_stack_top; +} /* Push the contents of current onto the mark stack if it is a valid */ /* ptr to a currently unmarked object. Mark it. */ @@ -316,7 +319,8 @@ GC_INNER mse * GC_signal_mark_stack_overflow(mse *msp); (unsigned)GC_gc_no, (void *)base, (void *)(source))); \ INCR_MARKS(hhdr); \ GC_STORE_BACK_PTR((ptr_t)(source), base); \ - PUSH_OBJ(base, hhdr, mark_stack_top, mark_stack_limit); \ + mark_stack_top = GC_push_obj(base, hhdr, mark_stack_top, \ + mark_stack_limit); \ } while (0) #endif /* MARK_BIT_PER_GRANULE */ @@ -375,7 +379,8 @@ GC_INNER mse * GC_signal_mark_stack_overflow(mse *msp); (unsigned)GC_gc_no, (void *)base, (void *)(source))); \ INCR_MARKS(hhdr); \ GC_STORE_BACK_PTR((ptr_t)(source), base); \ - PUSH_OBJ(base, hhdr, mark_stack_top, mark_stack_limit); \ + mark_stack_top = GC_push_obj(base, hhdr, mark_stack_top, \ + mark_stack_limit); \ } while (0) #endif /* MARK_BIT_PER_OBJ */ diff --git a/mark.c b/mark.c index d5fae4e..95dab2a 100644 --- a/mark.c +++ b/mark.c @@ -1885,10 +1885,11 @@ STATIC void GC_push_marked(struct hblk *h, hdr *hhdr) GC_mark_stack_top_reg = GC_mark_stack_top; for (p = h -> hb_body, bit_no = 0; (word)p <= (word)lim; p += sz, bit_no += MARK_BIT_OFFSET(sz)) { - if (mark_bit_from_hdr(hhdr, bit_no)) { - /* Mark from fields inside the object */ - PUSH_OBJ(p, hhdr, GC_mark_stack_top_reg, mark_stack_limit); - } + if (mark_bit_from_hdr(hhdr, bit_no)) { + /* Mark from fields inside the object. */ + GC_mark_stack_top_reg = GC_push_obj(p, hhdr, GC_mark_stack_top_reg, + mark_stack_limit); + } } GC_mark_stack_top = GC_mark_stack_top_reg; } @@ -1927,8 +1928,9 @@ STATIC void GC_push_marked(struct hblk *h, hdr *hhdr) GC_mark_stack_top_reg = GC_mark_stack_top; for (p = h -> hb_body; (word)p <= (word)lim; p += sz) - if ((*(word *)p & 0x3) != 0) - PUSH_OBJ(p, hhdr, GC_mark_stack_top_reg, mark_stack_limit); + if ((*(word *)p & 0x3) != 0) + GC_mark_stack_top_reg = GC_push_obj(p, hhdr, GC_mark_stack_top_reg, + mark_stack_limit); GC_mark_stack_top = GC_mark_stack_top_reg; } #endif /* ENABLE_DISCLAIM */