Commit 71e2ec73
71e2ec738620Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): Method fn_ptr arg unbox handles stale-int bigint emit
Details
- Commit
- 71e2ec738620
- Parent
- 34efb77573f0
spinel_codegen.rbmodifiedView file
@@ -22058,7 +22058,7 @@
2205822058
if arg_types[0] == "poly"2205922059
a0_int = "(" + a0_int + ").v.i"2206022060
end22061-
if arg_types[0] == "bigint"22061+
if arg_types[0] == "bigint" || (arg_types[0] == "int" && (a0_int.start_with?("sp_bigint_") || a0_int.start_with?("(sp_Bigint *)")))2206222062
@needs_bigint = 12206322063
a0_int = "sp_bigint_to_int((sp_Bigint *)" + a0_int + ")"2206422064
end@@ -22373,6 +22373,20 @@
2237322373
@needs_bigint = 12237422374
a0 = "sp_bigint_to_int((sp_Bigint *)" + a0 + ")"2237522375
end22376+
# When the cache reports stale "int" but the actual emit is22377+
# bigint (arith / bitop / user-method returning bigint), use22378+
# the same unbox. arg_types is populated from infer_type; the22379+
# walker catches stale-int rhs shapes.22380+
if arg_compiled.length > 0 && (arg_types.length == 0 || arg_types[0] == "int") && a0 != ""22381+
# Need the original AST node to consult expr_emit_is_bigint;22382+
# the caller doesn't pass it, so we detect from the compiled22383+
# string instead: sp_bigint_* return-typed expressions all22384+
# start with sp_bigint_ except for `(sp_Bigint *)lv_x` casts.22385+
if a0.start_with?("sp_bigint_") || a0.start_with?("(sp_Bigint *)")22386+
@needs_bigint = 122387+
a0 = "sp_bigint_to_int((sp_Bigint *)" + a0 + ")"22388+
end22389+
end2237622390
end2237722391
# `[]` — element types differ per built-in. When the result temp2237822392
# is sp_RbVal (poly return), every branch can box into it. When@@ -22728,6 +22742,12 @@
2272822742
elsif mi < arg_types.length && arg_types[mi] == "bigint"2272922743
@needs_bigint = 12273022744
ai_val = "sp_bigint_to_int((sp_Bigint *)" + ai_val + ")"22745+
elsif ai_val.start_with?("sp_bigint_") || ai_val.start_with?("(sp_Bigint *)")22746+
# Stale-int cache hiding a bigint emit (canonical arith /22747+
# bitop CallNode whose operands include a promote-widened22748+
# local). Method's fn_ptr ABI is fixed mrb_int — unbox.22749+
@needs_bigint = 122750+
ai_val = "sp_bigint_to_int((sp_Bigint *)" + ai_val + ")"2273122751
end2273222752
call_args = call_args + ", " + ai_val2273322753
mi = mi + 1