Next: , Up: Instruction Set   [Contents][Index] Lexical Environment Instructions

These instructions access and mutate the lexical environment of a compiled procedure—its free and bound variables. See Stack Layout, for more information on the format of stack frames.

Instruction: mov s12:dst s12:src
Instruction: long-mov s24:dst x8:_ s24:src

Copy a value from one local slot to another.

As discussed previously, procedure arguments and local variables are allocated to local slots. Guile’s compiler tries to avoid shuffling variables around to different slots, which often makes mov instructions redundant. However there are some cases in which shuffling is necessary, and in those cases, mov is the thing to use.

Instruction: long-fmov f24:dst x8:_ f24:src

Copy a value from one local slot to another, but addressing slots relative to the fp instead of the sp. This is used when shuffling values into place after multiple-value returns.

Instruction: make-closure s24:dst l32:offset x8:_ c24:nfree

Make a new closure, and write it to dst. The code for the closure will be found at offset words from the current ip. offset is a signed 32-bit integer. Space for nfree free variables will be allocated.

The size of a closure is currently two words, plus one word per free variable.

Instruction: free-ref s12:dst s12:src x8:_ c24:idx

Load free variable idx from the closure src into local slot dst.

Instruction: free-set! s12:dst s12:src x8:_ c24:idx

Set free variable idx from the closure dst to src.

This instruction is usually used when initializing a closure’s free variables, but not to mutate free variables, as variables that are assigned are boxed.

Recall that variables that are assigned are usually allocated in boxes, so that continuations and closures can capture their identity and not their value at one point in time. Variables are also used in the implementation of top-level bindings; see the next section for more information.

Instruction: box s12:dst s12:src

Create a new variable holding src, and place it in dst.

Instruction: box-ref s12:dst s12:src

Unpack the variable at src into dst, asserting that the variable is actually bound.

Instruction: box-set! s12:dst s12:src

Set the contents of the variable at dst to set.

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