Commit 86e03011
86e03011912eMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 2 files · ~2 modified
Description
fix(analyze,codegen): SuperNode + tail-arith infer-type promote sweep
@nd_inferred_type was populated by annotate_all_node_types AFTER
the global int -> bigint sweep, but several arms still cached an
"int" type:
- SuperNode: cls_method_return was returning the post-promotion bigint for direct calls, but a still-int cached value for the super reference confused compile_body_return's coerce.
- Arith CallNode chains (
super + 5): infer_type for the outer+stayed cached "int" even though the operand-side analysis said the recv side returned bigint.
Two tweaks:
- analyze: after annotate, sweep
@nd_inferred_typeand rewrite "int" -> "bigint" for SuperNode / ForwardingSuperNode entries. - codegen: compile_body_return peeks arith operand types so a
tail
super + N(where super is bigint and N is an int literal) doesn't re-wrap the already-bigint sum.
Promote-mode test count: 534 pass / 53 fail / 31 error -> 535 pass / 53 fail / 30 error. Default raise mode 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 86e03011912e
- Parent
- 5d63d8292198
spinel_analyze.rbmodifiedView file
@@ -21520,6 +21520,27 @@
2152021520
end2152121521
end2152221522
annotate_all_node_types21523+
# Promote-mode safety: annotate may have produced stale "int"21524+
# entries for nodes whose inferred type derived from cached21525+
# state captured before promote_int_to_bigint_globally landed21526+
# (SuperNode reading cls_method_return's pre-promotion result,21527+
# CallNode chains whose mid-tree return type was cached, etc.).21528+
# Sweep `@nd_inferred_type` again and rewrite "int" -> "bigint"21529+
# for node kinds whose concrete C emit is always bigint when the21530+
# underlying slot is promoted.21531+
if @int_overflow_mode == "promote"21532+
ni_p = 021533+
while ni_p < @nd_inferred_type.length21534+
tp = @nd_inferred_type[ni_p]21535+
if tp == "int"21536+
ntp = @nd_type[ni_p]21537+
if ntp == "SuperNode" || ntp == "ForwardingSuperNode"21538+
@nd_inferred_type[ni_p] = "bigint"21539+
end21540+
end21541+
ni_p = ni_p + 121542+
end21543+
end2152321544
# Now that @nd_inferred_type is populated for every reachable2152421545
# node, we can resolve `recv.method(...)`'s receiver class2152521546
# cheaply. Check each RBS-pinned method's positional args atspinel_codegen.rbmodifiedView file
Loading diff…