# HG changeset patch # User Doug Simon # Date 1432465913 -7200 # Node ID 01319414783b7f0b2899bce6c64d7642837b9d12 # Parent e37d1fe9f33257e810437d8f7de888034ae2aa83 added extension point for post Option parsing actions and used it to remove another JVMCI to non-JVMCI dependency (JBS:GRAAL-53) diff -r e37d1fe9f332 -r 01319414783b graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/OptionsParsed.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/OptionsParsed.java Sun May 24 13:11:53 2015 +0200 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.api.runtime; + +/** + * Extension for doing post-processing once all JVMCI options have been parsed and initialized. + */ +public interface OptionsParsed extends Service { + + /** + * Notifies this service that all JVMCI options have been parsed and initialized. + */ + void apply(); +} diff -r e37d1fe9f332 -r 01319414783b 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 Sun May 24 12:07:04 2015 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java Sun May 24 13:11:53 2015 +0200 @@ -76,11 +76,11 @@ public static final OptionValue LogVerbose = new OptionValue<>(false); // @formatter:on - public static boolean isNotEmpty(OptionValue option) { + static boolean isNotEmpty(OptionValue option) { return option.getValue() != null && !option.getValue().isEmpty(); } - public static boolean areDebugScopePatternsEnabled() { + static boolean areDebugScopePatternsEnabled() { return DumpOnError.getValue() || Dump.getValue() != null || Log.getValue() != null || areScopedMetricsOrTimersEnabled(); } diff -r e37d1fe9f332 -r 01319414783b graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfigOptionsParsed.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfigOptionsParsed.java Sun May 24 13:11:53 2015 +0200 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.compiler; + +import com.oracle.graal.api.runtime.*; +import com.oracle.graal.debug.*; + +/** + * Implementation of {@link OptionsParsed} for setting system properties used in the initialization + * of {@link Debug} based on the values specified for various {@link GraalDebugConfig} options. + */ +@ServiceProvider(OptionsParsed.class) +class GraalDebugConfigOptionsParsed implements OptionsParsed { + + public void apply() { + assert !Debug.Initialization.isDebugInitialized(); + if (GraalDebugConfig.areDebugScopePatternsEnabled()) { + System.setProperty(Debug.Initialization.INITIALIZER_PROPERTY_NAME, "true"); + } + if ("".equals(GraalDebugConfig.Meter.getValue())) { + System.setProperty(Debug.ENABLE_UNSCOPED_METRICS_PROPERTY_NAME, "true"); + } + if ("".equals(GraalDebugConfig.Time.getValue())) { + System.setProperty(Debug.ENABLE_UNSCOPED_TIMERS_PROPERTY_NAME, "true"); + } + if ("".equals(GraalDebugConfig.TrackMemUse.getValue())) { + System.setProperty(Debug.ENABLE_UNSCOPED_MEM_USE_TRACKERS_PROPERTY_NAME, "true"); + } + } +} diff -r e37d1fe9f332 -r 01319414783b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotOptions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotOptions.java Sun May 24 12:07:04 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotOptions.java Sun May 24 13:11:53 2015 +0200 @@ -22,10 +22,10 @@ */ package com.oracle.graal.hotspot.jvmci; -import static com.oracle.graal.compiler.GraalDebugConfig.*; import static com.oracle.graal.hotspot.jvmci.HotSpotOptionsLoader.*; import static java.lang.Double.*; +import com.oracle.graal.api.runtime.*; import com.oracle.graal.debug.*; import com.oracle.graal.options.*; import com.oracle.graal.options.OptionUtils.OptionConsumer; @@ -43,25 +43,20 @@ /** * Parses the JVMCI specific options specified to HotSpot (e.g., on the command line). + * + * @param optionsParsedClass the {@link Class} for {@link OptionsParsed} + * @return the implementations of {@link OptionsParsed} available */ - private static native void parseVMOptions(); + private static native OptionsParsed[] parseVMOptions(Class optionsParsedClass); static { - parseVMOptions(); - + // Debug should not be initialized until all options that may affect + // its initialization have been processed. assert !Debug.Initialization.isDebugInitialized() : "The class " + Debug.class.getName() + " must not be initialized before the JVMCI runtime has been initialized. " + "This can be fixed by placing a call to " + JVMCI.class.getName() + ".getRuntime() on the path that triggers initialization of " + Debug.class.getName(); - if (areDebugScopePatternsEnabled()) { - System.setProperty(Debug.Initialization.INITIALIZER_PROPERTY_NAME, "true"); - } - if ("".equals(Meter.getValue())) { - System.setProperty(Debug.ENABLE_UNSCOPED_METRICS_PROPERTY_NAME, "true"); - } - if ("".equals(Time.getValue())) { - System.setProperty(Debug.ENABLE_UNSCOPED_TIMERS_PROPERTY_NAME, "true"); - } - if ("".equals(TrackMemUse.getValue())) { - System.setProperty(Debug.ENABLE_UNSCOPED_MEM_USE_TRACKERS_PROPERTY_NAME, "true"); + + for (OptionsParsed handler : parseVMOptions(OptionsParsed.class)) { + handler.apply(); } } @@ -72,7 +67,7 @@ } /** - * Helper for the VM code called by {@link #parseVMOptions()}. + * Helper for the VM code called by {@link #parseVMOptions}. * * @param name the name of a parsed option * @param option the object encapsulating the option diff -r e37d1fe9f332 -r 01319414783b make/defs.make --- a/make/defs.make Sun May 24 12:07:04 2015 +0200 +++ b/make/defs.make Sun May 24 13:11:53 2015 +0200 @@ -371,6 +371,7 @@ EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/com.oracle.graal.truffle.OptimizedCallTargetInstrumentationFactory EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/com.oracle.graal.api.runtime.GraalRuntimeFactory EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/com.oracle.graal.hotspot.jvmci.HotSpotJVMCIBackendFactory +EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/com.oracle.graal.api.runtime.OptionsParsed .PHONY: $(HS_ALT_MAKE)/defs.make diff -r e37d1fe9f332 -r 01319414783b src/share/vm/graal/graalRuntime.cpp --- a/src/share/vm/graal/graalRuntime.cpp Sun May 24 12:07:04 2015 +0200 +++ b/src/share/vm/graal/graalRuntime.cpp Sun May 24 13:11:53 2015 +0200 @@ -725,11 +725,13 @@ GraalRuntime::initialize_natives(env, c2vmClass); JVM_END -// private static void HotSpotOptions.parseVMOptions() -JVM_ENTRY(void, JVM_ParseGraalOptions(JNIEnv *env, jclass c)) +// private static OptionsParsed[] HotSpotOptions.parseVMOptions(Class) +JVM_ENTRY(jobject, JVM_ParseGraalOptions(JNIEnv *env, jclass c, jobject optionsParsedClass_obj)) HandleMark hm; KlassHandle hotSpotOptionsClass(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(c))); - GraalRuntime::parse_arguments(hotSpotOptionsClass, CHECK); + GraalRuntime::parse_arguments(hotSpotOptionsClass, CHECK_NULL); + KlassHandle optionsParsedClass(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(optionsParsedClass_obj))); + return JNIHandles::make_local(THREAD, GraalRuntime::get_service_impls(optionsParsedClass, THREAD)()); JVM_END