Class CompilerAsserts

java.lang.Object
com.oracle.truffle.api.CompilerAsserts

public final class CompilerAsserts extends Object
Assertions about the code produced by the Truffle compiler. All operations have no effect when either executed in the interpreter or in the compiled code. The assertions are checked during code generation and the Truffle compiler produces for failing assertions a stack trace that identifies the code position of the assertion in the context of the current compilation.
Since:
0.8 or earlier
  • Method Details

    • neverPartOfCompilation

      public static void neverPartOfCompilation()
      Assertion that this code position should never be reached during compilation. It can be used for exceptional code paths or rare code paths that should never be included in a compilation unit. See CompilerDirectives.transferToInterpreter() for the corresponding compiler directive.

      CompilerDirectives.bailout(String) should be used if failing compilation is desired, e.g., for testing. neverPartOfCompilation() must not be reachable for runtime compilation, see the TruffleCheckNeverPartOfCompilation option.

      Since:
      0.8 or earlier
    • neverPartOfCompilation

      public static void neverPartOfCompilation(String message)
      Assertion that this code position should never be reached during compilation. It can be used for exceptional code paths or rare code paths that should never be included in a compilation unit. See CompilerDirectives.transferToInterpreter() for the corresponding compiler directive.

      CompilerDirectives.bailout(String) should be used if failing compilation is desired, e.g., for testing. neverPartOfCompilation() must not be reachable for runtime compilation, see the TruffleCheckNeverPartOfCompilation option.

      Parameters:
      message - text associated with the bailout exception
      Since:
      0.8 or earlier
    • compilationConstant

      public static <T> void compilationConstant(Object value)
      Assertion that the corresponding value is reduced to a constant during compilation. This is, for example, useful to assert that an array has always the same size, although the actual value is only known at run-time. In most cases, it is preferred to use partialEvaluationConstant(Object) and its specialized variants.
      Parameters:
      value - the value that must be constant during compilation
      Since:
      0.8 or earlier
      See Also:
    • partialEvaluationConstant

      public static <T> void partialEvaluationConstant(Object value)
      Assertion that the corresponding value is reduced to a constant during the initial partial evaluation phase. Compared with compilationConstant(Object), the constantness of the value is checked much earlier in the compilation pipeline. It should therefore be preferred, also because its specialized variants avoid boxing.
      Parameters:
      value - the value that must be constant during compilation
      Since:
      0.8 or earlier
      See Also:
    • partialEvaluationConstant

      public static <T> void partialEvaluationConstant(boolean value)
      Specialized version of compilationConstant(Object) for boolean values.
      Parameters:
      value - the value that must be constant during partial evaluation.
      Since:
      19.3
      See Also:
    • partialEvaluationConstant

      public static <T> void partialEvaluationConstant(int value)
      Specialized version of compilationConstant(Object) for int values.
      Parameters:
      value - the value that must be constant during partial evaluation.
      Since:
      19.3
      See Also:
    • partialEvaluationConstant

      public static <T> void partialEvaluationConstant(float value)
      Specialized version of compilationConstant(Object) for float values.
      Parameters:
      value - the value that must be constant during partial evaluation.
      Since:
      19.3
      See Also:
    • partialEvaluationConstant

      public static <T> void partialEvaluationConstant(long value)
      Specialized version of compilationConstant(Object) for long values.
      Parameters:
      value - the value that must be constant during partial evaluation.
      Since:
      19.3
      See Also:
    • partialEvaluationConstant

      public static <T> void partialEvaluationConstant(double value)
      Specialized version of compilationConstant(Object) for double values.
      Parameters:
      value - the value that must be constant during partial evaluation.
      Since:
      19.3
      See Also: