Package com.oracle.truffle.api.nodes
Class RootNode
- java.lang.Object
-
- com.oracle.truffle.api.nodes.Node
-
- com.oracle.truffle.api.nodes.RootNode
-
- All Implemented Interfaces:
NodeInterface
,java.lang.Cloneable
public abstract class RootNode extends Node
A root node is a node with a method to execute it given only a frame as a parameter. Therefore, a root node can be used to create a call target usingTruffleRuntime.createCallTarget(RootNode)
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.oracle.truffle.api.nodes.Node
Node.Child, Node.Children
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RootNode()
protected
RootNode(SourceSection sourceSection)
protected
RootNode(SourceSection sourceSection, FrameDescriptor frameDescriptor)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
applyInstrumentation()
Apply all registered instances ofASTProber
to the AST, if any, held by this root node.Node
copy()
Creates a shallow copy of this node.abstract java.lang.Object
execute(VirtualFrame frame)
Executes this function using the specified frame and returns the result value.RootCallTarget
getCallTarget()
CompilerOptions
getCompilerOptions()
Get compiler options specific to thisRootNode
.ExecutionContext
getExecutionContext()
Returns theExecutionContext
associated with thisRootNode
.FrameDescriptor
getFrameDescriptor()
boolean
isCloningAllowed()
Returnstrue
if thisRootNode
is allowed to be cloned.void
reportLoopCount(int count)
Reports the execution count of a loop that is a child of this node.void
setCallTarget(RootCallTarget callTarget)
-
Methods inherited from class com.oracle.truffle.api.nodes.Node
accept, adoptChildren, assignSourceSection, atomic, atomic, clearSourceSection, clone, getChildren, getCost, getDebugProperties, getDescription, getEncapsulatingSourceSection, getLanguage, getParent, getRootNode, getSourceSection, insert, insert, isReplaceable, onAdopt, onReplace, replace, replace, toString
-
-
-
-
Constructor Detail
-
RootNode
protected RootNode()
-
RootNode
protected RootNode(SourceSection sourceSection)
-
RootNode
protected RootNode(SourceSection sourceSection, FrameDescriptor frameDescriptor)
-
-
Method Detail
-
isCloningAllowed
public boolean isCloningAllowed()
Returnstrue
if thisRootNode
is allowed to be cloned. The runtime system might decide to create deep copies of theRootNode
in order to gather context sensitive profiling feedback. The default implementation returnsfalse
. Guest language specific implementations may want to returntrue
here to indicate that gathering call site specific profiling information might make sense for thisRootNode
.- Returns:
true
if cloning is allowed elsefalse
.
-
reportLoopCount
public final void reportLoopCount(int count)
Reports the execution count of a loop that is a child of this node. The optimization heuristics can use the loop count to guide compilation and inlining.
-
execute
public abstract java.lang.Object execute(VirtualFrame frame)
Executes this function using the specified frame and returns the result value.- Parameters:
frame
- the frame of the currently executing guest language method- Returns:
- the value of the execution
-
getCallTarget
public final RootCallTarget getCallTarget()
-
getFrameDescriptor
public final FrameDescriptor getFrameDescriptor()
-
setCallTarget
public final void setCallTarget(RootCallTarget callTarget)
-
getExecutionContext
public ExecutionContext getExecutionContext()
Returns theExecutionContext
associated with thisRootNode
. This allows the correctExecutionContext
to be determined for aRootNode
(and so also for aRootCallTarget
and aFrameInstance
obtained from the call stack) without prior knowledge of the language it has come from. Used for instance to determine the language of aRootNode
:
rootNode.getExecutionContext().getLanguageShortName();
null
by default.
-
getCompilerOptions
public CompilerOptions getCompilerOptions()
Get compiler options specific to thisRootNode
.
-
applyInstrumentation
public void applyInstrumentation()
Apply all registered instances ofASTProber
to the AST, if any, held by this root node. This can only be done once the AST is complete, notably once all parent pointers are correctly assigned. But it also must be done before any AST cloning or execution.If this is not done, then the AST will not be subject to debugging or any other instrumentation-supported tooling.
Implementations should ensure that instrumentation is never applied more than once to an AST, as this is not guaranteed to be error-free.
-
-