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


9.3.7.1 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 u12:dst u12:src
Instruction: long-mov u24:dst x8:_ u24: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: make-closure u24:dst l32:offset x8:_ u24: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 u12:dst u12:src x8:_ u24:idx

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

Instruction: free-set! u12:dst u12:src x8:_ u24: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 u12:dst u12:src

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

Instruction: box-ref u12:dst u12:src

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

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

Set the contents of the variable at dst to set.


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