Package com.oracle.truffle.api.profiles
Class BranchProfile
java.lang.Object
com.oracle.truffle.api.nodes.NodeCloneable
com.oracle.truffle.api.profiles.Profile
com.oracle.truffle.api.profiles.BranchProfile
- All Implemented Interfaces:
Cloneable
BranchProfiles are profiles to speculate on branches that are unlikely to be visited. If the
enter()
method is invoked first the optimized code is invalidated and the branch where
enter()
is invoked is enabled for compilation. Otherwise if the enter()
method
was never invoked the branch will not get compiled.
Usage example:
class BranchingNode extends Node {
final BranchProfile errorProfile = BranchProfile.create();
int execute(int value) {
if (value == Integer.MAX_VALUE) {
errorProfile.enter();
throw new Error("Invalid input value");
}
return value;
}
}
- Since:
- 0.10
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic BranchProfile
create()
Call to create a new instance of a branch profile.void
disable()
Disables this profile by setting it to its generic state.void
enter()
Call when an unlikely branch is entered.static BranchProfile
Returns the uncached version of the profile.static InlinedBranchProfile
inline
(InlineSupport.InlineTarget target) Returns an inlined version of the profile.void
reset()
Resets this profile to its uninitialized state.toString()
Methods inherited from class com.oracle.truffle.api.nodes.NodeCloneable
clone
-
Method Details
-
enter
public void enter()Call when an unlikely branch is entered.- 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
-
create
Call to create a new instance of a branch profile.- Since:
- 0.10
-
inline
Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining.- Since:
- 23.0
-
getUncached
Returns the uncached version of the profile. The uncached version of a profile does nothing.- Since:
- 19.0
-