Package com.oracle.truffle.api.dsl
Interface ExecuteTracingSupport
public interface ExecuteTracingSupport
Allows tracing of calls to
execute
methods of a Node
.
The methods declared in this interface are invoked by the code generated by Truffle DSL for nodes
which directly or indirectly implement this interface. All tracing methods are called only if
isTracingEnabled()
returns true
.
Example:
abstract static class BaseNode extends Node implements ExecuteTracingSupport {
static final TruffleLogger LOGGER = TruffleLogger.getLogger("id", "trace");
@Override
public boolean isTracingEnabled() {
return LOGGER.isLoggable(Level.INFO);
}
@Override
public void traceOnEnter(Object[] arguments) {
// called before any execute method
}
@Override
public void traceOnReturn(Object returnValue) {
// called after any execute method if it returns normally
}
@Override
public void traceOnException(Throwable t) {
// called after any execute method which throws an exception
}
}
abstract static class Operation1Node extends BaseNode {
// any execute call would automatically be traced
public abstract Object execute(int arg0, Object arg1);
@Specialization
int doInt(int a, int b) {
return a + b;
}
}
- Since:
- 21.3
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Invoked by the generated code to determine whether tracing is enabled.default void
traceOnEnter
(Object[] arguments) Invoked by the generatedexecute
methods before anySpecialization
is called, but after allNodeChildren
are evaluated.default void
Invoked by the generatedexecute
methods when aSpecialization
throws an exception.default void
traceOnReturn
(Object returnValue) Invoked by the generatedexecute
methods when aSpecialization
returns normally.
-
Method Details
-
isTracingEnabled
boolean isTracingEnabled()Invoked by the generated code to determine whether tracing is enabled. If tracing is disabled, no other methods in this interface will be invoked.- Returns:
true
if tracing is enabled- Since:
- 21.3
-
traceOnEnter
Invoked by the generatedexecute
methods before anySpecialization
is called, but after allNodeChildren
are evaluated. Called only ifisTracingEnabled()
returnstrue
.- Parameters:
arguments
- the arguments of the specialization except the frame, if any- Since:
- 21.3
-
traceOnReturn
Invoked by the generatedexecute
methods when aSpecialization
returns normally. Called only ifisTracingEnabled()
returnstrue
.- Parameters:
returnValue
- the value returned by the specialization ornull
if theexecute
method is declared to returnvoid
- Since:
- 21.3
-
traceOnException
Invoked by the generatedexecute
methods when aSpecialization
throws an exception. Called only ifisTracingEnabled()
returnstrue
. Exceptions thrown by child node invocations are not traced by the parent.- Parameters:
t
- the exception thrown by the specialization- Since:
- 21.3
-