Skip to content

Commit 91a0b41

Browse files
olwangclaude
andcommitted
feat(vm-jit): native-call ABI slice 4 core — mutual-recursion group compile
The "declare a cycle before defining" mechanism for native mutual recursion. - New `JitInstr::CallGroup { group_index, dst, args }`: a mutually-recursive call to a co-compiled group member (by index), since a sibling's id isn't minted until the whole cycle is declared. - `NativeModule::compile_recursive_group(&[JitFunction])`: declares every member's FuncId first, then builds+defines each with CallGroup resolving to the declared ids, then finalizes once. Returns one CompiledId per member. - The entry depth guard now fires for group members too (has_call_self || has_call_group) — mutual native recursion consumes the host C stack just like self-recursion, so the cap keeps a cycle from overflowing it (the failure mode is a crash). CallGroup is non-chaining (re-run-from-top deopt) like CallSelf, with its own callee-sized scratch slots (discarded on bail). - Extracted `push_compiled_abi_signature` so the CompiledAbi is defined once. Unit test `native_mutual_recursion_group_computes_and_caps_depth`: is_even/is_odd co-compiled, run natively (correct), and deep mutual recursion bails cleanly at the cap (no host-stack overflow). vm-jit 83/0, differential 33/0, default build OK. Next: reg-vm wiring (SCC detection + dispatch + translate CallGroup emission) to run mutual recursion natively from rss source end-to-end. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 01ab4dc commit 91a0b41

1 file changed

Lines changed: 382 additions & 27 deletions

File tree

0 commit comments

Comments
 (0)