/* 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. */
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. */
(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 */
(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 */
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;
}
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 */