L2SimpleChunk

class L2SimpleChunk : L2Chunk

A Level Two chunk represents a simply optimized implementation of an A_RawFunction. It's composed of L2SimpleInstructions, and doesn't have any deep optimizations. It does, however, attempt to eliminate dispatches for monomorphic call sites, as well as return type checks, whenever possible.

Author

Mark van Gulik

Parameters

instructions

The L2SimpleInstructions to execute.

code

The A_RawFunction that this is for, or null for the default chunk.

offsetAfterInitialTryPrimitive

The offset into my instructions at which to begin if this chunk's code was primitive and that primitive has already been attempted and failed.

contingentValues

The set of contingent values on which this chunk depends. If one of these changes significantly, this chunk must be invalidated (at which time this set will be emptied).

executableChunk

The L2SimpleExecutableChunk permanently associated with this L2SimpleChunk.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun beforeRunChunk(offset: Int)

Called just before running the JVMChunk inside this L2Chunk. This gives the opportunity for logging the chunk execution.

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

Dump the chunk to disk for debugging. This is expected to be called directly from the Kotlin debugger, and should result in the production of three files: JVMChunk_«uuid».l1, JVMChunk_«uuid».l2, and JVMChunk_«uuid».class. This momentarily sets the JVMTranslator.debugJVM flag to true, but restores it to its original value on return.

Link copied to clipboard
fun invalidate(reason: L2Chunk.InvalidationReason)

Something that this L2Chunk depended on has changed. This must have been because it was optimized in a way that relied on some aspect of the available definitions (e.g., monomorphic inlining), so we need to invalidate the chunk now, so that an attempt to invoke it or return into it will be detected and converted into using the unoptimizedChunk. Also remove this chunk from the contingent set of each object on which it was depending.

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

Properties

Link copied to clipboard
val chunkPojo: AvailObject

Answer the Avail pojo associated with this L2Chunk.

Link copied to clipboard
val code: A_RawFunction?

The code that was translated to L2. Null for the default (L1) chunk.

Link copied to clipboard
open override val executableChunk: L2SimpleExecutableChunk

The JVMChunk permanently associated with this L2Chunk.

Link copied to clipboard
var generation: L2Chunk.Generation?

An indication of how recently this chunk has been accessed, expressed as a reference to a Generation.

Link copied to clipboard
open override val instructions: List<L2SimpleInstruction>
Link copied to clipboard
val isValid: Boolean = true

A flag indicating whether this chunk is valid or if it has been invalidated by the addition or removal of a method signature. It doesn't have to be volatile, since it can only be set when Avail code execution is temporarily suspended in all fibers, which involves synchronization (and therefore memory coherence) before it can start running again.

Link copied to clipboard
val offsetAfterInitialTryPrimitive: Int

The level two offset at which to start if the corresponding A_RawFunction is a primitive, and it has already been attempted and failed. If it's not a primitive, this is the offset of the start of the code (0).

Link copied to clipboard
val weakReference: WeakReference<L2Chunk>

The WeakReference that points to this L2Chunk.