Package com.oracle.truffle.api.profiles
Class ConditionProfile
java.lang.Object
com.oracle.truffle.api.nodes.NodeCloneable
com.oracle.truffle.api.profiles.Profile
com.oracle.truffle.api.profiles.ConditionProfile
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
LoopConditionProfile
ConditionProfiles are useful to profile the outcome of conditions. A regular condition profile
keeps track of a binary state, for each branch whether a branch was hit or not and communicates
this to the compiler. If frequency information for each branch should be collected use
CountingConditionProfile
instead.
Usage example:
class AbsoluteNode extends Node { final ConditionProfile greaterZeroProfile = ConditionProfile.create(); void execute(int value) { if (greaterZeroProfile.profile(value >= 0)) { return value; } else { return -value; } } }
- Since:
- 0.10
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic ConditionProfile
create()
static ConditionProfile
Deprecated.static ConditionProfile
Deprecated.useCountingConditionProfile
insteadvoid
disable()
Disables this profile by setting it to its generic state.static ConditionProfile
Returns the uncached version of the profile.static InlinedConditionProfile
inline
(InlineSupport.InlineTarget target) Returns an inlined version of the profile.boolean
profile
(boolean value) void
reset()
Resets this profile to its uninitialized state.toString()
Methods inherited from class com.oracle.truffle.api.nodes.NodeCloneable
clone
-
Method Details
-
profile
public boolean profile(boolean value) - Since:
- 0.10
-
disable
public void disable()Disables this profile by setting it to its generic state. After disabling it is guaranteed to neverdeoptimize
on any invocation of a profile method.This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile.
-
reset
public void reset()Resets this profile to its uninitialized state. Has no effect if this profile is already in its uninitialized state or a disabled version of this profile is used.This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile.
-
toString
-
createCountingProfile
Deprecated.useCountingConditionProfile
instead- Since:
- 0.10
-
createBinaryProfile
Deprecated.usecreate()
instead.- Since:
- 0.10
-
create
Returns aConditionProfile
that speculates on conditions to be nevertrue
or to be neverfalse
. Condition profiles are intended to be used as part of if conditions.- Since:
- 20.2
-
getUncached
Returns the uncached version of the profile. The uncached version of a profile does nothing.- Since:
- 19.0
-
inline
Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining.- Since:
- 23.0
-
create()
instead.