Skip to main content

plg_rt_metacall_resolve

Function plg_rt_metacall_resolve 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn plg_rt_metacall_resolve( m: *mut Machine, goal: u64, ) -> u64
Expand description

Fast-path resolver for the metacall trampoline (#23): if goal is a simple compiled-predicate call (after peeling a single call/1 wrapper), marshal its arguments and return the entry function pointer as an integer for generated IR to musttail into — giving call(pred(...)) tail recursion constant C stack, like a direct call. Returns 0 for anything the full walker must handle (builtins, control constructs, call/N with extra args, variables, undefined predicates); the caller then falls back to plg_rt_metacall, which is bounded by the depth guard in call_goal.

Sets qbarrier exactly as plg_rt_metacall does, so cut-transparency of call/N is identical on both paths. The fast path does NOT bump metacall_depth: a musttail into the resolved entry leaves no walker frame to bound (only the slow path re-enters call_goal, which guards).

§Safety

Called from generated code with the live Machine pointer.