Interface ExecutionEventListener
public interface ExecutionEventListener
A listener attached by an
Instrumenter
to specific locations of a guest language program
to listen to execution events.- Since:
- 0.12
-
Method Summary
Modifier and TypeMethodDescriptionvoid
onEnter
(EventContext context, VirtualFrame frame) Invoked immediately before theinstrumented node
is executed.default void
onInputValue
(EventContext context, VirtualFrame frame, EventContext inputContext, int inputIndex, Object inputValue) Deprecated.in 20.0.default void
onResume
(EventContext context, VirtualFrame frame) Invoked on a resume of the execution on the current thread after ayield
.void
onReturnExceptional
(EventContext context, VirtualFrame frame, Throwable exception) Invoked immediately after aninstrumented node
did not successfully execute.void
onReturnValue
(EventContext context, VirtualFrame frame, Object result) Invoked immediately after aninstrumented node
is successfully executed.default Object
onUnwind
(EventContext context, VirtualFrame frame, Object info) Invoked when aninstrumented node
is unwound from the execution stack byunwind throwable
thrown in this listener instance.default void
onYield
(EventContext context, VirtualFrame frame, Object value) Invoked on a yield of the current thread.
-
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:
context
- indicating the current location in the guest language ASTframe
- the frame that was used for executing instrumented node- Since:
- 0.12
-
onInputValue
@Deprecated(since="20.0") default void onInputValue(EventContext context, VirtualFrame frame, EventContext inputContext, int inputIndex, Object inputValue) Deprecated.in 20.0. input value notifications are not functional forlisteners
. Useevent node factories
instead.Invoked immediately after each return value event of child nodes that match theinput filter
. Event listeners cannot save input values for later events. If that is required attach an event node factory instead.- Parameters:
context
- indicating the current location in the guest language ASTframe
- 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.30
-
onReturnValue
Invoked immediately after aninstrumented node
is successfully executed. The order in which multiple event listeners are notified matches the order they areattached
.- Parameters:
context
- indicating the current location in the guest language ASTframe
- the frame that was used for executing instrumented node- Since:
- 0.12
-
onReturnExceptional
Invoked immediately after aninstrumented node
did not successfully execute. The order in which multiple event listeners are notified matches the order they areattached
.When the
exception
is an instance ofThreadDeath
the execution was abruptly interrupted.EventContext.createUnwind(Object)
creates aThreadDeath
to unwind nodes off, for instance. Listener instances that threw an unwind throwable get calledonUnwind(EventContext, VirtualFrame, Object)
instead.- Parameters:
context
- indicating the current location in the guest language ASTframe
- 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 listener instance. Any nodes between the instrumented ones are unwound off without any notification. The default implementation returnsnull
.- Parameters:
context
- indicating the current location in the guest language ASTframe
- 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(EventContext, VirtualFrame, Object)
by default.- Parameters:
context
- indicating the current location in the guest language ASTframe
- 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(EventContext, VirtualFrame)
by default.Use
TruffleInstrument.Env.isSameFrame(RootNode, Frame, Frame)
to match the interrupted and resumed execution.- Parameters:
context
- indicating the current location in the guest language ASTframe
- the frame that was used for executing instrumented node- Since:
- 24.0
-