comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/ValueProfile.java @ 18164:53afdc71b311

Truffle: added PrimitiveValueProfile.
author Chris Seaton <chris.seaton@oracle.com>
date Fri, 24 Oct 2014 22:50:04 +0100
parents 1e542561783e
children e93507e232c9
comparison
equal deleted inserted replaced
18163:c88ab4f1f04a 18164:53afdc71b311
29 * 29 *
30 * Example usage: 30 * Example usage:
31 * 31 *
32 * <pre> 32 * <pre>
33 * private final ValueProfile classProfile = ValueProfile.createClassProfile(); 33 * private final ValueProfile classProfile = ValueProfile.createClassProfile();
34 * 34 *
35 * return classProfile.profile(value); 35 * return classProfile.profile(value);
36 * </pre> 36 * </pre>
37 * 37 *
38 * All instances of {@code ValueProfile} (and subclasses) must be held in {@code final} fields for 38 * All instances of {@code ValueProfile} (and subclasses) must be held in {@code final} fields for
39 * compiler optimizations to take effect. 39 * compiler optimizations to take effect.
40 * 40 *
41 * @see #createPrimitiveProfile()
41 * @see #createIdentityProfile() 42 * @see #createIdentityProfile()
42 * @see #createClassProfile() 43 * @see #createClassProfile()
43 */ 44 */
44 public abstract class ValueProfile { 45 public abstract class ValueProfile {
45 46
46 public abstract <T> T profile(T value); 47 public abstract <T> T profile(T value);
48
49 /**
50 * Returns a {@link ValueProfile} that speculates on the exact class of a value.
51 */
52 public static PrimitiveValueProfile createPrimitiveProfile() {
53 return new PrimitiveValueProfile();
54 }
47 55
48 /** 56 /**
49 * Returns a {@link ValueProfile} that speculates on the exact class of a value. 57 * Returns a {@link ValueProfile} that speculates on the exact class of a value.
50 */ 58 */
51 public static ValueProfile createClassProfile() { 59 public static ValueProfile createClassProfile() {