comparison truffle/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/ValueProfile.java @ 22504:d80a5ff56f51

Storing the profiling enabled information in a static field; checking it only once; shielding against missing method in the TruffleRuntime interface
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Thu, 17 Dec 2015 13:45:37 +0100
parents 828c67903db2
children
comparison
equal deleted inserted replaced
22503:828c67903db2 22504:d80a5ff56f51
26 26
27 import java.util.Objects; 27 import java.util.Objects;
28 28
29 import com.oracle.truffle.api.CompilerDirectives; 29 import com.oracle.truffle.api.CompilerDirectives;
30 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; 30 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
31 import com.oracle.truffle.api.Truffle;
32 31
33 /** 32 /**
34 * <p> 33 * <p>
35 * Specialized value profile to capture certain properties of <code>Object</code> runtime values. 34 * Specialized value profile to capture certain properties of <code>Object</code> runtime values.
36 * Value profiles require a runtime check in their initialized state to verify their profiled 35 * Value profiles require a runtime check in their initialized state to verify their profiled
90 * </P> 89 * </P>
91 * 90 *
92 * @see ValueProfile usage example 91 * @see ValueProfile usage example
93 */ 92 */
94 public static ValueProfile createClassProfile() { 93 public static ValueProfile createClassProfile() {
95 if (Truffle.getRuntime().isProfilingEnabled()) { 94 if (Profile.isProfilingEnabled()) {
96 return ExactClass.create(); 95 return ExactClass.create();
97 } else { 96 } else {
98 return Disabled.INSTANCE; 97 return Disabled.INSTANCE;
99 } 98 }
100 } 99 }
110 * object identity. If two identities have been seen on a single profile instance then this 109 * object identity. If two identities have been seen on a single profile instance then this
111 * profile will transition to a generic state with no overhead. 110 * profile will transition to a generic state with no overhead.
112 * </p> 111 * </p>
113 */ 112 */
114 public static ValueProfile createIdentityProfile() { 113 public static ValueProfile createIdentityProfile() {
115 if (Truffle.getRuntime().isProfilingEnabled()) { 114 if (Profile.isProfilingEnabled()) {
116 return Identity.create(); 115 return Identity.create();
117 } else { 116 } else {
118 return Disabled.INSTANCE; 117 return Disabled.INSTANCE;
119 } 118 }
120 } 119 }
133 * seen on a single profile instance then this profile will transition to a generic state with 132 * seen on a single profile instance then this profile will transition to a generic state with
134 * no overhead. 133 * no overhead.
135 * </p> 134 * </p>
136 */ 135 */
137 public static ValueProfile createEqualityProfile() { 136 public static ValueProfile createEqualityProfile() {
138 if (Truffle.getRuntime().isProfilingEnabled()) { 137 if (Profile.isProfilingEnabled()) {
139 return Equality.create(); 138 return Equality.create();
140 } else { 139 } else {
141 return Disabled.INSTANCE; 140 return Disabled.INSTANCE;
142 } 141 }
143 } 142 }