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.CompilationFinal
semantics. Though an interpreter can useLoadConstant
operations 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). Instrumentation
andProlog
operations 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.
Except for RootNode
s, 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 ElementDescriptionint
Specifies the number of array dimensions to be marked as compilation final.Optional documentation for the constant operand.Optional name for the constant operand.boolean
By default, when an operation has dynamic operands, the constant operands appear before them in signatures and must be supplied to the operation'sbegin
method 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, when an operation has dynamic operands, the constant operands appear before them in signatures and must be supplied to the operation'sbegin
method of theBytecodeBuilder
. WhenspecifyAtEnd()
istrue
, the constant operand instead appears after dynamic operands and is supplied to the operation'send
method (constant operands to theProlog
can be supplied to theendRoot
method).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
emit
method. The exception to this rule isProlog
s, which can receive their operands as arguments to eitherbeginRoot
orendRoot
.- 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
-