Class ValueProfile

All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
PrimitiveValueProfile

public abstract class ValueProfile extends Profile

Specialized value profile to capture certain properties of Object runtime values. Value profiles require a runtime check in their initialized state to verify their profiled assumption. Value profiles are limited to capture monomorphic profiles only. This means that if two or more identities or classes are profiles within a single profile then the profile has no effect and no overhead after compilation. There are specialized versions of this profile with less interpreter footprint for boolean, byte, int, long, float and double values.

Usage example:

 class SampleNode extends Node {

 final ValueProfile profile = ValueProfile.create{Identity,Class}Profile();

     Object execute(Object input) {
         Object profiledValue = profile.profile(input);
         // compiler may know now more about profiledValue
         return profieldValue;
     }
 }
 
Since:
0.10
See Also:
  • Method Details

    • profile

      public abstract <T> T profile(T value)
      Since:
      0.10
    • createClassProfile

      public static ValueProfile createClassProfile()

      Returns a value profile that profiles the exact class of a value. It will check the class of the profiled value and provide additional information to the compiler if only non-null values of exactly one concrete Java class are passed as a parameter to the profile(T) method. This can be beneficial if subsequent code can take advantage of knowing the concrete class of the value. The profile will degrade to the generic case if a null value or if at least two instances of two different Java classes are registered.

      Compilation notes: Value profiles require a runtime check in their initialized state to verify their profiled class. If two classes have been seen on a single profile instance then this profile will transition to a generic state with no overhead.

      Since:
      0.10
      See Also:
    • create

      public static ValueProfile create()

      Returns a value profile that profiles the exact class of a value. It will check the class of the profiled value and provide additional information to the compiler if only non-null values of exactly one concrete Java class are passed as a parameter to the profile(T) method. This can be beneficial if subsequent code can take advantage of knowing the concrete class of the value. The profile will degrade to the generic case if a null value or if at least two instances of two different Java classes are registered.

      Compilation notes: Value profiles require a runtime check in their initialized state to verify their profiled class. If two classes have been seen on a single profile instance then this profile will transition to a generic state with no overhead.

      Since:
      23.0
      See Also:
    • createIdentityProfile

      public static ValueProfile createIdentityProfile()

      Returns a value profile that profiles the object identity of a value. A single instance can only profile one particular instance.

      Compilation notes: Identity profiles require a runtime check to verify their profiled object identity. If two identities have been seen on a single profile instance then this profile will transition to a generic state with no overhead.

      Since:
      0.10
    • getUncached

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

      Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining.
      Since:
      23.0