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.
Pop off a foreign pointer (which should have been pushed on by the trampoline), and call it directly, with the nargs arguments from the stack. Return the resulting value or values to the calling procedure.
Pop off an internal foreign object (which should have been pushed on by the trampoline), and call that foreign function with the nargs arguments from the stack. Return the resulting value to the calling procedure.
Pop off an internal continuation object (which should have been pushed on by the trampoline), and reinstate that continuation. All of the procedure’s arguments are passed to the continuation. Does not return.
Pop off two objects from the stack: the dynamic winds associated with the partial continuation, and the VM continuation object. Unroll the continuation onto the stack, rewinding the dynamic environment and overwriting the current frame, and pass all arguments to the continuation. Control flow proceeds where the continuation was captured.