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


9.3.7.4 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 c24:idx

Call a subr, passing all locals in this frame as arguments, and storing the results on the stack, ready to be returned.

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

Call a foreign function. Fetch the cif and foreign pointer from cif-idx and ptr-idx closure slots of the callee. Arguments are taken from the stack, and results placed on the stack, ready to be returned.

Instruction: builtin-ref s12:dst c12:idx

Load a builtin stub by index into dst.