Package com.oracle.truffle.api.utilities
Class ConditionProfile
java.lang.Object
com.oracle.truffle.api.nodes.NodeCloneable
com.oracle.truffle.api.utilities.ConditionProfile
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
BinaryConditionProfile,CountingConditionProfile
Abstract utility class to speculate on conditions. Condition profiles are intended to be used as
part of if conditions.
Example usage:
private final ConditionProfile zero = ConditionProfile.createBinaryProfile();
int value = ...;
if (zero.profile(value == 0)) {
return 0;
} else {
return value;
}
All instances of ConditionProfile (and subclasses) must be held in final fields
for compiler optimizations to take effect.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ConditionProfileReturns aConditionProfilethat speculates on conditions to be never true or to be never false.static ConditionProfileabstract booleanprofile(boolean value) Methods inherited from class com.oracle.truffle.api.nodes.NodeCloneable
clone
-
Constructor Details
-
ConditionProfile
public ConditionProfile()
-
-
Method Details
-
profile
public abstract boolean profile(boolean value) -
createCountingProfile
Returns aConditionProfilethat speculates on conditions to be nevertrueor to be neverfalse. Additionally to a binary profile this method returns a condition profile that also counts the number of times the condition was true and false. This information is reported to the underlying optimization system usingCompilerDirectives.injectBranchProbability(double, boolean). Condition profiles are intended to be used as part of if conditions.- See Also:
-
createBinaryProfile
Returns aConditionProfilethat speculates on conditions to be never true or to be never false. Condition profiles are intended to be used as part of if conditions.- See Also:
-