Commit 75ab7d97
75ab7d970562Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Root allocating call arguments against the callee's own GC
The argument-hoist pass only rooted a freshly-allocated heap argument
when a LATER positional argument might allocate. But the callee itself
allocates too — a constructor (sp_X_new) always does — so
Ray.new(Vec.new(0,0,0), eye) left the new Vec in an unrooted temporary
while sp_Ray_new allocated the Ray, and a stress-mode collection swept
the Vec out of the half-built Ray (bm_ao_render segfault).
Hoist+root any heap-typed argument whose own expression may allocate, regardless of what later arguments do; a non-allocating heap expression (e.g. a ternary over two already-live reads) still skips. Also root the iteration-source temp in the map and all?/any?/none?/one? fold emitters, and the SymPolyHash#keys boxing intermediate.
bm_ao_render now passes under SPINEL_GC_STRESS=1; make test (845) and make bench (57) stay green.
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- 75ab7d970562
- Parent
- abcd50454b33
src/codegen_call.cmodifiedView file
/* runtime returns sym ids as an IntArray; box into a poly (sym) array */ int ki = ++g_tmp, kp = ++g_tmp, ii = ++g_tmp; buf_printf(b, "({ sp_IntArray *_t%d = sp_SymPolyHash_keys(", ki); emit_expr(c, recv, b); buf_printf(b, "); sp_PolyArray *_t%d = sp_PolyArray_new(); SP_GC_ROOT(_t%d);", kp, kp); buf_printf(b, "); SP_GC_ROOT(_t%d); sp_PolyArray *_t%d = sp_PolyArray_new(); SP_GC_ROOT(_t%d);", ki, kp, kp); buf_printf(b, " for (mrb_int _t%d = 0; _t%d < sp_IntArray_length(_t%d); _t%d++)" " sp_PolyArray_push(_t%d, sp_box_sym((sp_sym)sp_IntArray_get(_t%d, _t%d)));", ii, ii, ki, ii, kp, ki, ii);src/codegen_fold.cmodifiedView file
Loading diff…