public interface 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.
|
java.lang.String |
getName()
A name for the assumption that is used for debug output.
|
void |
invalidate()
Invalidates this assumption.
|
boolean |
isValid()
Checks whether the assumption is still valid.
|
void check() throws InvalidAssumptionException
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()
java.lang.String getName()