Class HostCompilerDirectives


public final class HostCompilerDirectives extends Object
Directives that influence the optimizations of the host compiler. These operations affect how the Truffle interpreter is itself compiled.
  • Method Details

    • inInterpreterFastPath

      public static boolean inInterpreterFastPath()
      Indicates whether a branch is executed only in the interpreter. In addition to CompilerDirectives.inInterpreter(), this method instructs the host compiler to treat the positive branch as frequently executed code of high importance. Branches protected by this method should be treated as if they were runtime compiled code paths, even if they may never actually be compiled. This means that slow-paths must be protected using either CompilerDirectives.transferToInterpreterAndInvalidate() or CompilerDirectives.TruffleBoundary.

      A common use case for this directive is in counting condition profiles, where counters must be protected by CompilerDirectives.inInterpreter() but also need to be optimized as fast-path by the host compiler. Without this directive, the host compiler may treat the branch as a slow-path branch.

      true if executed in the interpreter, false in compiled code.