Though most applicable objects in Guile are procedures implemented in
bytecode, not all are. There are primitives, continuations, and other
procedure-like objects that have their own calling convention. Instead
of adding special cases to the
call instruction, Guile wraps
these other applicable objects in VM trampoline procedures, then
provides special support for these objects in bytecode.
Trampoline procedures are typically generated by Guile at runtime, for
example in response to a call to
scm_c_make_gsubr. As such, a
compiler probably shouldn’t emit code with these instructions. However,
it’s still interesting to know how these things work, so we document
these trampoline instructions here.
Call a subr, passing all locals in this frame as arguments. Return from the calling frame.
Call a foreign function. Fetch the cif and foreign pointer from cif-idx and ptr-idx, both free variables. Return from the calling frame. Arguments are taken from the stack.
Return to a continuation, nonlocally. The arguments to the continuation are taken from the stack. contregs is a free variable containing the reified continuation.
Compose a partial continution with the current continuation. The arguments to the continuation are taken from the stack. cont is a free variable containing the reified continuation.
Tail-apply the procedure in local slot 0 to the rest of the arguments.
This instruction is part of the implementation of
apply, and is
not generated by the compiler.
Load a builtin stub by index into dst.