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 infinal
fields 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 ConditionProfile
createBinaryProfile()
Returns aConditionProfile
that speculates on conditions to be never true or to be never false.static ConditionProfile
createCountingProfile()
abstract boolean
profile(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 aConditionProfile
that speculates on conditions to be nevertrue
or 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 aConditionProfile
that 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()
-
-