Commit b5758a8a

b5758a8afeb5Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified

Description

Merge pull request #209 from mame/pr/gc-root-range-and-times-map

fix(codegen): SP_GC_ROOT Range#map / N.times.map accumulators

Details

Commit
b5758a8afeb5
Parent
95b51ab5502a
Merge parent
09252cc49467

spinel_codegen.rbmodifiedView file

@@ -26983,6 +26983,11 @@
2698326983 @needs_int_array = 1
2698426984 emit(" sp_IntArray *" + tmp_arrn + " = sp_IntArray_new();")
2698526985 end
26986+ # Root the accumulator so a GC pass triggered by an
26987+ # allocation inside the block (e.g. string interpolation)
26988+ # doesn't free the half-built array. Same reasoning as the
26989+ # int_array / str_array branches further down.
26990+ emit(" SP_GC_ROOT(" + tmp_arrn + ");")
2698626991 emit(" for (mrb_int " + tmp_in + " = 0; " + tmp_in + " < " + ncount + "; " + tmp_in + "++) {")
2698726992 if bpn != ""
2698826993 emit(" lv_" + bpn + " = " + tmp_in + ";")
@@ -27064,6 +27069,11 @@
2706427069 else
2706527070 emit(" sp_IntArray *" + tmp_arr + " = sp_IntArray_new();")
2706627071 end
27072+ # Root the accumulator so a GC pass triggered by an
27073+ # allocation inside the block (e.g. string interpolation)
27074+ # doesn't free the half-built array. Same reasoning as the
27075+ # int_array / str_array branches further down.
27076+ emit(" SP_GC_ROOT(" + tmp_arr + ");")
2706727077 # Walk through ParenthesesNode wrappers to find a literal
2706827078 # RangeNode (so we can read its exclude_end flag and its raw
2706927079 # endpoint expressions). If the receiver is a variable holding