public final class ProbeNode extends Node
Represents an event sink for instrumentation events that is embedded in the AST using wrappers if
needed. Instances of this class are provided by
InstrumentableFactory.createWrapper(Node, ProbeNode) to notify the instrumentation API
about execution events.
wrapper nodes looks as
follows:
@Override
public Object execute(VirtualFrame frame) {
try {
probeNode.onEnter(frame);
Object returnValue = delegate.execute(frame);
probeNode.onReturnValue(frame, returnValue);
return returnValue;
} catch (Throwable t) {
probeNode.onReturnExceptional(frame, t);
throw t;
}
}
Node.Child, Node.Children| Modifier and Type | Method and Description |
|---|---|
NodeCost |
getCost()
Returns a rough estimate for the cost of this
Node. |
void |
onEnter(VirtualFrame frame)
Should get invoked before the node is invoked.
|
void |
onReturnExceptional(VirtualFrame frame,
Throwable exception)
Should get invoked if the node did not complete successfully.
|
void |
onReturnValue(VirtualFrame frame,
Object result)
Should get invoked after the node is invoked successfully.
|
accept, adoptChildren, atomic, atomic, copy, deepCopy, getChildren, getDebugProperties, getDescription, getEncapsulatingSourceSection, getLock, getParent, getRootNode, getSourceSection, insert, insert, isSafelyReplaceableBy, isTaggedWith, onReplace, replace, replace, toStringpublic void onEnter(VirtualFrame frame)
frame - the current frame of the execution.public void onReturnValue(VirtualFrame frame, Object result)
result - the result value of the operationframe - the current frame of the execution.public void onReturnExceptional(VirtualFrame frame, Throwable exception)
exception - the exception that occurred during the executionframe - the current frame of the execution.public NodeCost getCost()
NodeNode. This estimate can be used by
runtime systems or guest languages to implement heuristics based on Truffle ASTs. This method
is intended to be overridden by subclasses. The default implementation returns the value of
NodeInfo.cost() of the NodeInfo annotation declared at the subclass. If no
NodeInfo annotation is declared the method returns NodeCost.MONOMORPHIC as a
default value.