Class BytecodeRootNodes<T extends RootNode & BytecodeRootNode>
- Type Parameters:
T- the type of the bytecode root node
BytecodeRootNodes instance encapsulates one or more bytecode root nodes produced from a
single parse. To reduce interpreter footprint, it supports on-demand reparsing to compute source
and instrumentation metadata.
This class will be overridden by the Bytecode DSL. Do not override manually.
- Since:
- 24.2
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBytecodeRootNodes(Object token, BytecodeParser<? extends BytecodeBuilder> parser) Default constructor for aBytecodeBuilder. -
Method Summary
Modifier and TypeMethodDescriptionfinal intcount()Returns the number of root nodes produced from the parse.final booleanChecks if the sources are present, and if not, reparses to get them.final booleanEnsures that sources are available, reparsing if necessary.final TgetNode(int i) Returns the bytecode root node at indexi.getNodes()Returns the list of bytecode root nodes.protected final BytecodeParser<? extends BytecodeBuilder> Returns the parser used to parse the root nodes.voidserialize(DataOutput buffer, BytecodeSerializer callback) Serializes the nodes to a byte buffer.toString()Returns a string representation of aBytecodeRootNodes.final booleanupdate(BytecodeConfig config) Updates the configuration for the given bytecode nodes.protected abstract booleanupdateImpl(BytecodeConfigEncoder encoder, long encoding) Implementation of reparse.
-
Field Details
-
TOKEN
A singleton object used to ensure certain Bytecode DSL APIs are only used by generated code.- Since:
- 24.2
-
nodes
The array of parsed nodes.- Since:
- 24.2
-
-
Constructor Details
-
BytecodeRootNodes
Default constructor for aBytecodeBuilder.- Since:
- 24.2
-
-
Method Details
-
getNodes
Returns the list of bytecode root nodes. The order of the list corresponds to the order ofendRoot()calls on the builder.- Since:
- 24.2
-
getNode
Returns the bytecode root node at indexi. The order of the list corresponds to the order ofendRoot()calls on the builder.- Since:
- 24.2
-
count
public final int count()Returns the number of root nodes produced from the parse.- Since:
- 24.2
-
getParser
Returns the parser used to parse the root nodes.- Since:
- 24.2
-
update
Updates the configuration for the given bytecode nodes. If the new configuration requires more information (e.g., sources, instrumentation or tags), may trigger a reparse to obtain it.Performance considerations: Updating and adding instrumentations or tags is a costly operation and requires reparsing all
root nodesof aBytecodeRootNodesunit. Reparsing and modifying the generated bytecodes will also deoptimize and invalidate all currently optimized code of the reparsed root nodes. It also may or may not reset all profiling feedback gathered so far. Updating and adding just source information is a much less expensive operation and does not require any invalidation, but also requires to reparse all root nodes. Since compiled code is not invalidated when source information is added (and hence theBytecodeNodeis not updated), lazily updated source information should not be accessed in compiled code.Usage in compiled code: This method may be used in compiled code, but the bytecode config must be a
partial evaluation constant. If the bytecode config is changed in compiled code thendeoptimizationwill be triggered. If an update does not require any operation then this operation will be a no-op in compiled code. In the interpreter it is also reasonably fast (read and compare of a volatile field), for example it should reasonable to call this method repeatedly in theprolog.- Since:
- 24.2
-
updateImpl
Implementation of reparse.This method will be generated by the Bytecode DSL. Do not override.
- Since:
- 24.2
-
serialize
Serializes the nodes to a byte buffer. This method will always fail unless serialization isenabled.Unlike the static
serializemethod defined on the generated root node, this method serializes the nodes using their current field values.This method will be overridden by the Bytecode DSL. Do not override.
- Parameters:
buffer- The buffer to write the serialized bytes to.callback- A language-defined method for serializing language constants.- Throws:
IOException- if an I/O error occurs with the buffer.
-
ensureSourceInformation
public final boolean ensureSourceInformation()Ensures that sources are available, reparsing if necessary.- Since:
- 24.2
-
ensureComplete
public final boolean ensureComplete()Checks if the sources are present, and if not, reparses to get them.- Since:
- 24.2
-
toString
Returns a string representation of aBytecodeRootNodes.
-