L2SimpleInstruction

sealed class L2SimpleInstruction : L2AbstractInstruction

L2SimpleInstruction is the abstract class for a simplified level two instruction set. It acts as a very lightweight translation of level one nybblecodes. Its invalidation machinery is managed by L2Chunk, so it subscribes to method dependencies the same way as for full chunks that are translated to JVMChunks.

Very little optimization is performed, at this level. Type deduction helps eliminate spurious checks that would be necessary if method definitions could be added or removed, but the invalidation mechanism handles that. Calls can often be statically transformed to simple monomorphic invocation, avoiding the dispatch trees. When the target is proven to be monomorphic, some primitives can be directly embedded (e.g., P_InvokeWithTuple), if they can be proven not to fail, skipping unnecessary type safety checks. Similarly, unnecessary return type checks can often be omitted as well.

There is no register coloring, dead code elimination, special rewriting of most primitives, or reworking into unboxed integer or floating point operations. Folding is attempted, however, if a monomorphic call indicates it would be a Primitive function with the Flag.CanFold flag set.

Flow is linear, and each instruction is responsible for handling reification, if it can happen. Boxed register values are maintained in an array, in the same manner as for L1InstructionStepper. The current function occupies register[0], then the frame slots.

Author

Mark van Gulik

Functions

Link copied to clipboard
fun fieldValueToString(value: Any?): String

Generate a suitable print representation of the value.

Link copied to clipboard
open fun reenter(registers: Array<AvailObject>, interpreter: Interpreter): StackReifier?

A previously constructed continuation is being resumed in some way, and the instruction just before the continuation's L2 offset has been asked to do anything specific to reentering the continuation. For example, a method call might be forced to reify the stack, but at resumption time (i.e., when "returning" into it), it will still need to check the type of the "returned" value against the expected type.

Link copied to clipboard
abstract fun step(registers: Array<AvailObject>, interpreter: Interpreter): StackReifier?

Perform this instruction, a single step of an L2SimpleChunk. The mutable Array of AvailObjects acts as a simple set of registers. Element 0 is the current function, and the remaining elements correspond with the continuation slots, should one need to be constructed.

Link copied to clipboard
open override fun toString(): String

Inheritors

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard