Class CompilerAsserts
java.lang.Object
com.oracle.truffle.api.CompilerAsserts
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 Summary
Modifier and TypeMethodDescriptionstatic <T> voidcompilationConstant(Object value) Assertion that the corresponding value is reduced to a constant during compilation.static voidAssertion that this code position should never be reached during compilation.static voidneverPartOfCompilation(String message) Assertion that this code position should never be reached during compilation.static <T> voidpartialEvaluationConstant(boolean value) Specialized version ofcompilationConstant(Object)forbooleanvalues.static <T> voidpartialEvaluationConstant(double value) Specialized version ofcompilationConstant(Object)fordoublevalues.static <T> voidpartialEvaluationConstant(float value) Specialized version ofcompilationConstant(Object)forfloatvalues.static <T> voidpartialEvaluationConstant(int value) Specialized version ofcompilationConstant(Object)forintvalues.static <T> voidpartialEvaluationConstant(long value) Specialized version ofcompilationConstant(Object)forlongvalues.static <T> voidpartialEvaluationConstant(Object value) Assertion that the corresponding value is reduced to a constant during the initial partial evaluation phase.
-
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. SeeCompilerDirectives.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
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. SeeCompilerDirectives.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
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 usepartialEvaluationConstant(Object)and its specialized variants.- Parameters:
value- the value that must be constant during compilation- Since:
- 0.8 or earlier
- See Also:
-
partialEvaluationConstant
Assertion that the corresponding value is reduced to a constant during the initial partial evaluation phase. Compared withcompilationConstant(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 ofcompilationConstant(Object)forbooleanvalues.- 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 ofcompilationConstant(Object)forintvalues.- 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 ofcompilationConstant(Object)forfloatvalues.- 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 ofcompilationConstant(Object)forlongvalues.- 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 ofcompilationConstant(Object)fordoublevalues.- Parameters:
value- the value that must be constant during partial evaluation.- Since:
- 19.3
- See Also:
-