Class CountingConditionProfile

All Implemented Interfaces:
Cloneable

public final class CountingConditionProfile extends Profile

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 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 never deoptimize 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.

      Overrides:
      disable in class Profile
      Since:
      23.0
    • 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.

      Overrides:
      reset in class Profile
      Since:
      23.0
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Since:
      23.0
    • getUncached

      public static CountingConditionProfile getUncached()
      Returns the uncached version of the profile. The uncached version of a profile does nothing.
      Since:
      23.0
    • create

      public static CountingConditionProfile create()
      Returns a ConditionProfile that speculates on conditions to be never true or to be never false. 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 using CompilerDirectives.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