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 Node
Node.Child, Node.Children -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final EventContextgetInputContext(int index) Returns the event context of an input by index.protected final intReturns the total number of instrumented input nodes that may produceinput eventswhen executed.protected final Object[]getSavedInputValues(VirtualFrame frame) Returns all saved input values.protected voidonDispose(VirtualFrame frame) Invoked when an event node is removed from the AST.protected voidonEnter(VirtualFrame frame) Invoked immediately before theinstrumented nodeis executed.protected voidonInputValue(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 voidonResume(VirtualFrame frame) Invoked on a resume of the execution on the current thread after ayield.protected voidonReturnExceptional(VirtualFrame frame, Throwable exception) Invoked immediately after the execution of aninstrumented noderesulted in an exception.protected voidonReturnValue(VirtualFrame frame, Object result) Invoked immediately after aninstrumented nodeis successfully executed.protected ObjectonUnwind(VirtualFrame frame, Object info) Invoked when aninstrumented nodeis unwound from the execution stack byunwind throwablethrown in this node implementation.protected voidonYield(VirtualFrame frame, Object value) Invoked on a yield of the current thread.protected final voidsaveInputValue(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 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 nodeis 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 index0and1. 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 sameindexmay 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
savedto make themgetSavedInputValues(VirtualFrame)accessible inonReturnoronReturnExceptionalevents.- 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 nodeis 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 noderesulted 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 nodeis unwound from the execution stack byunwind throwablethrown in this node implementation. Any nodes between the instrumented ones are unwound off without any notification. The default implementation returnsnullto 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:
nullto continue to unwind the parent node,ProbeNode.UNWIND_ACTION_REENTERto 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 isresumedlater 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 nodeis 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 eventswhen 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)inonReturnoronReturnExceptionalevents. 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 valuenullis returned. If all inputs were filtered or anullinput filter was provided then an empty array is returned.- Parameters:
frame- the frame to read the input values from.- Since:
- 0.33
- See Also:
-