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:
java.lang.Cloneable
- Direct Known Subclasses:
BinaryConditionProfile,CountingConditionProfile
public abstract class ConditionProfile extends NodeCloneable
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 ofConditionProfile(and subclasses) must be held infinalfields for compiler optimizations to take effect.- See Also:
createCountingProfile(),createBinaryProfile()
-
-
Constructor Summary
Constructors Constructor Description ConditionProfile()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static ConditionProfilecreateBinaryProfile()Returns aConditionProfilethat speculates on conditions to be never true or to be never false.static ConditionProfilecreateCountingProfile()abstract booleanprofile(boolean value)-
Methods inherited from class com.oracle.truffle.api.nodes.NodeCloneable
clone
-
-
-
-
Method Detail
-
profile
public abstract boolean profile(boolean value)
-
createCountingProfile
public static ConditionProfile 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:
ConditionProfile,createBinaryProfile()
-
createBinaryProfile
public static ConditionProfile 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:
ConditionProfile,createCountingProfile()
-
-