comparison truffle/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/LoopConditionProfile.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 * LoopConditionProfiles are designed to profile the outcome of loop conditions. Loop profiles can 32 * LoopConditionProfiles are designed to profile the outcome of loop conditions. Loop profiles can
34 * be used to profile unpredictable loops as well as predictable loops. 33 * be used to profile unpredictable loops as well as predictable loops.
116 * profiles are intended to be used for loop conditions. 115 * profiles are intended to be used for loop conditions.
117 * 116 *
118 * @see LoopConditionProfile 117 * @see LoopConditionProfile
119 */ 118 */
120 public static LoopConditionProfile createCountingProfile() { 119 public static LoopConditionProfile createCountingProfile() {
121 if (Truffle.getRuntime().isProfilingEnabled()) { 120 if (Profile.isProfilingEnabled()) {
122 return Enabled.create(); 121 return Enabled.create();
123 } else { 122 } else {
124 return Disabled.INSTANCE; 123 return Disabled.INSTANCE;
125 } 124 }
126 } 125 }