# HG changeset patch # User Doug Simon # Date 1384781268 -3600 # Node ID 516ad7baa08031fbe48bdefbc32ac57b759e6bde # Parent a7990d87c26ef9333aad6d86cdb7454e59cb0bbc made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime diff -r a7990d87c26e -r 516ad7baa080 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java Mon Nov 18 14:26:49 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java Mon Nov 18 14:27:48 2013 +0100 @@ -27,13 +27,17 @@ import static java.nio.file.Files.*; import java.io.*; +import java.lang.reflect.*; import java.nio.charset.*; import java.nio.file.*; import java.util.*; import com.oracle.graal.debug.*; +import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.logging.*; +import com.oracle.graal.java.*; import com.oracle.graal.options.*; +import com.oracle.graal.phases.common.*; /** * Called from {@code graalCompiler.cpp} to parse any Graal specific options. Such options are @@ -184,13 +188,47 @@ } /** + * Sets the relevant system property such that a {@link DebugTimer} or {@link DebugMetric} + * associated with a field in a class will be unconditionally enabled when it is created. + *

+ * This method verifies that the named field exists and is of an expected type. However, it does + * not verify that the timer or metric created has the same name of the field. + * + * @param c the class in which the field is declared + * @param name the name of the field + */ + private static void unconditionallyEnableTimerOrMetric(Class c, String name) { + try { + Field field = c.getDeclaredField(name); + String propertyName; + if (DebugTimer.class.isAssignableFrom(field.getType())) { + propertyName = Debug.ENABLE_TIMER_PROPERTY_NAME_PREFIX + name; + } else { + assert DebugMetric.class.isAssignableFrom(field.getType()); + propertyName = Debug.ENABLE_METRIC_PROPERTY_NAME_PREFIX + name; + } + String previous = System.setProperty(propertyName, "true"); + if (previous != null) { + Logger.info("Overrode value \"" + previous + "\" of system property \"" + propertyName + "\" with \"true\""); + } + } catch (Exception e) { + throw new GraalInternalError(e); + } + } + + /** * Called from VM code once all Graal command line options have been processed by * {@link #setOption(String)}. * * @param ciTime the value of the CITime HotSpot VM option */ public static void finalizeOptions(boolean ciTime) { - if (areDebugScopePatternsEnabled() || ciTime) { + if (ciTime) { + unconditionallyEnableTimerOrMetric(GraphBuilderPhase.class, "BytecodesParsed"); + unconditionallyEnableTimerOrMetric(InliningUtil.class, "InlinedBytecodes"); + unconditionallyEnableTimerOrMetric(CompilationTask.class, "CompilationTime"); + } + if (areDebugScopePatternsEnabled()) { assert !Debug.Initialization.isDebugInitialized(); System.setProperty(Debug.Initialization.INITIALIZER_PROPERTY_NAME, "true"); } diff -r a7990d87c26e -r 516ad7baa080 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Mon Nov 18 14:26:49 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Mon Nov 18 14:27:48 2013 +0100 @@ -157,12 +157,6 @@ } } - if (config.ciTime) { - BytecodesParsed.setConditional(false); - InlinedBytecodes.setConditional(false); - CompilationTime.setConditional(false); - } - if (Debug.isEnabled()) { DebugEnvironment.initialize(log);