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 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

      default void traceOnEnter(Object[] arguments)
      Invoked by the generated execute methods before any Specialization is called, but after all NodeChildren are evaluated. Called only if isTracingEnabled() returns true.
      Parameters:
      arguments - the arguments of the specialization except the frame, if any
      Since:
      21.3
    • traceOnReturn

      default void traceOnReturn(Object returnValue)
      Invoked by the generated execute methods when a Specialization returns normally. Called only if isTracingEnabled() returns true.
      Parameters:
      returnValue - the value returned by the specialization or null if the execute method is declared to return void
      Since:
      21.3
    • traceOnException

      default void traceOnException(Throwable t)
      Invoked by the generated execute methods when a Specialization throws an exception. Called only if isTracingEnabled() returns true. Exceptions thrown by child node invocations are not traced by the parent.
      Parameters:
      t - the exception thrown by the specialization
      Since:
      21.3