# HG changeset patch # User Doug Simon # Date 1378816375 -7200 # Node ID e1309fc4d17f990e89325f24aa534db209b9cc17 # Parent 1aa56a2fb08bd8ddb2ed73908dba6bfea20e474a ensure Debug.enable() is called before any DebugTimer or DebugMetric objects are requested diff -r 1aa56a2fb08b -r e1309fc4d17f graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java Tue Sep 10 14:30:07 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java Tue Sep 10 14:32:55 2013 +0200 @@ -36,8 +36,6 @@ public class GraalDebugConfig implements DebugConfig { // @formatter:off - @Option(help = "Enable scope-based debugging", name = "Debug") - public static final OptionValue DebugEnabled = new OptionValue<>(true); @Option(help = "Pattern for scope(s) to in which dumping is enabled (see DebugFilter and Debug.dump)") public static final OptionValue Dump = new OptionValue<>(null); @Option(help = "Pattern for scope(s) to in which metering is enabled (see DebugFilter and Debug.metric)") @@ -68,6 +66,10 @@ }; // @formatter:on + public static boolean isDebugEnabled() { + return Dump.getValue() != null || Meter.getValue() != null || Time.getValue() != null || Log.getValue() != null; + } + private final DebugFilter logFilter; private final DebugFilter meterFilter; private final DebugFilter timerFilter; diff -r 1aa56a2fb08b -r e1309fc4d17f graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerThread.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerThread.java Tue Sep 10 14:30:07 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerThread.java Tue Sep 10 14:32:55 2013 +0200 @@ -22,7 +22,6 @@ */ package com.oracle.graal.hotspot; -import static com.oracle.graal.compiler.GraalDebugConfig.*; import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; import java.io.*; @@ -52,7 +51,7 @@ @Override public void run() { GraalDebugConfig hotspotDebugConfig = null; - if (DebugEnabled.getValue()) { + if (Debug.isEnabled()) { PrintStream log = graalRuntime().getVMToCompiler().log(); DebugEnvironment.initialize(log); } diff -r 1aa56a2fb08b -r e1309fc4d17f 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 Tue Sep 10 14:30:07 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java Tue Sep 10 14:32:55 2013 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.hotspot; +import static com.oracle.graal.compiler.GraalDebugConfig.*; import static java.nio.file.Files.*; import java.io.*; @@ -30,6 +31,7 @@ import java.nio.file.*; import java.util.*; +import com.oracle.graal.debug.*; import com.oracle.graal.hotspot.logging.*; import com.oracle.graal.options.*; @@ -174,6 +176,16 @@ } /** + * Called from VM code once all Graal command line options have been processed by + * {@link #setOption(String)}. + */ + public static void finalizeOptions() { + if (Dump.getValue() != null || Meter.getValue() != null || Time.getValue() != null || Log.getValue() != null || HotSpotVMConfig.getVMOption("CITime")) { + Debug.enable(); + } + } + + /** * Wraps some given text to one or more lines of a given maximum width. * * @param text text to wrap diff -r 1aa56a2fb08b -r e1309fc4d17f 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 Tue Sep 10 14:30:07 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Tue Sep 10 14:32:55 2013 +0200 @@ -166,12 +166,11 @@ if (config.ciTime) { quietMeterAndTime = (Meter.getValue() == null && Time.getValue() == null); - DebugEnabled.setValue(true); Meter.setValue(""); Time.setValue(""); } - if (DebugEnabled.getValue()) { + if (Debug.isEnabled()) { DebugEnvironment.initialize(log); String summary = DebugValueSummary.getValue(); diff -r 1aa56a2fb08b -r e1309fc4d17f graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/VerifyHotSpotOptionsPhase.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/VerifyHotSpotOptionsPhase.java Tue Sep 10 14:30:07 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/VerifyHotSpotOptionsPhase.java Tue Sep 10 14:32:55 2013 +0200 @@ -57,22 +57,26 @@ for (OptionDescriptor desc : opts) { if (HotSpotOptions.isHotSpotOption(desc)) { HotSpotResolvedObjectType holder = (HotSpotResolvedObjectType) runtime.lookupJavaType(desc.getDeclaringClass()); - if (!checked.contains(holder)) { - checked.add(holder); - for (ResolvedJavaMethod method : holder.getMethods()) { - if (method.isClassInitializer()) { - StructuredGraph graph = new StructuredGraph(method); - new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); - new VerifyHotSpotOptionsPhase(holder, runtime).apply(graph); - } - } - } + checkType(runtime, checked, holder); } } } return true; } + private static void checkType(HotSpotRuntime runtime, Set checked, HotSpotResolvedObjectType holder) { + if (!checked.contains(holder)) { + checked.add(holder); + for (ResolvedJavaMethod method : holder.getMethods()) { + if (method.isClassInitializer()) { + StructuredGraph graph = new StructuredGraph(method); + new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); + new VerifyHotSpotOptionsPhase(holder, runtime).apply(graph); + } + } + } + } + private final HotSpotRuntime runtime; private final ResolvedJavaType declaringClass; private final ResolvedJavaType optionValueType; diff -r 1aa56a2fb08b -r e1309fc4d17f graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Tue Sep 10 14:30:07 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Tue Sep 10 14:32:55 2013 +0200 @@ -23,7 +23,6 @@ package com.oracle.graal.truffle; import static com.oracle.graal.api.code.CodeUtil.*; -import static com.oracle.graal.compiler.GraalDebugConfig.*; import java.util.*; import java.util.concurrent.*; @@ -84,7 +83,7 @@ this.partialEvaluator = new PartialEvaluator(metaAccessProvider, replacements, truffleCache); - if (DebugEnabled.getValue()) { + if (Debug.isEnabled()) { DebugEnvironment.initialize(System.out); } } diff -r 1aa56a2fb08b -r e1309fc4d17f src/share/vm/classfile/vmSymbols.hpp --- a/src/share/vm/classfile/vmSymbols.hpp Tue Sep 10 14:30:07 2013 +0200 +++ b/src/share/vm/classfile/vmSymbols.hpp Tue Sep 10 14:32:55 2013 +0200 @@ -356,6 +356,7 @@ template(compileMethod_signature, "(JLcom/oracle/graal/hotspot/meta/HotSpotResolvedObjectType;IZ)V") \ template(setOption_name, "setOption") \ template(setOption_signature, "(Ljava/lang/String;)Z") \ + template(finalizeOptions_name, "finalizeOptions") \ template(createUnresolvedJavaMethod_name, "createUnresolvedJavaMethod") \ template(createUnresolvedJavaMethod_signature, "(Ljava/lang/String;Ljava/lang/String;Lcom/oracle/graal/api/meta/JavaType;)Lcom/oracle/graal/api/meta/JavaMethod;") \ template(createSignature_name, "createSignature") \ diff -r 1aa56a2fb08b -r e1309fc4d17f src/share/vm/graal/graalCompiler.cpp --- a/src/share/vm/graal/graalCompiler.cpp Tue Sep 10 14:30:07 2013 +0200 +++ b/src/share/vm/graal/graalCompiler.cpp Tue Sep 10 14:32:55 2013 +0200 @@ -95,6 +95,8 @@ vm_abort(false); } } + VMToCompiler::finalizeOptions(); + if (UseCompiler) { VMToCompiler::startCompiler(BootstrapGraal); _initialized = true; diff -r 1aa56a2fb08b -r e1309fc4d17f src/share/vm/graal/graalVMToCompiler.cpp --- a/src/share/vm/graal/graalVMToCompiler.cpp Tue Sep 10 14:30:07 2013 +0200 +++ b/src/share/vm/graal/graalVMToCompiler.cpp Tue Sep 10 14:32:55 2013 +0200 @@ -90,23 +90,31 @@ } void VMToCompiler::initOptions() { - KlassHandle compilerKlass = loadClass(vmSymbols::com_oracle_graal_hotspot_HotSpotOptions()); + KlassHandle optionsKlass = loadClass(vmSymbols::com_oracle_graal_hotspot_HotSpotOptions()); Thread* THREAD = Thread::current(); - compilerKlass->initialize(THREAD); + optionsKlass->initialize(THREAD); check_pending_exception("Error while calling initOptions"); } jboolean VMToCompiler::setOption(Handle option) { assert(!option.is_null(), ""); - KlassHandle compilerKlass = loadClass(vmSymbols::com_oracle_graal_hotspot_HotSpotOptions()); + KlassHandle optionsKlass = loadClass(vmSymbols::com_oracle_graal_hotspot_HotSpotOptions()); Thread* THREAD = Thread::current(); JavaValue result(T_BOOLEAN); - JavaCalls::call_static(&result, compilerKlass, vmSymbols::setOption_name(), vmSymbols::setOption_signature(), option, THREAD); + JavaCalls::call_static(&result, optionsKlass, vmSymbols::setOption_name(), vmSymbols::setOption_signature(), option, THREAD); check_pending_exception("Error while calling setOption"); return result.get_jboolean(); } +void VMToCompiler::finalizeOptions() { + KlassHandle optionsKlass = loadClass(vmSymbols::com_oracle_graal_hotspot_HotSpotOptions()); + Thread* THREAD = Thread::current(); + JavaValue result(T_VOID); + JavaCalls::call_static(&result, optionsKlass, vmSymbols::finalizeOptions_name(), vmSymbols::void_method_signature(), THREAD); + check_pending_exception("Error while calling finalizeOptions"); +} + void VMToCompiler::compileMethod(Method* method, Handle holder, int entry_bci, jboolean blocking) { assert(method != NULL, "just checking"); assert(!holder.is_null(), "just checking"); diff -r 1aa56a2fb08b -r e1309fc4d17f src/share/vm/graal/graalVMToCompiler.hpp --- a/src/share/vm/graal/graalVMToCompiler.hpp Tue Sep 10 14:30:07 2013 +0200 +++ b/src/share/vm/graal/graalVMToCompiler.hpp Tue Sep 10 14:32:55 2013 +0200 @@ -57,6 +57,9 @@ // public static boolean HotSpotOptions.setOption(String option); static jboolean setOption(Handle option); + // public static void HotSpotOptions.finalizeOptions(); + static void finalizeOptions(); + // public abstract boolean compileMethod(long vmId, String name, int entry_bci, boolean blocking); static void compileMethod(Method* method, Handle holder, int entry_bci, jboolean blocking);