L2Simple Instruction
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
Inheritors
Functions
Generate a suitable print representation of the value.
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.
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.