L2SimpleTranslator

class L2SimpleTranslator(val code: A_RawFunction, nextOptimizationLevel: OptimizationLevel, val interpreter: Interpreter) : L1OperationDispatcher

An L2SimpleTranslator produces a fast translation from L1 nybblecodes into a sequence of L2SimpleInstructions within an L2SimpleExecutableChunk.

Author

Mark van Gulik

Constructors

Link copied to clipboard
constructor(code: A_RawFunction, nextOptimizationLevel: OptimizationLevel, interpreter: Interpreter)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val pc: Int

The current program counter, taken from the instructionDecoder.

Link copied to clipboard

The types of the registers at this point.

Link copied to clipboard
var stackp: Int

The current operand stack pointer during code generation.

Functions

Link copied to clipboard
fun add(instruction: L2SimpleInstruction)
Link copied to clipboard

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.

Link copied to clipboard
open override fun L1_doCall()

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.

Link copied to clipboard
open override fun L1_doClose()

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.

Link copied to clipboard
open override fun L1_doExtension()

The extension nybblecode was encountered. Read another nybble and dispatch it as an extended instruction.

Link copied to clipboard
open override fun L1_doGetLocal()

n - Push the value of the local variable (not an argument) indexed by n (index 1 is first argument).

Link copied to clipboard
open override fun L1_doGetLocalClearing()

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.

Link copied to clipboard
open override fun L1_doGetOuter()

n - Push the value of the outer variable indexed by n in the current function.

Link copied to clipboard
open override fun L1_doGetOuterClearing()

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.

Link copied to clipboard
open override fun L1_doMakeTuple()

n - Make a tuple from n values popped from the stack. Push the tuple.

Link copied to clipboard
open override fun L1_doPop()

Remove the top item from the stack.

Link copied to clipboard
open override fun L1_doPushLastLocal()

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.

Link copied to clipboard
open override fun L1_doPushLastOuter()

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.

Link copied to clipboard
open override fun L1_doPushLiteral()

n - Push the literal indexed by n in the current compiledCode.

Link copied to clipboard
open override fun L1_doPushLocal()

n - Push the argument (actual value) or local variable (the variable itself) indexed by n.

Link copied to clipboard
open override fun L1_doPushOuter()

n - Push the outer variable indexed by n in the current function.

Link copied to clipboard
open override fun L1_doSetLocal()

n - Pop the stack and assign this value to the local variable (not an argument) indexed by n (index 1 is first argument).

Link copied to clipboard
open override fun L1_doSetOuter()

n - Pop the stack and assign this value to the outer variable indexed by n in the current function.

Link copied to clipboard
open override fun L1Ext_doDuplicate()

Duplicate the element at the top of the stack. Make the element immutable since there are now at least two references.

Link copied to clipboard
open override fun L1Ext_doGetLiteral()

n - Push the value of the variable that's literal number n in the current compiledCode.

Link copied to clipboard
open override fun L1Ext_doPermute()

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.

Link copied to clipboard
open override fun L1Ext_doPushLabel()

Build a continuation which, when restarted, will be just like restarting the current continuation.

Link copied to clipboard
open override fun L1Ext_doSetLiteral()

n - Pop the stack and assign this value to the variable that's the literal indexed by n in the current compiledCode.

Link copied to clipboard
open override fun L1Ext_doSetLocalSlot()

Pop the stack, writing the value directly into the indicated local slot. This is how local constants become initialized.

Link copied to clipboard
open override fun L1Ext_doSuperCall()

Invoke a method with a supercall.