L2Simple Translator
An L2SimpleTranslator produces a fast translation from L1 nybblecodes into a sequence of L2SimpleInstructions within an L2SimpleExecutableChunk.
Author
Mark van Gulik
Constructors
Properties
The L1InstructionDecoder that provides L1 operations and operands.
The list of L2SimpleInstructions being generated.
The current program counter, taken from the instructionDecoder.
The types of the registers at this point.
Functions
Create an L2Chunk. This must only be performed while interpreters are able to run. Invalidation happens within safe-points, because that's when method definitions can be added and removed.
n,m - Send the message at index n in the compiledCode's literals. Pop the arguments for this message off the stack (the message itself knows how many to expect). The first argument was pushed first, and is the deepest on the stack. Use these arguments to look up the method dynamically. Before invoking the method, push nil onto the stack. Its presence will help distinguish continuations produced by the pushLabel instruction from their senders. When the call completes (if ever) by using an implicit return instruction, it will replace this nil with the result of the call.
n,m - Pop the top n items off the stack, and use them as outer variables in the construction of a function based on the compiledCode that's the literal at index m of the current compiledCode.
The extension nybblecode was encountered. Read another nybble and dispatch it as an extended instruction.
n - Push the value of the local variable (not an argument) indexed by n (index 1 is first argument).
n - Push the value of the local variable (not an argument) indexed by n (index 1 is first argument). If the variable itself is mutable, clear it now - nobody will know.
n - Push the value of the outer variable indexed by n in the current function.
n - Push the value of the outer variable indexed by n in the current function. If the variable itself is mutable, clear it at this time - nobody will know.
n - Make a tuple from n values popped from the stack. Push the tuple.
n - Push the argument (actual value) or local variable (the variable itself) indexed by n. Since this is known to be the last use (non-debugger) of the argument or local, void that slot of the current continuation.
n - Push the outer variable indexed by n in the current function. If the variable is mutable, clear it (no one will know). If the variable and function are both mutable, remove the variable from the function by voiding it.
n - Push the literal indexed by n in the current compiledCode.
n - Push the argument (actual value) or local variable (the variable itself) indexed by n.
n - Push the outer variable indexed by n in the current function.
n - Pop the stack and assign this value to the local variable (not an argument) indexed by n (index 1 is first argument).
n - Pop the stack and assign this value to the outer variable indexed by n in the current function.
Duplicate the element at the top of the stack. Make the element immutable since there are now at least two references.
n - Push the value of the variable that's literal number n in the current compiledCode.
n - Permute the top n stack elements as specified by a literal permutation tuple. For example, if A, B, and C have been pushed, in that order, a permute tuple of <2, 3, 1> indicates the stack should have A in the 2nd slot, B in the 3rd, and C in the 1st. It has the same effect as having pushed C, and A, and B, in that order.
Build a continuation which, when restarted, will be just like restarting the current continuation.
n - Pop the stack and assign this value to the variable that's the literal indexed by n in the current compiledCode.
Pop the stack, writing the value directly into the indicated local slot. This is how local constants become initialized.
Invoke a method with a supercall.