Class ExecutionEventNode
java.lang.Object
com.oracle.truffle.api.nodes.Node
com.oracle.truffle.api.instrumentation.ExecutionEventNode
- All Implemented Interfaces:
NodeInterface
,Cloneable
An event node created by an
ExecutionEventNodeFactory
for a specific locations of a guest
language program to listen to instrumentation events. In addition to
listeners
event nodes allow to store state for a particular
program location
.- Since:
- 0.12
-
Nested Class Summary
Nested classes/interfaces inherited from class com.oracle.truffle.api.nodes.Node
Node.Child, Node.Children
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final EventContext
getInputContext
(int index) Returns the event context of an input by index.protected final int
Returns the total number of instrumented input nodes that may produceinput events
when executed.protected final Object[]
getSavedInputValues
(VirtualFrame frame) Returns all saved input values.protected void
onDispose
(VirtualFrame frame) Invoked when an event node is removed from the AST.protected void
onEnter
(VirtualFrame frame) Invoked immediately before theinstrumented node
is executed.protected void
onInputValue
(VirtualFrame frame, EventContext inputContext, int inputIndex, Object inputValue) Invoked immediately after each return value event of instrumented input child node that match theinput filter
.protected void
onResume
(VirtualFrame frame) Invoked on a resume of the execution on the current thread after ayield
.protected void
onReturnExceptional
(VirtualFrame frame, Throwable exception) Invoked immediately after the execution of aninstrumented node
resulted in an exception.protected void
onReturnValue
(VirtualFrame frame, Object result) Invoked immediately after aninstrumented node
is successfully executed.protected Object
onUnwind
(VirtualFrame frame, Object info) Invoked when aninstrumented node
is unwound from the execution stack byunwind throwable
thrown in this node implementation.protected void
onYield
(VirtualFrame frame, Object value) Invoked on a yield of the current thread.protected final void
saveInputValue
(VirtualFrame frame, int inputIndex, Object inputValue) Saves an input value reported byonInputValue(VirtualFrame, EventContext, int, Object)
for use in later events.Methods inherited from class com.oracle.truffle.api.nodes.Node
accept, adoptChildren, atomic, atomic, copy, deepCopy, getChildren, getCost, getDebugProperties, getDescription, getEncapsulatingSourceSection, getLock, getParent, getRootNode, getSourceSection, insert, insert, isAdoptable, isSafelyReplaceableBy, notifyInserted, onReplace, replace, replace, reportPolymorphicSpecialize, reportReplace, toString
-
Constructor Details
-
ExecutionEventNode
protected ExecutionEventNode()- Since:
- 0.12
-
-
Method Details
-
onEnter
Invoked immediately before theinstrumented node
is executed. The order in which multiple event listeners are notified matches the order they areattached
.- Parameters:
frame
- the current frame used in the instrumented node- Since:
- 0.12
-
onInputValue
protected void onInputValue(VirtualFrame frame, EventContext inputContext, int inputIndex, Object inputValue) Invoked immediately after each return value event of instrumented input child node that match theinput filter
. Whether, when and how often input child value events are triggered depends on the semantics of the instrumented node. For example, if the instrumented node represents binary arithmetic then two input value events will be triggered for index0
and1
. For short-circuited child values not all input child nodes may be executed therefore they might not trigger events forall inputs
. For instrumented loop nodes input value events with the sameindex
may be triggered many times.The total number of input nodes that may produce input events can be accessed using
getInputCount()
. Other input contexts than the currently input context can be accessed usinggetInputContext(int)
.Input values can be
saved
to make themgetSavedInputValues(VirtualFrame)
accessible inonReturn
oronReturnExceptional
events.- Parameters:
frame
- the current frame in useinputContext
- the event context of the input child nodeinputIndex
- the child index of the inputinputValue
- the return value of the input child- Since:
- 0.33
- See Also:
-
onReturnValue
Invoked immediately after aninstrumented node
is successfully executed. The order in which multiple event listeners are notified matches the order they areattached
.- Parameters:
frame
- the frame that was used for executing instrumented node- Since:
- 0.12
-
onReturnExceptional
Invoked immediately after the execution of aninstrumented node
resulted in an exception. Note that this could be aControlFlowException
, which is expected and considered a successful execution of the node. The order in which multiple event listeners are notified matches the order they areattached
.- Parameters:
frame
- the frame that was used for executing instrumented nodeexception
- the exception that occurred during the node's execution- Since:
- 0.12
-
onUnwind
Invoked when aninstrumented node
is unwound from the execution stack byunwind throwable
thrown in this node implementation. Any nodes between the instrumented ones are unwound off without any notification. The default implementation returnsnull
to indicate continue unwind.- Parameters:
frame
- the frame that was used for executing instrumented nodeinfo
- an info associated with the unwind - the object passed toEventContext.createUnwind(Object)
- Returns:
null
to continue to unwind the parent node,ProbeNode.UNWIND_ACTION_REENTER
to reenter the current node, or an interop value to return that value early from the current node (void nodes just return, ignoring the return value).- Since:
- 0.31
-
onYield
Invoked on a yield of the current thread. A yield interrupts the current execution, which isresumed
later on. Delegates toonReturnValue(VirtualFrame, Object)
by default.- Parameters:
frame
- the frame that was used for executing instrumented node- Since:
- 24.0
-
onResume
Invoked on a resume of the execution on the current thread after ayield
. Delegates toonEnter(VirtualFrame)
by default.Use
TruffleInstrument.Env.isSameFrame(RootNode, Frame, Frame)
to match the interrupted and resumed execution.- Parameters:
frame
- the frame that was used for executing instrumented node- Since:
- 24.0
-
onDispose
Invoked when an event node is removed from the AST. This happens if the underlying binding, language/instrument or engine is disposed. Event nodes are removed lazily. This means thatonDispose(VirtualFrame)
is invoked the next time the particular part of the AST is executed. If theinstrumented node
is not invoked anymore after it was disposed thenonDispose(VirtualFrame)
might or might not be executed.- Parameters:
frame
- the frame that was used for executing instrumented node- Since:
- 0.12
-
getInputContext
Returns the event context of an input by index. The returned input context matches the input context provided inonInputValue(VirtualFrame, EventContext, int, Object)
. The total number of instrumented input nodes can be accessed usinggetInputCount()
. This method returns a constant event context for a constant input index, when called in partially evaluated code paths.- Parameters:
index
- the context index- Throws:
IndexOutOfBoundsException
- if the index is out of bounds.- Since:
- 0.33
- See Also:
-
getInputCount
protected final int getInputCount()Returns the total number of instrumented input nodes that may produceinput events
when executed.- Since:
- 0.33
- See Also:
-
saveInputValue
Saves an input value reported byonInputValue(VirtualFrame, EventContext, int, Object)
for use in later events. Saved input values can be restored usinggetSavedInputValues(VirtualFrame)
inonReturn
oronReturnExceptional
events. The implementation ensures that a minimal number of frame slots is used to save input values. It uses the AST structure to reuse frame slots efficiently whenever possible. The used frame slots are freed if the event binding isdisposed
.- Parameters:
frame
- the frame to store the input value ininputIndex
- the child input indexinputValue
- the input value- Throws:
IllegalArgumentException
- for invalid input indexes for non-existing input nodes.- Since:
- 0.33
- See Also:
-
getSavedInputValues
Returns all saved input values. For valid input indices that did not save any valuenull
is returned. If all inputs were filtered or anull
input filter was provided then an empty array is returned.- Parameters:
frame
- the frame to read the input values from.- Since:
- 0.33
- See Also:
-