comparison truffle/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/BranchProfile.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 a5e58793bbca
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 * BranchProfiles are profiles to speculate on branches that are unlikely to be visited. If the 32 * BranchProfiles are profiles to speculate on branches that are unlikely to be visited. If the
34 * {@link #enter()} method is invoked first the optimized code is invalidated and the branch where 33 * {@link #enter()} method is invoked first the optimized code is invalidated and the branch where
76 75
77 /** 76 /**
78 * Call to create a new instance of a branch profile. 77 * Call to create a new instance of a branch profile.
79 */ 78 */
80 public static BranchProfile create() { 79 public static BranchProfile create() {
81 if (Truffle.getRuntime().isProfilingEnabled()) { 80 if (Profile.isProfilingEnabled()) {
82 return Enabled.create0(); 81 return Enabled.create0();
83 } else { 82 } else {
84 return Disabled.INSTANCE; 83 return Disabled.INSTANCE;
85 } 84 }
86 } 85 }