Commit 2a03d8f2

2a03d8f28f2cMerged

sacckey <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified

Description

fix(codegen): avoid duplicate SP_GC_SAVE in constructor initialize path

Details

Commit
2a03d8f28f2c
Parent
308afd30fb1f

spinel_codegen.rbmodifiedView file

@@ -10481,6 +10481,7 @@
1048110481 end
1048210482
1048310483 def emit_constructor(ci)
10484+ saved_gc_scope = @in_gc_scope
1048410485 cname = @cls_names[ci]
1048510486 init_idx = cls_find_method_direct(ci, "initialize")
1048610487 if @cls_is_value_type[ci] == 1
@@ -10489,6 +10490,7 @@
1048910490 else
1049010491 emit_raw("static inline sp_" + cname + " *sp_" + cname + "_new(" + constructor_params_decl(ci) + ") {")
1049110492 emit_raw(" SP_GC_SAVE();")
10493+ @in_gc_scope = 1
1049210494 scan_fn = "NULL"
1049310495 if class_has_ptr_ivars(ci) == 1
1049410496 scan_fn = "sp_" + cname + "_gc_scan"
@@ -10641,6 +10643,7 @@
1064110643 emit_raw(" return self;")
1064210644 emit_raw("}")
1064310645 emit_raw("")
10646+ @in_gc_scope = saved_gc_scope
1064410647
1064510648 # Initialize function (for super calls) - always uses *self (pointer)
1064610649 if init_idx >= 0
@@ -11025,8 +11028,10 @@
1102511028 end
1102611029 if has_gc_locals == 1
1102711030 if @needs_gc == 1
11028- emit(" SP_GC_SAVE();")
11029- @in_gc_scope = 1
11031+ if @in_gc_scope == 0
11032+ emit(" SP_GC_SAVE();")
11033+ @in_gc_scope = 1
11034+ end
1103011035 end
1103111036 end
1103211037 j = 0