Commit 177d70f1
177d70f1452fMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 1 file · ~1 modified
Description
fix: ao_render value-type detection for classes with attr_writers
Classes with attr_writer declarations are mutable by definition, so they should not be promoted to value types (stack-allocated structs). Previously, attr_writers were skipped in the mutation check, causing Isect to be incorrectly treated as a value type in self-compiled output.
Also extend detect_param_mutated_types to check toplevel functions (not just class methods) for parameter mutation.
67 tests pass, bootstrap clean.
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- 177d70f1452f
- Parent
- dfb930ffa39f
spinel_codegen.rbmodifiedView file
@@ -7652,6 +7652,42 @@
76527652
end76537653
i = i + 176547654
end7655+
# Also check toplevel functions7656+
mi = 07657+
while mi < @meth_names.length7658+
bid = @meth_body_ids[mi]7659+
pnames = @meth_param_names[mi].split(",")7660+
ptypes = @meth_param_types[mi].split(",")7661+
obj_param_names = "".split(",")7662+
obj_param_types = "".split(",")7663+
pj = 07664+
while pj < pnames.length7665+
pt = "int"7666+
if pj < ptypes.length7667+
pt = ptypes[pj]7668+
end7669+
if is_obj_type(pt) == 17670+
obj_param_names.push(pnames[pj])7671+
obj_param_types.push(pt)7672+
end7673+
pj = pj + 17674+
end7675+
if obj_param_names.length > 0 && bid >= 07676+
mutated_name = subtree_has_setter_on_params(bid, obj_param_names)7677+
if mutated_name != ""7678+
pj = 07679+
while pj < obj_param_names.length7680+
if obj_param_names[pj] == mutated_name7681+
if not_in(obj_param_types[pj], @param_mutated_types) == 17682+
@param_mutated_types.push(obj_param_types[pj])7683+
end7684+
end7685+
pj = pj + 17686+
end7687+
end7688+
end7689+
mi = mi + 17690+
end76557691
end76567692
76577693
def recalc_needs_gc@@ -7703,11 +7739,15 @@
77037739
end77047740
j = j + 177057741
end7706-
# Exclude classes with self-mutating methods7742+
# Exclude classes with self-mutating methods or attr_writers77077743
if all_val == 177087744
if cls_has_self_mutating_methods(i) == 177097745
all_val = 077107746
end7747+
writers = @cls_attr_writers[i].split(";")7748+
if writers.length > 0 && writers[0] != ""7749+
all_val = 07750+
end77117751
end77127752
# Exclude classes involved in inheritance77137753
if all_val == 1