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 class
Represents metadata for an argument of an instruction in a bytecode node. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Instruction
(Object token) Internal constructor for generated code. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
abstract List
<Instruction.Argument> Returns an immutable list of immediate arguments for this instructions.abstract int
Returns the bytecode index of this instruction.abstract BytecodeNode
Returns the bytecode node this instruction belongs to.abstract int
Returns the length of this instruction in bytes.final BytecodeLocation
Converts this instruction pointer into a bytecode location.abstract String
getName()
Returns the name of this instruction.final int
Returns the bytecode index of the next instruction.abstract int
Returns the operation code of this instruction.final SourceSection
Returns 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 int
hashCode()
abstract boolean
Returnstrue
if this instruction represents a bytecode or tag instrumentation instruction, elsefalse
.protected abstract Instruction
next()
Returns the next instruction object.final String
toString()
-
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
- See Also:
-
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 useBytecodeLocation
to 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
Instruction
object, but the name of an instruction at a particularlocation
can 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
Instruction
object, but the operation code of an instruction at a particularlocation
can 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()Returnstrue
if 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 anInstrumentation
isconfigured
.- 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, thennull
is returned. Source sections may be materialized by callingupdate
withBytecodeConfig.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, thennull
is returned. Source sections may be materialized by callingupdate
withBytecodeConfig.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
-