Commit 45fae0a0
45fae0a0846aMerged
fc-anjos <[email protected]> · 6 months ago · 5 files · +4 added · ~1 modified
Description
fix value-type GC tracing
Co-Authored-By: OpenAI Codex 5.5
Details
- Commit
- 45fae0a0846a
- Parent
- 234e29dfa690
spinel_codegen.rbmodifiedView file
@@ -8508,13 +8508,27 @@
85088508
085098509
end85108510
8511+
def ivar_needs_gc_mark(t)8512+
if ivar_is_gc_ptr(t) == 18513+
return 18514+
end8515+
if is_value_type_obj(t) == 18516+
cname = t[4, t.length - 4]8517+
ci = find_class_idx(cname)8518+
if ci >= 0 && class_has_ptr_ivars(ci) == 18519+
return 18520+
end8521+
end8522+
08523+
end8524+
85118525
def class_has_ptr_ivars(ci)85128526
names = @cls_ivar_names[ci].split(";")85138527
types = @cls_ivar_types[ci].split(";")85148528
j = 085158529
while j < names.length85168530
if j < types.length8517-
if ivar_is_gc_ptr(types[j]) == 18531+
if ivar_needs_gc_mark(types[j]) == 185188532
return 185198533
end85208534
end@@ -8568,12 +8582,28 @@
85688582
def emit_gc_mark_ivar(field, t)85698583
if t == "poly"85708584
emit_raw(" sp_mark_rbval(" + field + ");")8585+
elsif is_value_type_obj(t) == 18586+
cname = t[4, t.length - 4]8587+
emit_raw(" sp_" + cname + "_gc_scan(&" + field + ");")85718588
else85728589
emit_raw(" if (" + field + ") sp_gc_mark((void *)" + field + ");")85738590
end85748591
end85758592
85768593
def emit_gc_scan_functions8594+
emitted_proto = 08595+
i = 08596+
while i < @cls_names.length8597+
if cls_emit_skipped(i) == 0 && class_has_ptr_ivars(i) == 18598+
emit_raw("static void sp_" + @cls_names[i] + "_gc_scan(void *p);")8599+
emitted_proto = 18600+
end8601+
i = i + 18602+
end8603+
if emitted_proto == 18604+
emit_raw("")8605+
end8606+
85778607
i = 085788608
while i < @cls_names.length85798609
if cls_emit_skipped(i) == 1@@ -8605,7 +8635,7 @@
86058635
end86068636
end86078637
end8608-
if skip_inherited == 0 && ivar_is_gc_ptr(types[j]) == 18638+
if skip_inherited == 0 && ivar_needs_gc_mark(types[j]) == 186098639
emit_gc_mark_ivar("self->" + sanitize_ivar(names[j]), types[j])86108640
end86118641
end@@ -8620,7 +8650,7 @@
86208650
pj = 086218651
while pj < pnames.length86228652
if pj < ptypes.length8623-
if ivar_is_gc_ptr(ptypes[pj]) == 18653+
if ivar_needs_gc_mark(ptypes[pj]) == 186248654
emit_gc_mark_ivar("self->" + sanitize_ivar(pnames[pj]), ptypes[pj])86258655
end86268656
end@@ -24908,7 +24938,7 @@
2490824938
def constructor_arg_needs_root(arg_type)2490924939
bt = base_type(arg_type)2491024940
if is_obj_type(bt) == 124911-
return 124941+
return type_is_pointer(bt)2491224942
end2491324943
if is_array_type(bt) == 1 || is_ptr_array_type(bt) == 1 || is_tuple_type(bt) == 12491424944
return 1test/value_type_constructor_arg_gc_root.rbaddedView file
Loading diff…
test/value_type_constructor_arg_gc_root.rb.expectedaddedView file
Loading diff…
test/value_type_ivar_gc_scan.rbaddedView file
Loading diff…
test/value_type_ivar_gc_scan.rb.expectedaddedView file
Loading diff…