Class InlinedLoopConditionProfile
InlinedLoopConditionProfiles are designed to profile the outcome of loop conditions. Loop profiles can be used to profile unpredictable loops as well as predictable loops. This profile is intended to be used in combination with Truffle DSL.
Uncounted loop usage example:
class LoopNode extends Node {
abstract void execute();
@Specialization
void doDefault(@Cached InlinedLoopConditionProfile loopProfile) {
// loop count cannot be predicted
while (loopProfile.profile(this, Math.random() >= 0.9)) {
// work
}
}
}
Counted loop usage example:
class CountedLoopNode extends Node {
abstract void execute(int length);
@Specialization
void doDefault(int length, @Cached InlinedLoopConditionProfile loopProfile) {
// loop count can be predicted
loopProfile.profileCounted(this, length);
for (int i = 0; loopProfile.inject(this, i < length); i++) {
// work
}
}
}
The advantage of using profileCounted(Node, long) to using
profile(Node, boolean) is that it incurs less overhead in the interpreter. Using
inject(Node, boolean) is a no-op in the interpreter while
profile(Node, boolean) needs to use a counter for each iteration.
- Since:
- 23.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidDisables this profile by setting it to its generic state.static InlinedLoopConditionProfileReturns the uncached version of the profile.booleanProvides an alternative way to profile counted loops with less interpreter footprint.static InlinedLoopConditionProfileinline(InlineSupport.InlineTarget target) Returns an inlined version of the profile.booleanvoidprofileCounted(Node node, long length) Provides an alternative way to profile counted loops with less interpreter footprint.voidResets this profile to its uninitialized state.Prints a string representation of this inlined profile given a target node.booleanbooleanMethods inherited from class com.oracle.truffle.api.profiles.InlinedProfile
toString
-
Method Details
-
profile
- Since:
- 23.0
-
profileCounted
Provides an alternative way to profile counted loops with less interpreter footprint. Please seeInlinedLoopConditionProfilefor an usage example.- Since:
- 23.0
- See Also:
-
inject
Provides an alternative way to profile counted loops with less interpreter footprint. Please seeInlinedLoopConditionProfilefor an usage example.- Since:
- 23.0
-
wasTrue
Returnstrueif theprofile(Node, boolean)method ever received atruevalue, otherwisefalse. For profiles with profiling disabled oruncachedprofiles this method always returnstrue.- Since:
- 23.0
-
wasFalse
Returnstrueif theprofile(Node, boolean)method ever received afalsevalue, otherwisefalse. For profiles with profiling disabled oruncachedprofiles this method always returnstrue.- Since:
- 23.0
-
disable
Disables this profile by setting it to its generic state. After disabling it is guaranteed to neverdeoptimizeon 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.
- Specified by:
disablein classInlinedProfile- Since:
- 23.0
-
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.
- Specified by:
resetin classInlinedProfile- Since:
- 23.0
-
toString
Prints a string representation of this inlined profile given a target node.- Specified by:
toStringin classInlinedProfile- Since:
- 23.0
-
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 not perform any profiling.- Since:
- 23.0
-