Annotation Interface ConstantOperand
Operation, Instrumentation, and Prolog operations.
Constant operands have a few benefits:
- In contrast to dynamic operands, which are computed by executing the "children" of an operation at run time, constant operands are specified at parse time and require no run-time computation.
- Constant operands have
CompilerDirectives.CompilationFinalsemantics. Though an interpreter can useLoadConstantoperations to supply dynamic operands, those constants are not guaranteed to be compilation-final (the constant is pushed onto and then popped from the stack, which PE cannot always constant fold). InstrumentationandPrologoperations are restricted and cannot encode arbitrary dynamic operands. Constant operands can be used to encode other information needed by these operations.
type() of
the constant operand.
When parsing the operation, a constant must be supplied as an additional parameter to the
begin or emit method of the BytecodeBuilder. Constant operands to the
Prolog should be supplied to the beginRoot method (or endRoot if the
operand is specified at the end).
Except for RootNodes, a constant operand cannot be a subclass of Node. If an
operation needs a compilation-final node operand, it can declare a NodeFactory constant
operand and then declare a Cached parameter initialized with the result of
createNode.
- Since:
- 24.2
-
Nested Class Summary
Nested Classes -
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionintSpecifies the number of array dimensions to be marked as compilation final.Optional documentation for the constant operand.Optional name for the constant operand.booleanBy default, constant operands appear before dynamic operands and are specified to the operation'sbeginmethod of theBytecodeBuilder.
-
Element Details
-
type
Class<?> typeThe type of the constant operand. All specializations must declare a parameter with this exact type.- Since:
- 24.2
-
name
String nameOptional name for the constant operand. When this field is not provided, the Bytecode DSL will infer a name from the specializations' parameters.- Since:
- 24.2
- Default:
""
-
javadoc
String javadocOptional documentation for the constant operand. This documentation is included in the javadoc for the generated interpreter.- Since:
- 24.2
- Default:
""
-
specifyAtEnd
boolean specifyAtEndBy default, constant operands appear before dynamic operands and are specified to the operation'sbeginmethod of theBytecodeBuilder. WhenspecifyAtEnd()istrue, the constant operand instead appears after dynamic operands and is specified to the operation'sendmethod.In some cases, it may be more convenient to specify a constant operand after parsing the child operations; for example, the constant may only be known after traversing child ASTs.
This flag is meaningless if the operation does not take dynamic operands, since all constant operands will be supplied to a single
emitmethod (except forPrologs, which receive their operands as arguments toandinvalid reference
beginRoot).invalid reference
endRoot- Since:
- 24.2
- Default:
false
-
dimensions
int dimensionsSpecifies the number of array dimensions to be marked as compilation final. SeeCompilerDirectives.CompilationFinal.dimensions().The Bytecode DSL currently only supports a value of 0; that is, array elements are not compilation-final.
- Since:
- 24.2
- Default:
0
-