# HG changeset patch # User Doug Simon # Date 1432471468 -7200 # Node ID b118c9be1d1f54bb18208b42145b4f0d73026083 # Parent ee764a50af61d73ba46be8eb23944f353097ca02 fixed regression preventing hosted CompileTheWorld from running (JBS:GRAAL-53) diff -r ee764a50af61 -r b118c9be1d1f graal/com.oracle.graal.hotspot/src/META-INF/services/com.oracle.graal.api.runtime.GraalRuntimeFactory --- a/graal/com.oracle.graal.hotspot/src/META-INF/services/com.oracle.graal.api.runtime.GraalRuntimeFactory Sun May 24 14:42:38 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.oracle.graal.hotspot.HotSpotGraalRuntime$HotSpotGraalRuntimeFactory diff -r ee764a50af61 -r b118c9be1d1f graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Sun May 24 14:42:38 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Sun May 24 14:44:28 2015 +0200 @@ -25,7 +25,6 @@ import static com.oracle.graal.compiler.GraalDebugConfig.*; import static com.oracle.graal.compiler.common.GraalOptions.*; import static com.oracle.graal.compiler.common.UnsafeAccess.*; -import static com.oracle.graal.hotspot.CompileTheWorld.Options.*; import static com.oracle.graal.hotspot.HotSpotGraalRuntime.Options.*; import static com.oracle.graal.hotspot.jvmci.InitTimer.*; @@ -42,7 +41,6 @@ import com.oracle.graal.compiler.target.*; import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; -import com.oracle.graal.hotspot.CompileTheWorld.Config; import com.oracle.graal.hotspot.debug.*; import com.oracle.graal.hotspot.events.*; import com.oracle.graal.hotspot.jvmci.*; @@ -59,7 +57,7 @@ /** * Singleton class holding the instance of the {@link GraalRuntime}. */ -public final class HotSpotGraalRuntime implements HotSpotGraalRuntimeProvider, HotSpotProxified, HotSpotVMEventListener { +public final class HotSpotGraalRuntime implements HotSpotGraalRuntimeProvider, HotSpotProxified { private static final HotSpotGraalRuntime instance; @@ -209,19 +207,9 @@ private final HotSpotJVMCIRuntime jvmciRuntime; - public static class HotSpotGraalRuntimeFactory implements GraalRuntimeFactory { - - @Override - public GraalRuntime getRuntime() { - return runtime(); - } - - } - private HotSpotGraalRuntime() { jvmciRuntime = (HotSpotJVMCIRuntime) JVMCI.getRuntime(); - jvmciRuntime.registerVMEventListener(this); HotSpotVMConfig config = getConfig(); CompileTheWorld.Options.overrideWithNativeOptions(config); @@ -452,22 +440,7 @@ CompilationStatistics.clear(phase); } - @Override - public void notifyCompileTheWorld() throws Throwable { - CompilerToVM compilerToVM = runtime().getJVMCIRuntime().getCompilerToVM(); - int iterations = CompileTheWorld.Options.CompileTheWorldIterations.getValue(); - for (int i = 0; i < iterations; i++) { - compilerToVM.resetCompilationStatistics(); - TTY.println("CompileTheWorld : iteration " + i); - CompileTheWorld ctw = new CompileTheWorld(CompileTheWorldClasspath.getValue(), new Config(CompileTheWorldConfig.getValue()), CompileTheWorldStartAt.getValue(), - CompileTheWorldStopAt.getValue(), CompileTheWorldMethodFilter.getValue(), CompileTheWorldExcludeMethodFilter.getValue(), CompileTheWorldVerbose.getValue()); - ctw.compile(); - } - System.exit(0); - } - - @Override - public void notifyShutdown() { + void shutdown() { if (debugValuesPrinter != null) { debugValuesPrinter.printDebugValues(); } diff -r ee764a50af61 -r b118c9be1d1f graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntimeFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntimeFactory.java Sun May 24 14:44:28 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.hotspot; + +import com.oracle.graal.api.runtime.*; + +@ServiceProvider(GraalRuntimeFactory.class) +public class HotSpotGraalRuntimeFactory implements GraalRuntimeFactory { + + @Override + public GraalRuntime getRuntime() { + return HotSpotGraalRuntime.runtime(); + } +} diff -r ee764a50af61 -r b118c9be1d1f graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalVMEventListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalVMEventListener.java Sun May 24 14:44:28 2015 +0200 @@ -0,0 +1,53 @@ +/* + * 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.hotspot; + +import static com.oracle.graal.hotspot.CompileTheWorld.Options.*; + +import com.oracle.graal.api.runtime.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.hotspot.CompileTheWorld.Config; +import com.oracle.graal.hotspot.jvmci.*; + +@ServiceProvider(HotSpotVMEventListener.class) +public class HotSpotGraalVMEventListener implements HotSpotVMEventListener { + + @Override + public void notifyCompileTheWorld() throws Throwable { + CompilerToVM compilerToVM = HotSpotGraalRuntime.runtime().getJVMCIRuntime().getCompilerToVM(); + int iterations = CompileTheWorld.Options.CompileTheWorldIterations.getValue(); + for (int i = 0; i < iterations; i++) { + compilerToVM.resetCompilationStatistics(); + TTY.println("CompileTheWorld : iteration " + i); + CompileTheWorld ctw = new CompileTheWorld(CompileTheWorldClasspath.getValue(), new Config(CompileTheWorldConfig.getValue()), CompileTheWorldStartAt.getValue(), + CompileTheWorldStopAt.getValue(), CompileTheWorldMethodFilter.getValue(), CompileTheWorldExcludeMethodFilter.getValue(), CompileTheWorldVerbose.getValue()); + ctw.compile(); + } + System.exit(0); + } + + @Override + public void notifyShutdown() { + HotSpotGraalRuntime.runtime().shutdown(); + } +} diff -r ee764a50af61 -r b118c9be1d1f graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotJVMCIRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotJVMCIRuntime.java Sun May 24 14:42:38 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotJVMCIRuntime.java Sun May 24 14:44:28 2015 +0200 @@ -288,20 +288,13 @@ return Collections.unmodifiableMap(backends); } - private HotSpotVMEventListener vmEventListener; - - public void registerVMEventListener(HotSpotVMEventListener l) { - assert vmEventListener == null : "cannot register multiple HotSpotVMEventListeners"; - vmEventListener = l; - } - /** * Called from the VM. */ - @SuppressWarnings("unused") + @SuppressWarnings({"unused", "static-method"}) private void compileTheWorld() throws Throwable { - if (vmEventListener != null) { - vmEventListener.notifyCompileTheWorld(); + for (HotSpotVMEventListener l : Services.load(HotSpotVMEventListener.class)) { + l.notifyCompileTheWorld(); } } @@ -310,10 +303,10 @@ * * Called from the VM. */ - @SuppressWarnings("unused") + @SuppressWarnings({"unused", "static-method"}) private void shutdown() throws Exception { - if (vmEventListener != null) { - vmEventListener.notifyShutdown(); + for (HotSpotVMEventListener l : Services.load(HotSpotVMEventListener.class)) { + l.notifyShutdown(); } } } diff -r ee764a50af61 -r b118c9be1d1f graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMEventListener.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMEventListener.java Sun May 24 14:42:38 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMEventListener.java Sun May 24 14:44:28 2015 +0200 @@ -22,7 +22,9 @@ */ package com.oracle.graal.hotspot.jvmci; -public interface HotSpotVMEventListener { +import com.oracle.graal.api.runtime.*; + +public interface HotSpotVMEventListener extends Service { /** * Notifies this client that HotSpot is running in CompileTheWorld mode and the JVMCI compiler diff -r ee764a50af61 -r b118c9be1d1f make/defs.make --- a/make/defs.make Sun May 24 14:42:38 2015 +0200 +++ b/make/defs.make Sun May 24 14:44:28 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.hotspot.jvmci.HotSpotVMEventListener EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/com.oracle.graal.api.runtime.OptionsParsed .PHONY: $(HS_ALT_MAKE)/defs.make