Commit c8b87a1e

c8b87a1eacf0Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

fix(codegen): Method#call dispatch unboxes bigint args to mrb_int ABI

The bound Method object's underlying C function pointer has the fixed (void *self, mrb_int...) ABI. Two emit paths still passed promote-widened bigint args raw:

  • compile_call_expr's obj_Method.call(...) arm (line 13362).
  • compile_poly_method_call's inline Method-dispatch fallback for poly-recv shapes (line 21791).

Both now check the arg's static type and unbox via sp_bigint_to_int when bigint, matching the existing poly unbox.

Promote-mode test count: 508 pass / 46 fail / 64 error -> 508 pass / 47 fail / 63 error. Default raise mode unchanged at 618 / 0 / 0.

Co-Authored-By: Claude Opus 4.7 [email protected]

Details

Commit
c8b87a1eacf0
Parent
145d121fb15c

spinel_codegen.rbmodifiedView file

@@ -13354,7 +13354,15 @@
1335413354 aargs = get_args(args_id)
1335513355 k = 0
1335613356 while k < aargs.length
13357- joined = joined + ", " + compile_expr(aargs[k])
13357+ # Method's bound C function has the fixed `(void *self,
13358+ # mrb_int...)` ABI; promote-widened bigint args need
13359+ # unbox before being passed through.
13360+ arg_v_bm = compile_expr(aargs[k])
13361+ if infer_type(aargs[k]) == "bigint"
13362+ @needs_bigint = 1
13363+ arg_v_bm = "sp_bigint_to_int((sp_Bigint *)" + arg_v_bm + ")"
13364+ end
13365+ joined = joined + ", " + arg_v_bm
1335813366 sig_args = sig_args + ", mrb_int"
1335913367 k = k + 1
1336013368 end
@@ -21784,6 +21792,9 @@
2178421792 ai_val = arg_compiled[mi]
2178521793 if mi < arg_types.length && arg_types[mi] == "poly"
2178621794 ai_val = "(" + ai_val + ").v.i"
21795+ elsif mi < arg_types.length && arg_types[mi] == "bigint"
21796+ @needs_bigint = 1
21797+ ai_val = "sp_bigint_to_int((sp_Bigint *)" + ai_val + ")"
2178721798 end
2178821799 call_args = call_args + ", " + ai_val
2178921800 mi = mi + 1