public interface Assumption
Assumption.invalidate()
). Once
invalidated, an assumption can never get valid again. Assumptions can be created using the
TruffleRuntime.createAssumption()
or the TruffleRuntime.createAssumption(String)
method. The Truffle compiler has special knowledge of this class in order to produce efficient
machine code for checking an assumption in case the assumption object is a compile time constant.
Therefore, assumptions should be stored in final fields in Truffle nodes.
All instances of classes implementing Assumption
must be held in final
fields for
compiler optimizations to take effect.Modifier and Type | Method and Description |
---|---|
void |
check()
Checks that this assumption is still valid.
|
String |
getName()
A name for the assumption that is used for debug output.
|
void |
invalidate()
Invalidates this assumption.
|
default void |
invalidate(String message)
Invalidates this assumption.
|
boolean |
isValid()
Checks whether the assumption is still valid.
|
static boolean |
isValidAssumption(Assumption assumption)
Checks whether an assumption is not
null and valid. |
static boolean |
isValidAssumption(Assumption[] assumptions)
Checks whether all assumptions in an array are not
null and valid. |
void check() throws InvalidAssumptionException
Assumption.isValid()
method when writing
guest language interpreter code. The catch block should perform a node rewrite (see
Node.replace(Node)
) with a node that no longer relies on the assumption.InvalidAssumptionException
- If the assumption is no longer valid.boolean isValid()
void invalidate()
default void invalidate(String message)
message
- a message stating the reason of the invalidationString getName()
static boolean isValidAssumption(Assumption assumption)
null
and valid.static boolean isValidAssumption(Assumption[] assumptions)
null
and valid. Returns
false
if the assumptions array itself is null
. This method is
designed for compilation. Note that the provided assumptions array must be a compilation
final array with dimensions
set to one.