Class Instruction
Compatibility note: The data contained in instruction classes is subject to change without notice between Truffle versions. This introspection API is therefore intended to be used for debugging and tracing purposes only. Do not rely on instructions for your language semantics.
The current instruction can be bound using @Bind Instruction instruction from
operations. This class is not intended to be subclassed by clients, only by
code generated by the Bytecode DSL.
- Since:
- 24.2
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents metadata for an argument of an instruction in a bytecode node. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstruction(Object token) Internal constructor for generated code. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanabstract List<Instruction.Argument> Returns an immutable list of immediate arguments for this instructions.abstract intReturns the bytecode index of this instruction.abstract BytecodeNodeReturns the bytecode node this instruction belongs to.abstract intReturns the length of this instruction in bytes.final BytecodeLocationConverts this instruction pointer into a bytecode location.abstract StringgetName()Returns the name of this instruction.final intReturns the bytecode index of the next instruction.abstract intReturns the operation code of this instruction.final SourceSectionReturns the most concrete source section associated with this instruction.final SourceSection[]Returns all source section associated with this instruction starting with the most concrete source section.final inthashCode()abstract booleanReturnstrueif this instruction represents a bytecode or tag instrumentation instruction, elsefalse.protected abstract Instructionnext()Returns the next instruction object.final StringtoString()
-
Constructor Details
-
Instruction
Internal constructor for generated code. Do not use.- Since:
- 24.2
-
-
Method Details
-
getBytecodeNode
Returns the bytecode node this instruction belongs to.- Since:
- 24.2
-
getBytecodeIndex
public abstract int getBytecodeIndex()Returns the bytecode index of this instruction. A bytecode index is only valid for a givenBytecodeNode, it is therefore recommended to usegetLocation()instead whenever possible.- Since:
- 24.2
-
getLength
public abstract int getLength()Returns the length of this instruction in bytes.- Since:
- 24.2
-
getLocation
Converts this instruction pointer into a bytecode location. It is recommended to useBytecodeLocationto persist a bytecode location instead of using instruction.- Since:
- 24.2
-
getName
Returns the name of this instruction. The name of the instruction is purely for human consumption and no structure should be assumed. If two instructions have the same instruction name then they also have the sameoperation code.The name is fixed for an
Instructionobject, but the name of an instruction at a particularlocationcan change during execution due to quickening and other optimizations.- Since:
- 24.2
- See Also:
-
getOperationCode
public abstract int getOperationCode()Returns the operation code of this instruction. The operation code of the instruction is purely for human consumption and no values should be assumed. If two instructions have the same instruction operation code then they also have the samename.The operation code is fixed for an
Instructionobject, but the operation code of an instruction at a particularlocationcan change during execution due to quickening and other optimizations.- Since:
- 24.2
- See Also:
-
getArguments
Returns an immutable list of immediate arguments for this instructions. The number and kinds of arguments remain stable during execution, however, the actual values of the arguments (e.g.,Instruction.Argument.asBranchProfile()) may change during execution.- Since:
- 24.2
-
isInstrumentation
public abstract boolean isInstrumentation()Returnstrueif this instruction represents a bytecode or tag instrumentation instruction, elsefalse. Instrumentation instructions may get inserted dynamically during execution, e.g., if a tag is materialized or anInstrumentationisconfigured.- Since:
- 24.2
-
getSourceSection
Returns the most concrete source section associated with this instruction. If no source section is available for this instruction or source sections have not yet been materialized, thennullis returned. Source sections may be materialized by callingupdatewithBytecodeConfig.WITH_SOURCE.- Since:
- 24.2
-
getSourceSections
Returns all source section associated with this instruction starting with the most concrete source section. If no source sections are available, then an empty array is returned. If source sections have not yet been materialized, thennullis returned. Source sections may be materialized by callingupdatewithBytecodeConfig.WITH_SOURCE.- Since:
- 24.2
-
getNextBytecodeIndex
public final int getNextBytecodeIndex()Returns the bytecode index of the next instruction. This method is useful to quickly find the next instruction. The next bytecode index is computed as.getBytecodeIndex()+getLength()The next bytecode index may not be a valid index if this instruction is the last instruction. Use
BytecodeNode.getInstructions()to walk all instructions efficiently and safely. Since the bytecode encoding is variable length, there is no efficient way to get to the previous bytecode index. Only forward traversial is efficient. If random access is desired useBytecodeNode.getInstructionsAsList().- Since:
- 24.2
-
next
Returns the next instruction object. Implemented by generated code, intended for internal use only.- Since:
- 24.2
-
hashCode
-
equals
-
toString
-