Commit 5ff8b80d

5ff8b80dbb02Merged

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

Description

Merge pull request #231 from mame/pr/gc-scan-skip-inherited

fix(codegen): gc_scan skips ivars inherited from parent class

Details

Commit
5ff8b80dbb02
Parent
1ea24b3bdc46
Merge parent
592a33addfcb

spinel_codegen.rbmodifiedView file

@@ -13113,7 +13113,23 @@
1311313113 j = 0
1311413114 while j < names.length
1311513115 if j < types.length
13116- if ivar_is_gc_ptr(types[j]) == 1
13116+ # Skip ivars inherited from parent — emit_class_struct
13117+ # also skips them on the child, so the struct field type
13118+ # comes from the parent's recorded type, and re-emitting
13119+ # here under the child's type info can produce a wrong
13120+ # mark (e.g. parent says int_array, child has widened to
13121+ # poly, struct field is sp_RbVal). The parent walk below
13122+ # marks them via the parent's type.
13123+ skip_inherited = 0
13124+ if @cls_parents[i] != ""
13125+ parent_idx = find_class_idx(@cls_parents[i])
13126+ if parent_idx >= 0
13127+ if ivar_in_chain(parent_idx, names[j]) == 1
13128+ skip_inherited = 1
13129+ end
13130+ end
13131+ end
13132+ if skip_inherited == 0 && ivar_is_gc_ptr(types[j]) == 1
1311713133 emit_gc_mark_ivar("self->" + sanitize_ivar(names[j]), types[j])
1311813134 end
1311913135 end