Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/ConditionProfile.java @ 22501:a63bda98cfdb
Extract profiles into separate package. Add isProfilingEnabled in TruffleRuntime to disable profiling in the default runtime; Add low overhead profiles for primitives; Add LoopConditionProfile; Profile footprint/threadsafety improvements; Make toString implementations more consistent; Greatly enhanced javadoc documentation for profiles; Deprecate old profiles
author | Christian Humer <christian.humer@oracle.com> |
---|---|
date | Wed, 16 Dec 2015 16:38:13 +0100 |
parents | dc83cc1f94f2 |
children |
comparison
equal
deleted
inserted
replaced
22500:fbe1eb7b4172 | 22501:a63bda98cfdb |
---|---|
22 * or visit www.oracle.com if you need additional information or have any | 22 * or visit www.oracle.com if you need additional information or have any |
23 * questions. | 23 * questions. |
24 */ | 24 */ |
25 package com.oracle.truffle.api.utilities; | 25 package com.oracle.truffle.api.utilities; |
26 | 26 |
27 import com.oracle.truffle.api.CompilerDirectives; | |
28 import com.oracle.truffle.api.nodes.NodeCloneable; | 27 import com.oracle.truffle.api.nodes.NodeCloneable; |
29 | 28 |
30 /** | 29 /** |
31 * Abstract utility class to speculate on conditions. Condition profiles are intended to be used as | 30 * @deprecated use {@link com.oracle.truffle.api.profiles.ConditionProfile} instead |
32 * part of if conditions. | |
33 * | |
34 * Example usage: | |
35 * | |
36 * <pre> | |
37 * private final ConditionProfile zero = ConditionProfile.createBinaryProfile(); | |
38 * | |
39 * int value = ...; | |
40 * if (zero.profile(value == 0)) { | |
41 * return 0; | |
42 * } else { | |
43 * return value; | |
44 * } | |
45 * | |
46 * </pre> | |
47 * | |
48 * All instances of {@code ConditionProfile} (and subclasses) must be held in {@code final} fields | |
49 * for compiler optimizations to take effect. | |
50 * | |
51 * @see #createCountingProfile() | |
52 * @see #createBinaryProfile() | |
53 */ | 31 */ |
32 @Deprecated | |
54 public abstract class ConditionProfile extends NodeCloneable { | 33 public abstract class ConditionProfile extends NodeCloneable { |
55 ConditionProfile() { | 34 ConditionProfile() { |
56 } | 35 } |
57 | 36 |
58 public abstract boolean profile(boolean value); | 37 public abstract boolean profile(boolean value); |
59 | 38 |
60 /** | 39 /** |
61 * Returns a {@link ConditionProfile} that speculates on conditions to be never | 40 * @deprecated use |
62 * <code>true</code> or to be never <code>false</code>. Additionally to a binary profile this | 41 * {@link com.oracle.truffle.api.profiles.ConditionProfile#createCountingProfile()} |
63 * method returns a condition profile that also counts the number of times the condition was | 42 * instead |
64 * true and false. This information is reported to the underlying optimization system using | |
65 * {@link CompilerDirectives#injectBranchProbability(double, boolean)}. Condition profiles are | |
66 * intended to be used as part of if conditions. | |
67 * | |
68 * @see ConditionProfile | |
69 * @see #createBinaryProfile() | |
70 */ | 43 */ |
44 @SuppressWarnings("deprecation") | |
45 @Deprecated | |
71 public static ConditionProfile createCountingProfile() { | 46 public static ConditionProfile createCountingProfile() { |
72 return new CountingConditionProfile(); | 47 return new CountingConditionProfile(); |
73 } | 48 } |
74 | 49 |
75 /** | 50 /** |
76 * Returns a {@link ConditionProfile} that speculates on conditions to be never true or to be | 51 * @deprecated use |
77 * never false. Condition profiles are intended to be used as part of if conditions. | 52 * {@link com.oracle.truffle.api.profiles.ConditionProfile#createBinaryProfile()} |
78 * | 53 * instead |
79 * @see ConditionProfile | |
80 * @see ConditionProfile#createCountingProfile() | |
81 */ | 54 */ |
55 @Deprecated | |
56 @SuppressWarnings("deprecation") | |
82 public static ConditionProfile createBinaryProfile() { | 57 public static ConditionProfile createBinaryProfile() { |
83 return new BinaryConditionProfile(); | 58 return new BinaryConditionProfile(); |
84 } | 59 } |
85 } | 60 } |