Warning: This is the manual of the legacy Guile 2.2 series. You may want to read the manual of the current stable series instead.
Next: Trampoline Instructions, Previous: Procedure Call and Return Instructions, Up: Instruction Set [Contents][Index]
A function call in Guile is very cheap: the VM simply hands control to the procedure. The procedure itself is responsible for asserting that it has been passed an appropriate number of arguments. This strategy allows arbitrarily complex argument parsing idioms to be developed, without harming the common case.
For example, only calls to keyword-argument procedures “pay” for the cost of parsing keyword arguments. (At the time of this writing, calling procedures with keyword arguments is typically two to four times as costly as calling procedures with a fixed set of arguments.)
If the number of actual arguments is not ==
, >=
, or
<=
expected, respectively, signal an error.
The number of arguments is determined by subtracting the stack pointer
from the frame pointer (fp - sp
). See Stack Layout, for more
details on stack frames. Note that expected includes the
procedure itself.
If the number of actual arguments is not equal, less than, or greater than expected, respectively, add offset, a signed 24-bit number, to the current instruction pointer. Note that expected includes the procedure itself.
These instructions are used to implement multiple arities, as in
case-lambda
. See Case-lambda, for more information.
Ensure that there is space on the stack for nlocals local
variables, setting them all to SCM_UNDEFINED
, except those values
that are already on the stack.
Like alloc-frame
, but doesn’t check that the stack is big enough,
and doesn’t initialize values to SCM_UNDEFINED
. Used to reset
the frame size to something less than the size that was previously set
via alloc-frame.
Equivalent to a sequence of assert-nargs-ee
and
reserve-locals
. The number of locals reserved is expected
+ nlocals.
Find the first positional argument after nreq. If it is greater than npos, jump to offset.
This instruction is only emitted for functions with multiple clauses,
and an earlier clause has keywords and no rest arguments.
See Case-lambda, for more on how case-lambda
chooses the
clause to apply.
flags is a bitfield, whose lowest bit is allow-other-keys, second bit is has-rest, and whose following six bits are unused.
Find the last positional argument, and shuffle all the rest above
ntotal. Initialize the intervening locals to
SCM_UNDEFINED
. Then load the constant at kw-offset words
from the current ip, and use it and the allow-other-keys
flag to bind keyword arguments. If has-rest, collect all shuffled
arguments into a list, and store it in nreq-and-opt. Finally,
clear the arguments that we shuffled up.
The parsing is driven by a keyword arguments association list, looked up
using kw-offset. The alist is a list of pairs of the form
(kw . index)
, mapping keyword arguments to their
local slot indices. Unless allow-other-keys
is set, the parser
will signal an error if an unknown key is found.
A macro-mega-instruction.
Collect any arguments at or above dst into a list, and store that list at dst.
Next: Trampoline Instructions, Previous: Procedure Call and Return Instructions, Up: Instruction Set [Contents][Index]