Mercurial > hg > truffle
diff 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 |
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/Profile.java Thu Dec 17 10:01:38 2015 +0100 +++ b/truffle/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/Profile.java Thu Dec 17 13:45:37 2015 +0100 @@ -27,6 +27,7 @@ import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.TruffleRuntime; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeCloneable; @@ -90,6 +91,21 @@ * @see Assumption */ public abstract class Profile extends NodeCloneable { + private static final boolean ENABLED; + static { + boolean enabled; + try { + enabled = Truffle.getRuntime().isProfilingEnabled(); + } catch (NoSuchMethodError ex) { + // running on old version of Graal + enabled = true; + } + ENABLED = enabled; + } + + static boolean isProfilingEnabled() { + return ENABLED; + } Profile() { /* We don't to allow custom profiles. We want to evolve this API further first. Sorry. */