Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/ConditionProfile.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 |
---|---|
24 */ | 24 */ |
25 package com.oracle.truffle.api.profiles; | 25 package com.oracle.truffle.api.profiles; |
26 | 26 |
27 import com.oracle.truffle.api.CompilerDirectives; | 27 import com.oracle.truffle.api.CompilerDirectives; |
28 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; | 28 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; |
29 import com.oracle.truffle.api.Truffle; | |
30 | 29 |
31 /** | 30 /** |
32 * <p> | 31 * <p> |
33 * ConditionProfiles are useful to profile the outcome of conditions. | 32 * ConditionProfiles are useful to profile the outcome of conditions. |
34 * </p> | 33 * </p> |
74 * | 73 * |
75 * @see ConditionProfile | 74 * @see ConditionProfile |
76 * @see #createBinaryProfile() | 75 * @see #createBinaryProfile() |
77 */ | 76 */ |
78 public static ConditionProfile createCountingProfile() { | 77 public static ConditionProfile createCountingProfile() { |
79 if (Truffle.getRuntime().isProfilingEnabled()) { | 78 if (Profile.isProfilingEnabled()) { |
80 return Counting.create(); | 79 return Counting.create(); |
81 } else { | 80 } else { |
82 return Disabled.INSTANCE; | 81 return Disabled.INSTANCE; |
83 } | 82 } |
84 } | 83 } |
90 * | 89 * |
91 * @see ConditionProfile | 90 * @see ConditionProfile |
92 * @see ConditionProfile#createCountingProfile() | 91 * @see ConditionProfile#createCountingProfile() |
93 */ | 92 */ |
94 public static ConditionProfile createBinaryProfile() { | 93 public static ConditionProfile createBinaryProfile() { |
95 if (Truffle.getRuntime().isProfilingEnabled()) { | 94 if (Profile.isProfilingEnabled()) { |
96 return Binary.create(); | 95 return Binary.create(); |
97 } else { | 96 } else { |
98 return Disabled.INSTANCE; | 97 return Disabled.INSTANCE; |
99 } | 98 } |
100 } | 99 } |