Class ProbeNode
java.lang.Object
com.oracle.truffle.api.nodes.Node
com.oracle.truffle.api.instrumentation.ProbeNode
- All Implemented Interfaces:
NodeInterface
,Cloneable
Represents an event sink for instrumentation events that is embedded in the AST using wrappers if
needed. Instances of this class are provided by
InstrumentableNode.createWrapper(ProbeNode)
to notify the instrumentation API about
execution events.
GenerateWrapper
to generate implementations of wrapper
nodes. If needed to be done manually then the recommended implementation of an execute method
looks as follows:
@Override public Object execute(VirtualFrame frame) { Object returnValue; for (;;) { boolean wasOnReturnExecuted = false; try { probeNode.onEnter(frame); returnValue = delegateNode.executeGeneric(frame); wasOnReturnExecuted = true; probeNode.onReturnValue(frame, returnValue); break; } catch (Throwable t) { Object result = probeNode.onReturnExceptionalOrUnwind(frame, t, wasOnReturnExecuted); if (result == ProbeNode.UNWIND_ACTION_REENTER) { continue; } else if (result != null) { returnValue = result; break; } throw t; } } return returnValue; }
- Since:
- 0.12
-
Nested Class Summary
Nested classes/interfaces inherited from class com.oracle.truffle.api.nodes.Node
Node.Child, Node.Children
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Object
A constant that performs reenter of the current node when returned fromExecutionEventListener.onUnwind(EventContext, VirtualFrame, Object)
orExecutionEventNode.onUnwind(VirtualFrame, Object)
. -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Creates a shallow copy of this node.void
onEnter
(VirtualFrame frame) Should get invoked before the node is invoked.void
onResume
(VirtualFrame frame) Should be invoked when execution is resumed after ayield
.onReturnExceptionalOrUnwind
(VirtualFrame frame, Throwable exception, boolean isReturnCalled) Should get invoked if the node did not complete successfully and handle a possible unwind.void
onReturnValue
(VirtualFrame frame, Object result) Should get invoked after the node is invoked successfully.void
onYield
(VirtualFrame frame, Object result) Should be invoked when the node yields execution.Methods inherited from class com.oracle.truffle.api.nodes.Node
accept, adoptChildren, atomic, atomic, deepCopy, getChildren, getCost, getDebugProperties, getDescription, getEncapsulatingSourceSection, getLock, getParent, getRootNode, getSourceSection, insert, insert, isAdoptable, isSafelyReplaceableBy, notifyInserted, onReplace, replace, replace, reportPolymorphicSpecialize, toString
-
Field Details
-
UNWIND_ACTION_REENTER
A constant that performs reenter of the current node when returned fromExecutionEventListener.onUnwind(EventContext, VirtualFrame, Object)
orExecutionEventNode.onUnwind(VirtualFrame, Object)
.- Since:
- 0.31
-
-
Method Details
-
onEnter
Should get invoked before the node is invoked.- Parameters:
frame
- the current frame of the execution.- Since:
- 0.12
-
onReturnValue
Should get invoked after the node is invoked successfully.- Parameters:
frame
- the current frame of the execution.result
- the result value of the operation, must be an interop type (i.e. either implementing TruffleObject or be a primitive value), ornull
.- Since:
- 0.12
-
copy
Creates a shallow copy of this node. -
onReturnExceptionalOrUnwind
public Object onReturnExceptionalOrUnwind(VirtualFrame frame, Throwable exception, boolean isReturnCalled) Should get invoked if the node did not complete successfully and handle a possible unwind. When a non-null
value is returned, a change of the execution path was requested by anunwind
.- Parameters:
frame
- the current frame of the execution.exception
- the exception that occurred during the executionisReturnCalled
-true
whenonReturnValue(VirtualFrame, Object)
was called already for this node's execution,false
otherwise. This helps to assure correct pairing of enter/return notifications.- Returns:
null
to proceed to throw of the exception,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
Should be invoked when the node yields execution. UseGenerateWrapper.yieldExceptions()
when possible, to haveonYield()
called automatically.When the yielded execution is resumed, call
onResume(VirtualFrame)
, or useGenerateWrapper.resumeMethodPrefix()
.- Parameters:
frame
- the current frame of the execution.- Since:
- 24.0
-
onResume
Should be invoked when execution is resumed after ayield
. UseGenerateWrapper.resumeMethodPrefix()
when possible, to have this method called automatically by the wrapper node.Override
RootNode.isSameFrame(Frame, Frame)
if necessary, to be able to match the yielded and resumed executions.- Parameters:
frame
- the current frame of the execution.- Since:
- 24.0
-