Next: , Previous: , Up: Instruction Set   [Contents][Index]


9.3.7.5 Trampoline Instructions

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.

Instruction: subr-call u24:ptr-idx

Call a subr, passing all locals in this frame as arguments. Fetch the foreign pointer from ptr-idx, a free variable. Return from the calling frame.

Instruction: foreign-call u12:cif-idx u12:ptr-idx

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.

Instruction: continuation-call u24:contregs

Return to a continuation, nonlocally. The arguments to the continuation are taken from the stack. contregs is a free variable containing the reified continuation.

Instruction: compose-continuation u24:cont

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.

Instruction: tail-apply x24:_

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.

Instruction: builtin-ref u12:dst u12:idx

Load a builtin stub by index into dst.


Next: , Previous: , Up: Instruction Set   [Contents][Index]