L1Operation
An L1Operation is encoded within a nybblecode stream as an opcode followed by operands. Opcodes less than 16 are encoded as a single nybble, and the others are represented as the extension nybble (15), followed by the opcode minus 16. This supports up to 31 distinct nybblecodes, the statically most frequently occurring of which should be assigned to the first 15 values (0-14) for compactness.
The operands are encoded in such a way that very small values occupy a single nybble, but values up to Integer.MAX_VALUE are supported efficiently.
Author
Mark van Gulik
Parameters
This operation's ordinal.
This operation's list of operand types.
Entries
Pop the stack, writing the value directly to the current continuation in the indicated local slot.
Invoke a method with a supercall.
Permute the top N stack elements based on the literal which is an N-tuple of distinct integers in 1..N (i.e., a permutation). The mutability of the values is unaffected.
Duplicate the top stack element (i.e., push another occurrence of the top of stack}. Make the object immutable since it now has an additional reference.
Pop the stack and write the value into a variable literal. This is used to write to module variables.
Get the value of a variable literal. This is used only to read from module variables.
Push a continuation just like the current one, such that if it is ever resumed it will have the same effect as restarting the current one.
Process an extension nybblecode, which involves consuming the next nybble and dispatching it as though 16 were added to it.
Push the current value of the specified outer variable of the function.
Pop the specified number of elements from the stack and assemble them into a tuple. Push the tuple.
Push the value of the specified local variable or constant. Make it immutable, since it may still be needed by subsequent instructions.
Pop the stack and write it to the specified outer variable of the function.
Push the current value of the specified outer variable. The outer variable is part of the function being executed. Clear this outer variable if it is mutable.
Push the specified outer variable of the function.
Extract the value from the specified local variable or constant. If the variable is mutable, null it out in the continuation. Raise a suitable runtime exception if the variable does not have a value.
Pop the stack and write the value into the specified local variable.
Create a function from the specified number of pushed outer variables and the specified literal compiled code.
Push an outer variable, i.e. a variable lexically captured by the current function. This should be the last use of the variable, so clear it from the function if the function is still mutable.
Push a local variable -- not its value, but the variable itself. If an argument or constant is specified then push the value, since there is no actual variable to operate on.
Push a local variable -- not its value, but the variable itself. This should be the last use of the variable, so erase it from the continuation at the same time.
Push the literal whose index is specified by the operand.
Types
Functions
Dispatch this operation through an L1OperationDispatcher.
Write this operation to a NybbleOutputStream. Do not output operands.