Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/Profile.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 | 1133c68332ef |
comparison
equal
deleted
inserted
replaced
22503:828c67903db2 | 22504:d80a5ff56f51 |
---|---|
25 package com.oracle.truffle.api.profiles; | 25 package com.oracle.truffle.api.profiles; |
26 | 26 |
27 import com.oracle.truffle.api.Assumption; | 27 import com.oracle.truffle.api.Assumption; |
28 import com.oracle.truffle.api.CompilerDirectives; | 28 import com.oracle.truffle.api.CompilerDirectives; |
29 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; | 29 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; |
30 import com.oracle.truffle.api.Truffle; | |
30 import com.oracle.truffle.api.TruffleRuntime; | 31 import com.oracle.truffle.api.TruffleRuntime; |
31 import com.oracle.truffle.api.nodes.Node; | 32 import com.oracle.truffle.api.nodes.Node; |
32 import com.oracle.truffle.api.nodes.NodeCloneable; | 33 import com.oracle.truffle.api.nodes.NodeCloneable; |
33 import com.oracle.truffle.api.nodes.RootNode; | 34 import com.oracle.truffle.api.nodes.RootNode; |
34 | 35 |
88 * </p> | 89 * </p> |
89 * | 90 * |
90 * @see Assumption | 91 * @see Assumption |
91 */ | 92 */ |
92 public abstract class Profile extends NodeCloneable { | 93 public abstract class Profile extends NodeCloneable { |
94 private static final boolean ENABLED; | |
95 static { | |
96 boolean enabled; | |
97 try { | |
98 enabled = Truffle.getRuntime().isProfilingEnabled(); | |
99 } catch (NoSuchMethodError ex) { | |
100 // running on old version of Graal | |
101 enabled = true; | |
102 } | |
103 ENABLED = enabled; | |
104 } | |
105 | |
106 static boolean isProfilingEnabled() { | |
107 return ENABLED; | |
108 } | |
93 | 109 |
94 Profile() { | 110 Profile() { |
95 /* We don't to allow custom profiles. We want to evolve this API further first. Sorry. */ | 111 /* We don't to allow custom profiles. We want to evolve this API further first. Sorry. */ |
96 } | 112 } |
97 | 113 |