L2PcOperand

class L2PcOperand(targetBlock: L2BasicBlock, var isBackward: Boolean, manifest: L2ValueManifest? = null, val optionalName: String? = null) : L2Operand

An L2PcOperand is an operand of type L2OperandType.PC. It refers to a target L2BasicBlock, that either be branched to at runtime, or captured in some other way that flow control may end up there.

Author

Mark van Gulik

Constructors

Link copied to clipboard
constructor(targetBlock: L2BasicBlock, isBackward: Boolean, manifest: L2ValueManifest? = null, optionalName: String? = null)

Construct a new L2PcOperand that leads to the specified L2BasicBlock. Set isBackward to true if this is a back-link to a loop head,

Properties

Link copied to clipboard

The Set of L2Registers that are written in all pasts, and are consumed along all future paths after the start of this block. This is only populated during optimization, while the control flow graph is still in SSA form.

Link copied to clipboard

A counter of how many times this edge has been traversed. This will be used to determine the amount of effort to apply to subsequent re-optimization attempts, modulating inlining, order of tests, whether to optimize for space, run time, or compile time; that sort of thing. The counter itself (a LongAdder) is passed as a constant through a special class loader, and captured as a final constant within the L2Chunk's class.

Link copied to clipboard

Either null, the normal case, or a set with each L2Entity/RegisterKind that is allowed to pass along this edge. This mechanism is used to break control flow cycles, allowing a simple liveness algorithm to be used, instead of iterating (backward) through loops until the live set has converged.

Link copied to clipboard

Answer the L2Instruction containing this operand.

Link copied to clipboard

Answer whether this write operand has been written yet as the destination of some instruction.

Link copied to clipboard

Whether this edge points backward to a block marked as L2BasicBlock.isLoopHead, thereby closing a loop.

Link copied to clipboard

Answer whether this operand is misconnected to its L2Instruction.

Link copied to clipboard
open override val operandType: L2OperandType

Answer this operand's L2OperandType.

Link copied to clipboard
val optionalName: String? = null
Link copied to clipboard

The Set of L2Registers that are written in all pasts, and are consumed along at least one future after the start of this block. This is only populated during optimization, while the control flow graph is still in SSA form.

Functions

Link copied to clipboard
open fun addDestinationRegistersTo(destinationRegisters: MutableList<L2Register>)

Move any registers used as destinations within me into the provided list.

Link copied to clipboard
open fun addReadsTo(readOperands: MutableList<L2ReadOperand<*>>)

Capture all L2ReadOperands within this operand into the provided List.

Link copied to clipboard
open fun addSourceRegistersTo(sourceRegisters: MutableList<L2Register>)

Move any registers used as sources within me into the provided list.

Link copied to clipboard
open fun addWritesTo(writeOperands: MutableList<L2WriteOperand<*>>)

Capture all L2WriteOperands within this operand into the provided List.

Link copied to clipboard
open override fun adjustCloneForInstruction(theInstruction: L2Instruction)

This is a freshly cloned operand. Adjust it for use in the given L2Instruction. Note that the new instruction has not yet been installed into an L2BasicBlock.

Link copied to clipboard
open override fun appendTo(builder: StringBuilder)

Write a description of this operand to the given StringBuilder.

Link copied to clipboard
fun appendWithWarningsTo(builder: StringBuilder, indent: Int, warningStyleChange: (Boolean) -> Unit)

Append a textual representation of this operand to the provided StringBuilder. If a style change is appropriate while building the string, invoke the warningStyleChange lambda with true to enable the warning style, and false to turn it off again.

Link copied to clipboard

Assert that this operand knows its instruction, which should always be the case if the instruction has already been emitted.

Link copied to clipboard
open override fun clone(): L2Operand
Link copied to clipboard
fun createAndPushRegisterDumpArrays(translator: JVMTranslator, method: MethodVisitor, skipIfEmpty: Boolean): Boolean

Write JVM bytecodes to the JVMTranslator which will push:

Link copied to clipboard
open override fun dispatchOperand(dispatcher: L2OperandDispatcher)

Dispatch this L2Operand to the provided L2OperandDispatcher.

Link copied to clipboard

Create and install a LongAdder to count visits through this edge in the final JVM code.

Link copied to clipboard
open override fun instructionWasAdded(manifest: L2ValueManifest)

This is an operand of the given instruction, which was just added to its basic block. Its instruction was just set.

Link copied to clipboard
open override fun instructionWasInserted(newInstruction: L2Instruction)

This is an operand of the given instruction, which was just inserted into its basic block as part of an optimization pass.

Link copied to clipboard
open override fun instructionWasRemoved()

This is an operand of the given instruction, which was just removed from its basic block.

Link copied to clipboard

Answer the L2ValueManifest for this edge, which describes which L2Registers hold which L2SemanticValues.

Link copied to clipboard

If the L2ValueManifest has not yet been stripped from the containing chunk, answer it, otherwise answer null.

Link copied to clipboard
fun offset(): Int

Answer the L2 offset at the start of the L2BasicBlock that this operand refers to.

Link copied to clipboard
open override fun postOptimizationCleanup()

Now that chunk optimization has completed, remove information from this instruction that will no longer be needed in the finished chunk. Note that during subsequent inlining of this chunk at a call site, the type and synonym information will be reconstructed without too much cost.

Link copied to clipboard
open override fun replaceRegisters(registerRemap: Map<L2Register, L2Register>, theInstruction: L2Instruction)

Replace occurrences in this operand of each register that is a key of this map with the register that is the corresponding value. Do nothing to registers that are not keys of the map. Update all secondary structures, such as the instruction's source/destination collections.

Link copied to clipboard
open fun setInstruction(theInstruction: L2Instruction?)

Set the instructionOrNull field.

Link copied to clipboard

Answer the source L2BasicBlock that this operand is an edge from.

Link copied to clipboard

Create a new L2BasicBlock that will be the new target of this edge, and write an L2_JUMP into the new block to jump to the old target of this edge. Be careful to maintain predecessor order at the target block.

Link copied to clipboard
fun switchTargetBlockNonSSA(newTarget: L2BasicBlock, isBackwardFlag: Boolean)

In a non-SSA control flow graph that has had its phi functions removed and converted to moves, switch the target of this edge.

Link copied to clipboard

Answer the target L2BasicBlock that this operand refers to.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open fun transformEachRead(transformer: (L2ReadOperand<*>) -> L2ReadOperand<*>): L2Operand

Transform each L2ReadOperand through the given lambda, producing either a new L2Operand of the same type, or the receiver.