Package com.oracle.truffle.api.profiles
Class CountingConditionProfile
java.lang.Object
com.oracle.truffle.api.nodes.NodeCloneable
com.oracle.truffle.api.profiles.Profile
com.oracle.truffle.api.profiles.CountingConditionProfile
- All Implemented Interfaces:
Cloneable
CountingConditionProfiles are useful to profile the outcome of conditions. A counting condition
profile holds a count for each branch whether a branch was hit or not and communicates this to
the compiler as frequency information. If binary information only is desired for each branch
should use ConditionProfile
instead.
Usage example:
class AbsoluteNode extends Node { final CountingConditionProfile greaterZeroProfile = CountingConditionProfile.create(); void execute(int value) { if (greaterZeroProfile.profile(value >= 0)) { return value; } else { return -value; } } }
- Since:
- 23.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic CountingConditionProfile
create()
void
disable()
Disables this profile by setting it to its generic state.static CountingConditionProfile
Returns the uncached version of the profile.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:
- 22.1
-
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
-
getUncached
Returns the uncached version of the profile. The uncached version of a profile does nothing.- Since:
- 23.0
-
create
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.- Since:
- 23.0
- See Also:
-
inline
Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining.- Since:
- 23.0
-