com.oracle.truffle.api.utilities

## Class ConditionProfile

- java.lang.Object
- - com.oracle.truffle.api.nodes.NodeCloneable
  - - com.oracle.truffle.api.utilities.ConditionProfile

All Implemented Interfaces:
  java.lang.Cloneable

Direct Known Subclasses:
  BinaryConditionProfile, CountingConditionProfile

    public abstract class ConditionProfile
    extends NodeCloneable

Abstract utility class to speculate on conditions. Condition profiles are intended to be used as part of if conditions. Example usage:

     private final ConditionProfile zero = ConditionProfile.createBinaryProfile();

     int value = ...;
     if (zero.profile(value == 0)) {
       return 0;
     } else {
       return value;
     }

All instances of `ConditionProfile` (and subclasses) must be held in `final` fields for compiler optimizations to take effect.

See Also:
  `createCountingProfile()`, `createBinaryProfile()`

### Constructor Summary

Constructors
Constructor and Description
`ConditionProfile()`

### Method Summary

Methods
`static ConditionProfile` `createBinaryProfile()` Returns a `ConditionProfile` that speculates on conditions to be never true or to be never false.
`static ConditionProfile` `createCountingProfile()` Returns a `ConditionProfile` that speculates on conditions to be never `true` or to be never `false`.
`abstract boolean` `profile(boolean value)`

### Methods inherited from class com.oracle.truffle.api.nodes.NodeCloneable

`clone`

### Methods inherited from class java.lang.Object

`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### ConditionProfile

    public ConditionProfile()

### Method Detail

#### profile

    public abstract boolean profile(boolean value)

#### createCountingProfile

    public static ConditionProfile createCountingProfile()

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.

See Also:
  `ConditionProfile`, `createBinaryProfile()`

#### createBinaryProfile

    public static ConditionProfile createBinaryProfile()

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.

See Also:
  `ConditionProfile`, `createCountingProfile()`