Class ConditionProfile

All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
LoopConditionProfile

public class ConditionProfile extends Profile

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 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 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
    • createCountingProfile

      @Deprecated public static ConditionProfile createCountingProfile()
      Deprecated.
      Since:
      0.10
    • createBinaryProfile

      @Deprecated public static ConditionProfile createBinaryProfile()
      Deprecated.
      use create() instead.
      Since:
      0.10
    • create

      public static ConditionProfile create()
      Returns a ConditionProfile that speculates on conditions to be never true or to be never false. Condition profiles are intended to be used as part of if conditions.
      Since:
      20.2
    • getUncached

      public static ConditionProfile getUncached()
      Returns the uncached version of the profile. The uncached version of a profile does nothing.
      Since:
      19.0
    • inline

      public static InlinedConditionProfile inline(InlineSupport.InlineTarget target)
      Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining.
      Since:
      23.0