Package com.oracle.truffle.api
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> void
compilationConstant
(Object value) Assertion that the corresponding value is reduced to a constant during compilation.static void
Assertion that this code position should never be reached during compilation.static void
neverPartOfCompilation
(String message) Assertion that this code position should never be reached during compilation.static <T> void
partialEvaluationConstant
(boolean value) Specialized version ofcompilationConstant(Object)
forboolean
values.static <T> void
partialEvaluationConstant
(double value) Specialized version ofcompilationConstant(Object)
fordouble
values.static <T> void
partialEvaluationConstant
(float value) Specialized version ofcompilationConstant(Object)
forfloat
values.static <T> void
partialEvaluationConstant
(int value) Specialized version ofcompilationConstant(Object)
forint
values.static <T> void
partialEvaluationConstant
(long value) Specialized version ofcompilationConstant(Object)
forlong
values.static <T> void
partialEvaluationConstant
(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)
forboolean
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 ofcompilationConstant(Object)
forint
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 ofcompilationConstant(Object)
forfloat
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 ofcompilationConstant(Object)
forlong
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 ofcompilationConstant(Object)
fordouble
values.- Parameters:
value
- the value that must be constant during partial evaluation.- Since:
- 19.3
- See Also:
-