Commit fd76e665
fd76e6658c1dMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 2 files · ~2 modified
Description
fix(analyze,codegen): cls method adapter coerces bigint, skip Method ivar promote
Two follow-ups to the cls_method_return cache invalidate fix.
-
emit_cls_method_adapterhardcodedmrb_int _aNfor every adapter parameter and a raw pass-through call. When the wrapped class method's params (or return) got widened to bigint by promote mode, the adapter's call into the bigint signature broke (makes pointer from integer). The Method dispatch ABI is fixed at(void *, mrb_int...), so the adapter is the right place to bridge: wrap each bigint-typed arg throughsp_bigint_new_intand unwrap a bigint return viasp_bigint_to_intbefore handing back through the ABI. -
Skip the built-in
Methodclass inpromote_int_to_bigint_globally. Method's@fn_ptrivar holds a function pointer cast to mrb_int, andMethod#initializetakes that mrb_int as its second arg. Promoting either to bigint produced ansp_Method_new(sp_Method *, sp_Bigint *)signature that no call site matches —sp_Method_new((sp_Method *)0, (mrb_int)(uintptr_t)&adapter_fn)then fails-Werror=int-conversion.
Also bump @cls_meth_ptypes_version /
@cls_cmeth_ptypes_version inside
promote_int_to_bigint_globally so the cls_*_ptypes_get per-
class memoized splits re-read the now-promoted strings instead
of returning the stale pre-promotion split.
Promote-mode test count: 446 pass / 39 fail / 133 error -> 450 pass / 43 fail / 125 error. Default raise mode unchanged at 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- fd76e6658c1d
- Parent
- 9af973420183
spinel_analyze.rbmodifiedView file
# bigint). The cache has no version stamp, so wipe it whole — # next caller refills lazily off the now-promoted tables. @cls_meth_return_cache = {} # cls_meth_ptypes_get / cls_cmeth_ptypes_get use a per-class # memoized split keyed off @cls_meth_ptypes_version / # @cls_cmeth_ptypes_version. promote_meth_ptypes_table below # mutates the underlying join'd string in place, so bump both # version counters now to invalidate any cached split that # downstream readers might pick up. @cls_meth_ptypes_version = @cls_meth_ptypes_version + 1 @cls_cmeth_ptypes_version = @cls_cmeth_ptypes_version + 1 # Top-level methods. mi = 0 while mi < @meth_param_types.length # Class instance + class methods. ci = 0 while ci < @cls_names.length # The built-in Method class carries a raw function pointer in # @fn_ptr (cast to mrb_int) and `Method#initialize(self_obj, # fn_ptr)` takes that mrb_int. Promoting either to bigint # breaks dispatch (sp_Method_new expects a function-pointer- # shaped mrb_int, and the .call lowering reads @fn_ptr back as # mrb_int). Skip the whole class. if @cls_names[ci] == "Method" ci = ci + 1 next end promote_meth_ptypes_table(ci, @cls_meth_ptypes) promote_meth_returns_table(ci, @cls_meth_returns) if ci < @cls_cmeth_ptypes.lengthspinel_codegen.rbmodifiedView file
Loading diff…