Mercurial > hg > graal-compiler
changeset 22471:0a082a17d2a7
Use jvmci.compiler property for compiler selection.
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64SuitesProvider.java Wed Aug 12 13:57:35 2015 +0200 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64SuitesProvider.java Mon Aug 17 19:36:19 2015 +0200 @@ -24,15 +24,16 @@ import static com.oracle.graal.compiler.common.BackendOptions.*; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; +import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.*; import com.oracle.graal.java.*; import com.oracle.graal.lir.amd64.phases.*; import com.oracle.graal.lir.phases.*; +import com.oracle.graal.phases.tiers.*; public class AMD64SuitesProvider extends DefaultSuitesProvider { - public AMD64SuitesProvider(Plugins plugins) { - super(plugins); + public AMD64SuitesProvider(CompilerConfiguration compilerConfiguration, Plugins plugins) { + super(compilerConfiguration, plugins); } @Override
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/BasicCompilerConfiguration.java Wed Aug 12 13:57:35 2015 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/BasicCompilerConfiguration.java Mon Aug 17 19:36:19 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -22,16 +22,13 @@ */ package com.oracle.graal.compiler.phases; -import jdk.internal.jvmci.service.*; - -import com.oracle.graal.lir.phases.AllocationPhase.AllocationContext; import com.oracle.graal.lir.phases.*; -import com.oracle.graal.lir.phases.PostAllocationOptimizationPhase.PostAllocationOptimizationContext; -import com.oracle.graal.lir.phases.PreAllocationOptimizationPhase.PreAllocationOptimizationContext; +import com.oracle.graal.lir.phases.AllocationPhase.*; +import com.oracle.graal.lir.phases.PostAllocationOptimizationPhase.*; +import com.oracle.graal.lir.phases.PreAllocationOptimizationPhase.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.tiers.*; -@ServiceProvider(CompilerConfiguration.class) public class BasicCompilerConfiguration implements CompilerConfiguration { public PhaseSuite<HighTierContext> createHighTier() {
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/EconomyCompilerConfiguration.java Wed Aug 12 13:57:35 2015 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/EconomyCompilerConfiguration.java Mon Aug 17 19:36:19 2015 +0200 @@ -22,16 +22,13 @@ */ package com.oracle.graal.compiler.phases; -import jdk.internal.jvmci.service.*; - -import com.oracle.graal.lir.phases.AllocationPhase.AllocationContext; import com.oracle.graal.lir.phases.*; -import com.oracle.graal.lir.phases.PostAllocationOptimizationPhase.PostAllocationOptimizationContext; -import com.oracle.graal.lir.phases.PreAllocationOptimizationPhase.PreAllocationOptimizationContext; +import com.oracle.graal.lir.phases.AllocationPhase.*; +import com.oracle.graal.lir.phases.PostAllocationOptimizationPhase.*; +import com.oracle.graal.lir.phases.PreAllocationOptimizationPhase.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.tiers.*; -@ServiceProvider(CompilerConfiguration.class) public class EconomyCompilerConfiguration implements CompilerConfiguration { public PhaseSuite<HighTierContext> createHighTier() {
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Wed Aug 12 13:57:35 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Mon Aug 17 19:36:19 2015 +0200 @@ -26,28 +26,35 @@ import java.util.*; +import com.oracle.graal.api.replacements.*; +import com.oracle.graal.compiler.amd64.*; +import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.*; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.word.*; +import com.oracle.graal.phases.tiers.*; +import com.oracle.graal.phases.util.*; +import com.oracle.graal.replacements.amd64.*; + import jdk.internal.jvmci.amd64.*; import jdk.internal.jvmci.code.*; +import jdk.internal.jvmci.compiler.*; import jdk.internal.jvmci.hotspot.*; import jdk.internal.jvmci.inittimer.*; import jdk.internal.jvmci.meta.*; import jdk.internal.jvmci.runtime.*; import jdk.internal.jvmci.service.*; -import com.oracle.graal.api.replacements.*; -import com.oracle.graal.compiler.amd64.*; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.meta.*; -import com.oracle.graal.hotspot.word.*; -import com.oracle.graal.phases.util.*; -import com.oracle.graal.replacements.amd64.*; - -@ServiceProvider(HotSpotBackendFactory.class) -public class AMD64HotSpotBackendFactory implements HotSpotBackendFactory { +@ServiceProvider(StartupEventListener.class) +public class AMD64HotSpotBackendFactory implements HotSpotBackendFactory, StartupEventListener { @Override - public HotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, JVMCIBackend jvmci, HotSpotBackend host) { + public void beforeJVMCIStartup() { + DefaultHotSpotGraalCompilerFactory.registerBackend(AMD64.class, this); + } + + @Override + public HotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, CompilerConfiguration compilerConfiguration, JVMCIBackend jvmci, HotSpotBackend host) { assert host == null; HotSpotProviders providers; @@ -94,7 +101,7 @@ replacements.setGraphBuilderPlugins(plugins); } try (InitTimer rt = timer("create Suites provider")) { - suites = createSuites(runtime, plugins, codeCache, registers); + suites = createSuites(runtime, compilerConfiguration, plugins, codeCache, registers); } providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, suites, registers, snippetReflection, wordTypes, plugins); } @@ -128,8 +135,9 @@ return new AMD64HotSpotForeignCallsProvider(runtime, metaAccess, codeCache, nativeABICallerSaveRegisters); } - protected HotSpotSuitesProvider createSuites(HotSpotGraalRuntimeProvider runtime, Plugins plugins, CodeCacheProvider codeCache, HotSpotRegistersProvider registers) { - return new HotSpotSuitesProvider(new AMD64SuitesProvider(plugins), runtime, new AMD64HotSpotAddressLowering(codeCache, runtime.getConfig().getOopEncoding().base, + protected HotSpotSuitesProvider createSuites(HotSpotGraalRuntimeProvider runtime, CompilerConfiguration compilerConfiguration, Plugins plugins, CodeCacheProvider codeCache, + HotSpotRegistersProvider registers) { + return new HotSpotSuitesProvider(new AMD64SuitesProvider(compilerConfiguration, plugins), runtime, new AMD64HotSpotAddressLowering(codeCache, runtime.getConfig().getOopEncoding().base, registers.getHeapBaseRegister())); } @@ -168,15 +176,15 @@ } else { /* * System V Application Binary Interface, AMD64 Architecture Processor Supplement - * + * * Draft Version 0.96 - * + * * http://www.uclibc.org/docs/psABI-x86_64.pdf - * + * * 3.2.1 - * + * * ... - * + * * This subsection discusses usage of each register. Registers %rbp, %rbx and %r12 * through %r15 "belong" to the calling function and the called function is required to * preserve their values. In other words, a called function must preserve these @@ -198,16 +206,13 @@ return nativeABICallerSaveRegisters; } - public String getArchitecture() { + @Override + public String toString() { return "AMD64"; } - public String getGraalRuntimeName() { - return "basic"; - } - - @Override - public String toString() { - return getGraalRuntimeName() + ":" + getArchitecture(); + public Architecture initializeArchitecture(Architecture arch) { + assert arch instanceof AMD64; + return arch; } }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Wed Aug 12 13:57:35 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Mon Aug 17 19:36:19 2015 +0200 @@ -24,28 +24,35 @@ import java.util.*; +import com.oracle.graal.compiler.sparc.*; +import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.*; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.word.*; +import com.oracle.graal.java.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.phases.tiers.*; +import com.oracle.graal.phases.util.*; +import com.oracle.graal.replacements.sparc.*; + import jdk.internal.jvmci.code.*; +import jdk.internal.jvmci.compiler.*; import jdk.internal.jvmci.hotspot.*; import jdk.internal.jvmci.meta.*; import jdk.internal.jvmci.runtime.*; import jdk.internal.jvmci.service.*; import jdk.internal.jvmci.sparc.*; -import com.oracle.graal.compiler.sparc.*; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.meta.*; -import com.oracle.graal.hotspot.word.*; -import com.oracle.graal.java.*; -import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.phases.util.*; -import com.oracle.graal.replacements.sparc.*; - -@ServiceProvider(HotSpotBackendFactory.class) -public class SPARCHotSpotBackendFactory implements HotSpotBackendFactory { +@ServiceProvider(StartupEventListener.class) +public class SPARCHotSpotBackendFactory implements HotSpotBackendFactory, StartupEventListener { @Override - public HotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, JVMCIBackend jvmci, HotSpotBackend host) { + public void beforeJVMCIStartup() { + DefaultHotSpotGraalCompilerFactory.registerBackend(SPARC.class, this); + } + + @Override + public HotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, CompilerConfiguration compilerConfiguration, JVMCIBackend jvmci, HotSpotBackend host) { assert host == null; HotSpotRegistersProvider registers = createRegisters(); @@ -63,7 +70,7 @@ HotSpotWordTypes wordTypes = new HotSpotWordTypes(metaAccess, target.wordKind); Plugins plugins = createGraphBuilderPlugins(runtime, metaAccess, constantReflection, foreignCalls, stampProvider, snippetReflection, replacements, wordTypes); replacements.setGraphBuilderPlugins(plugins); - HotSpotSuitesProvider suites = createSuites(runtime, plugins, codeCache); + HotSpotSuitesProvider suites = createSuites(runtime, compilerConfiguration, plugins, codeCache); HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, suites, registers, snippetReflection, wordTypes, plugins); return createBackend(runtime, providers); @@ -77,8 +84,8 @@ return plugins; } - protected HotSpotSuitesProvider createSuites(HotSpotGraalRuntimeProvider runtime, Plugins plugins, CodeCacheProvider codeCache) { - return new HotSpotSuitesProvider(new DefaultSuitesProvider(plugins), runtime, new SPARCAddressLowering(codeCache)); + protected HotSpotSuitesProvider createSuites(HotSpotGraalRuntimeProvider runtime, CompilerConfiguration compilerConfiguration, Plugins plugins, CodeCacheProvider codeCache) { + return new HotSpotSuitesProvider(new DefaultSuitesProvider(compilerConfiguration, plugins), runtime, new SPARCAddressLowering(codeCache)); } protected SPARCHotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, HotSpotProviders providers) { @@ -112,17 +119,12 @@ } @Override - public String getArchitecture() { + public String toString() { return "SPARC"; } - @Override - public String getGraalRuntimeName() { - return "basic"; - } - - @Override - public String toString() { - return getGraalRuntimeName() + ":" + getArchitecture(); + public Architecture initializeArchitecture(Architecture arch) { + assert arch instanceof SPARC; + return arch; } }
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompileTheWorldTest.java Wed Aug 12 13:57:35 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompileTheWorldTest.java Mon Aug 17 19:36:19 2015 +0200 @@ -28,7 +28,9 @@ import com.oracle.graal.compiler.test.*; import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.CompileTheWorld.Config; +import com.oracle.graal.hotspot.CompileTheWorld.*; + +import jdk.internal.jvmci.hotspot.*; /** * Tests {@link CompileTheWorld} functionality. @@ -40,7 +42,8 @@ boolean originalSetting = ExitVMOnException.getValue(); // Compile a couple classes in rt.jar String file = System.getProperty("java.home") + "/lib/rt.jar"; - new CompileTheWorld(file, new Config(null), 1, 5, null, null, false).compile(); + HotSpotJVMCIRuntime runtime = HotSpotJVMCIRuntime.runtime(); + new CompileTheWorld(runtime, (HotSpotGraalCompiler) runtime.getCompiler(), file, new Config(null), 1, 5, null, null, false).compile(); assert ExitVMOnException.getValue() == originalSetting; }
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java Wed Aug 12 13:57:35 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java Mon Aug 17 19:36:19 2015 +0200 @@ -132,7 +132,8 @@ long graalEnv = 0L; try (MemoryUsageCloseable c = label == null ? null : new MemoryUsageCloseable(label)) { - CompilationTask task = new CompilationTask(method, jdk.internal.jvmci.compiler.Compiler.INVOCATION_ENTRY_BCI, graalEnv, id, false); + HotSpotJVMCIRuntime runtime = HotSpotJVMCIRuntime.runtime(); + CompilationTask task = new CompilationTask(runtime, (HotSpotGraalCompiler) runtime.getCompiler(), method, jdk.internal.jvmci.compiler.Compiler.INVOCATION_ENTRY_BCI, graalEnv, id, false); task.runCompilation(); } } @@ -147,7 +148,9 @@ int id = method.allocateCompileId(jdk.internal.jvmci.compiler.Compiler.INVOCATION_ENTRY_BCI); long graalEnv = 0L; try (AllocSpy as = AllocSpy.open(methodName)) { - CompilationTask task = new CompilationTask(method, jdk.internal.jvmci.compiler.Compiler.INVOCATION_ENTRY_BCI, graalEnv, id, false); + HotSpotJVMCIRuntime runtime = HotSpotJVMCIRuntime.runtime(); + CompilationTask task = new CompilationTask(runtime, (HotSpotGraalCompiler) runtime.getCompiler(), method, jdk.internal.jvmci.compiler.Compiler.INVOCATION_ENTRY_BCI, graalEnv, id, + false); task.runCompilation(); } } @@ -172,7 +175,8 @@ compileAndTime("simple"); compileAndTime("complex"); if (CompileTheWorld.Options.CompileTheWorldClasspath.getValue() != CompileTheWorld.SUN_BOOT_CLASS_PATH) { - CompileTheWorld ctw = new CompileTheWorld(); + HotSpotJVMCIRuntime runtime = HotSpotJVMCIRuntime.runtime(); + CompileTheWorld ctw = new CompileTheWorld(runtime, (HotSpotGraalCompiler) runtime.getCompiler()); try { ctw.compile(); } catch (Throwable e) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Wed Aug 12 13:57:35 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Mon Aug 17 19:36:19 2015 +0200 @@ -28,15 +28,13 @@ import java.util.concurrent.*; import com.oracle.graal.debug.*; -import com.oracle.graal.debug.Debug.Scope; -import com.oracle.graal.debug.internal.*; +import com.oracle.graal.debug.Debug.*; import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.compiler.Compiler; import jdk.internal.jvmci.hotspot.*; import jdk.internal.jvmci.hotspot.events.*; -import jdk.internal.jvmci.hotspot.events.EventProvider.CompilationEvent; -import jdk.internal.jvmci.hotspot.events.EventProvider.CompilerFailureEvent; +import jdk.internal.jvmci.hotspot.events.EventProvider.*; import jdk.internal.jvmci.meta.*; import jdk.internal.jvmci.service.*; @@ -57,6 +55,10 @@ } } + private final HotSpotJVMCIRuntimeProvider jvmciRuntime; + + private final HotSpotGraalCompiler compiler; + private final HotSpotResolvedJavaMethod method; private final int entryBCI; private final int id; @@ -80,7 +82,9 @@ */ private final long jvmciEnv; - public CompilationTask(HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id, boolean installAsDefault) { + public CompilationTask(HotSpotJVMCIRuntimeProvider jvmciRuntime, HotSpotGraalCompiler compiler, HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id, boolean installAsDefault) { + this.jvmciRuntime = jvmciRuntime; + this.compiler = compiler; this.method = method; this.entryBCI = entryBCI; this.id = id; @@ -118,7 +122,7 @@ public static final DebugTimer CodeInstallationTime = Debug.timer("CodeInstallation"); public void runCompilation() { - HotSpotVMConfig config = HotSpotJVMCIRuntime.runtime().getConfig(); + HotSpotVMConfig config = jvmciRuntime.getConfig(); final long threadId = Thread.currentThread().getId(); long startCompilationTime = System.nanoTime(); HotSpotInstalledCode installedCode = null; @@ -158,7 +162,6 @@ // Begin the compilation event. compilationEvent.begin(); - HotSpotGraalCompiler compiler = new HotSpotGraalCompiler(); result = compiler.compile(method, entryBCI, mustRecordMethodInlining(config)); result.setId(getId()); @@ -245,7 +248,7 @@ long compilationTime = System.nanoTime() - startCompilationTime; if ((config.ciTime || config.ciTimeEach) && installedCode != null) { long timeUnitsPerSecond = TimeUnit.NANOSECONDS.convert(1, TimeUnit.SECONDS); - CompilerToVM c2vm = HotSpotJVMCIRuntime.runtime().getCompilerToVM(); + CompilerToVM c2vm = jvmciRuntime.getCompilerToVM(); c2vm.notifyCompilationStatistics(id, method, entryBCI != Compiler.INVOCATION_ENTRY_BCI, compiledBytecodes, compilationTime, timeUnitsPerSecond, installedCode); } } @@ -270,7 +273,7 @@ } private InstalledCode installMethod(final CompilationResult compResult) { - final HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) HotSpotJVMCIRuntime.runtime().getHostJVMCIBackend().getCodeCache(); + final HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) jvmciRuntime.getHostJVMCIBackend().getCodeCache(); InstalledCode installedCode = null; try (Scope s = Debug.scope("CodeInstall", new DebugDumpScope(String.valueOf(id), true), codeCache, method)) { installedCode = codeCache.installMethod(method, compResult, jvmciEnv, installAsDefault); @@ -284,20 +287,4 @@ public String toString() { return "Compilation[id=" + id + ", " + method.format("%H.%n(%p)") + (entryBCI == Compiler.INVOCATION_ENTRY_BCI ? "" : "@" + entryBCI) + "]"; } - - /** - * Compiles a method to machine code. - */ - public static void compileMethod(HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id) { - // Ensure a debug configuration for this thread is initialized - if (Debug.isEnabled() && DebugScope.getConfig() == null) { - DebugEnvironment.initialize(TTY.out); - } - - CompilationTask task = new CompilationTask(method, entryBCI, jvmciEnv, id, true); - try (DebugConfigScope dcs = Debug.setConfig(new TopLevelDebugConfig())) { - task.runCompilation(); - } - return; - } }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java Wed Aug 12 13:57:35 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java Mon Aug 17 19:36:19 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -141,6 +141,10 @@ } } + private final HotSpotJVMCIRuntimeProvider jvmciRuntime; + + private final HotSpotGraalCompiler compiler; + /** List of Zip/Jar files to compile (see {@link Options#CompileTheWorldClasspath}). */ private final String files; @@ -181,7 +185,10 @@ * @param methodFilters * @param excludeMethodFilters */ - public CompileTheWorld(String files, Config config, int startAt, int stopAt, String methodFilters, String excludeMethodFilters, boolean verbose) { + public CompileTheWorld(HotSpotJVMCIRuntimeProvider jvmciRuntime, HotSpotGraalCompiler compiler, String files, Config config, int startAt, int stopAt, String methodFilters, + String excludeMethodFilters, boolean verbose) { + this.jvmciRuntime = jvmciRuntime; + this.compiler = compiler; this.files = files; this.startAt = startAt; this.stopAt = stopAt; @@ -199,8 +206,8 @@ config.putIfAbsent(HotSpotResolvedJavaMethodImpl.Options.UseProfilingInformation, false); } - public CompileTheWorld() { - this(CompileTheWorldClasspath.getValue(), new Config(CompileTheWorldConfig.getValue()), CompileTheWorldStartAt.getValue(), CompileTheWorldStopAt.getValue(), + public CompileTheWorld(HotSpotJVMCIRuntimeProvider jvmciRuntime, HotSpotGraalCompiler compiler) { + this(jvmciRuntime, compiler, CompileTheWorldClasspath.getValue(), new Config(CompileTheWorldConfig.getValue()), CompileTheWorldStartAt.getValue(), CompileTheWorldStopAt.getValue(), CompileTheWorldMethodFilter.getValue(), CompileTheWorldExcludeMethodFilter.getValue(), CompileTheWorldVerbose.getValue()); } @@ -278,7 +285,7 @@ // compile dummy method to get compiler initilized outside of the config debug override. HotSpotResolvedJavaMethod dummyMethod = (HotSpotResolvedJavaMethod) JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess().lookupJavaMethod( CompileTheWorld.class.getDeclaredMethod("dummy")); - CompilationTask task = new CompilationTask(dummyMethod, Compiler.INVOCATION_ENTRY_BCI, 0L, dummyMethod.allocateCompileId(Compiler.INVOCATION_ENTRY_BCI), false); + CompilationTask task = new CompilationTask(jvmciRuntime, compiler, dummyMethod, Compiler.INVOCATION_ENTRY_BCI, 0L, dummyMethod.allocateCompileId(Compiler.INVOCATION_ENTRY_BCI), false); task.runCompilation(); } catch (NoSuchMethodException | SecurityException e1) { e1.printStackTrace(); @@ -468,7 +475,7 @@ long start = System.currentTimeMillis(); long allocatedAtStart = MemUseTrackerImpl.getCurrentThreadAllocatedBytes(); - CompilationTask task = new CompilationTask(method, Compiler.INVOCATION_ENTRY_BCI, 0L, method.allocateCompileId(Compiler.INVOCATION_ENTRY_BCI), false); + CompilationTask task = new CompilationTask(jvmciRuntime, compiler, method, Compiler.INVOCATION_ENTRY_BCI, 0L, method.allocateCompileId(Compiler.INVOCATION_ENTRY_BCI), false); task.runCompilation(); memoryUsed.getAndAdd(MemUseTrackerImpl.getCurrentThreadAllocatedBytes() - allocatedAtStart);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/DefaultHotSpotGraalCompilerFactory.java Mon Aug 17 19:36:19 2015 +0200 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2015, 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 java.util.*; + +import com.oracle.graal.compiler.phases.*; +import com.oracle.graal.phases.tiers.*; + +import jdk.internal.jvmci.code.*; +import jdk.internal.jvmci.compiler.*; +import jdk.internal.jvmci.service.*; + +@ServiceProvider(CompilerFactory.class) +public class DefaultHotSpotGraalCompilerFactory extends HotSpotGraalCompilerFactory { + + private static IdentityHashMap<Class<? extends Architecture>, HotSpotBackendFactory> backends = new IdentityHashMap<>(); + + public static void registerBackend(Class<? extends Architecture> arch, HotSpotBackendFactory factory) { + assert !backends.containsKey(arch) : "duplicate graal backend"; + backends.put(arch, factory); + } + + @Override + public String getCompilerName() { + return "graal"; + } + + @Override + protected CompilerConfiguration createCompilerConfiguration() { + return new BasicCompilerConfiguration(); + } + + @Override + protected HotSpotBackendFactory getBackendFactory(Architecture arch) { + return backends.get(arch.getClass()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/EconomyHotSpotGraalCompilerFactory.java Mon Aug 17 19:36:19 2015 +0200 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015, 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.compiler.phases.*; +import com.oracle.graal.phases.tiers.*; + +import jdk.internal.jvmci.compiler.*; +import jdk.internal.jvmci.service.*; + +@ServiceProvider(CompilerFactory.class) +public class EconomyHotSpotGraalCompilerFactory extends DefaultHotSpotGraalCompilerFactory { + + @Override + public String getCompilerName() { + return "graal-economy"; + } + + @Override + protected CompilerConfiguration createCompilerConfiguration() { + return new EconomyCompilerConfiguration(); + } +}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackendFactory.java Wed Aug 12 13:57:35 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackendFactory.java Mon Aug 17 19:36:19 2015 +0200 @@ -22,22 +22,14 @@ */ package com.oracle.graal.hotspot; -import jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime.*; +import com.oracle.graal.phases.tiers.*; + +import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.runtime.*; public interface HotSpotBackendFactory { - HotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, JVMCIBackend jvmciBackend, HotSpotBackend host); - - /** - * Gets the CPU architecture of this backend. - */ - String getArchitecture(); + Architecture initializeArchitecture(Architecture arch); - /** - * Gets the name of the {@link Options#JVMCIRuntime JVMCIRuntime} in which the backend created - * by this factory should be used. - */ - String getGraalRuntimeName(); - + HotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, CompilerConfiguration compilerConfiguration, JVMCIBackend jvmciBackend, HotSpotBackend host); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompiler.java Wed Aug 12 13:57:35 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompiler.java Mon Aug 17 19:36:19 2015 +0200 @@ -28,6 +28,8 @@ import static jdk.internal.jvmci.code.CodeUtil.*; import com.oracle.graal.compiler.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.debug.internal.*; import com.oracle.graal.graphbuilderconf.*; import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.*; import com.oracle.graal.hotspot.meta.*; @@ -45,9 +47,42 @@ import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.code.CallingConvention.*; import jdk.internal.jvmci.compiler.Compiler; +import jdk.internal.jvmci.hotspot.*; import jdk.internal.jvmci.meta.*; -public class HotSpotGraalCompiler { +public class HotSpotGraalCompiler implements Compiler { + + private final HotSpotJVMCIRuntimeProvider jvmciRuntime; + + HotSpotGraalCompiler(HotSpotJVMCIRuntimeProvider jvmciRuntime) { + this.jvmciRuntime = jvmciRuntime; + } + + @Override + public void compileMethod(ResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id) { + // Ensure a debug configuration for this thread is initialized + if (Debug.isEnabled() && DebugScope.getConfig() == null) { + DebugEnvironment.initialize(TTY.out); + } + + CompilationTask task = new CompilationTask(jvmciRuntime, this, (HotSpotResolvedJavaMethod) method, entryBCI, jvmciEnv, id, true); + try (DebugConfigScope dcs = Debug.setConfig(new TopLevelDebugConfig())) { + task.runCompilation(); + } + } + + @Override + public void compileTheWorld() throws Throwable { + CompilerToVM compilerToVM = jvmciRuntime.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(jvmciRuntime, this); + ctw.compile(); + } + System.exit(0); + } public CompilationResult compile(ResolvedJavaMethod method, int entryBCI, boolean mustRecordMethodInlining) { HotSpotBackend backend = HotSpotGraalRuntime.runtime().getHostBackend(); @@ -83,8 +118,8 @@ // all code after the OSR loop is never executed. optimisticOpts.remove(Optimization.RemoveNeverExecutedCode); } - CompilationResult result = GraalCompiler.compileGraph(graph, cc, method, providers, backend, backend.getTarget(), getGraphBuilderSuite(providers, isOSR), optimisticOpts, profilingInfo, suites, - lirSuites, new CompilationResult(), CompilationResultBuilderFactory.Default); + CompilationResult result = GraalCompiler.compileGraph(graph, cc, method, providers, backend, backend.getTarget(), getGraphBuilderSuite(providers, isOSR), optimisticOpts, profilingInfo, + suites, lirSuites, new CompilationResult(), CompilationResultBuilderFactory.Default); result.setEntryBCI(entryBCI); @@ -107,14 +142,13 @@ Replacements replacements = providers.getReplacements(); ResolvedJavaMethod substMethod = replacements.getSubstitutionMethod(method); if (substMethod != null) { - assert!substMethod.equals(method); + assert !substMethod.equals(method); StructuredGraph graph = new StructuredGraph(substMethod, AllowAssumptions.YES); Plugins plugins = new Plugins(providers.getGraphBuilderPlugins()); GraphBuilderConfiguration config = GraphBuilderConfiguration.getSnippetDefault(plugins); IntrinsicContext initialReplacementContext = new IntrinsicContext(method, substMethod, ROOT_COMPILATION); - new GraphBuilderPhase.Instance(providers.getMetaAccess(), providers.getStampProvider(), providers.getConstantReflection(), config, OptimisticOptimizations.NONE, - initialReplacementContext).apply(graph); - assert!graph.isFrozen(); + new GraphBuilderPhase.Instance(providers.getMetaAccess(), providers.getStampProvider(), providers.getConstantReflection(), config, OptimisticOptimizations.NONE, initialReplacementContext).apply(graph); + assert !graph.isFrozen(); return graph; } return null;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompilerFactory.java Mon Aug 17 19:36:19 2015 +0200 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2015, 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.phases.tiers.*; + +import jdk.internal.jvmci.code.*; +import jdk.internal.jvmci.common.*; +import jdk.internal.jvmci.compiler.*; +import jdk.internal.jvmci.compiler.Compiler; +import jdk.internal.jvmci.hotspot.*; +import jdk.internal.jvmci.runtime.*; + +public abstract class HotSpotGraalCompilerFactory implements CompilerFactory { + + protected abstract HotSpotBackendFactory getBackendFactory(Architecture arch); + + protected abstract CompilerConfiguration createCompilerConfiguration(); + + @Override + public Architecture initializeArchitecture(Architecture arch) { + HotSpotBackendFactory backend = getBackendFactory(arch); + if (backend == null) { + throw new JVMCIError("no Graal backend found for %s", arch); + } + return backend.initializeArchitecture(arch); + } + + @Override + public Compiler createCompiler(JVMCIRuntime runtime) { + HotSpotJVMCIRuntime jvmciRuntime = (HotSpotJVMCIRuntime) runtime; + HotSpotGraalRuntime.initialize(jvmciRuntime, this); + return new HotSpotGraalCompiler(jvmciRuntime); + } +}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Wed Aug 12 13:57:35 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Mon Aug 17 19:36:19 2015 +0200 @@ -24,22 +24,11 @@ import static com.oracle.graal.compiler.common.GraalOptions.*; import static com.oracle.graal.debug.GraalDebugConfig.*; -import static com.oracle.graal.hotspot.HotSpotGraalRuntime.Options.*; import static jdk.internal.jvmci.inittimer.InitTimer.*; import java.lang.reflect.*; import java.util.*; -import jdk.internal.jvmci.code.*; -import jdk.internal.jvmci.code.stack.*; -import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.hotspot.*; -import jdk.internal.jvmci.inittimer.*; -import jdk.internal.jvmci.meta.*; -import jdk.internal.jvmci.options.*; -import jdk.internal.jvmci.runtime.*; -import jdk.internal.jvmci.service.*; - import com.oracle.graal.api.collections.*; import com.oracle.graal.api.replacements.*; import com.oracle.graal.api.runtime.*; @@ -49,9 +38,18 @@ import com.oracle.graal.hotspot.debug.*; import com.oracle.graal.hotspot.logging.*; import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.phases.tiers.*; import com.oracle.graal.replacements.*; import com.oracle.graal.runtime.*; +import jdk.internal.jvmci.code.*; +import jdk.internal.jvmci.code.stack.*; +import jdk.internal.jvmci.common.*; +import jdk.internal.jvmci.hotspot.*; +import jdk.internal.jvmci.inittimer.*; +import jdk.internal.jvmci.meta.*; +import jdk.internal.jvmci.runtime.*; + //JaCoCo Exclude /** @@ -59,27 +57,45 @@ */ public final class HotSpotGraalRuntime implements HotSpotGraalRuntimeProvider, HotSpotProxified { - private static final HotSpotGraalRuntime instance; + private static class Instance { + private static final HotSpotGraalRuntime instance; + + static { + try (InitTimer t0 = timer("HotSpotGraalRuntime.<clinit>")) { + // initJvmciRuntime and initCompilerFactory are set by the JVMCI initialization code + JVMCI.initialize(); + assert initJvmciRuntime != null && initCompilerFactory != null; - static { - try (InitTimer t0 = timer("HotSpotGraalRuntime.<clinit>")) { - try (InitTimer t = timer("HotSpotGraalRuntime.<init>")) { - instance = new HotSpotGraalRuntime(); - } + try (InitTimer t = timer("HotSpotGraalRuntime.<init>")) { + instance = new HotSpotGraalRuntime(initJvmciRuntime, initCompilerFactory); + } - try (InitTimer t = timer("HotSpotGraalRuntime.completeInitialization")) { - // Why deferred initialization? See comment in completeInitialization(). - instance.completeInitialization(); + try (InitTimer t = timer("HotSpotGraalRuntime.completeInitialization")) { + // Why deferred initialization? See comment in completeInitialization(). + instance.completeInitialization(); + } } } + + private static void forceStaticInitializer() { + } + } + + private static HotSpotJVMCIRuntime initJvmciRuntime; + private static HotSpotGraalCompilerFactory initCompilerFactory; + + public static void initialize(HotSpotJVMCIRuntime runtime, HotSpotGraalCompilerFactory factory) { + initJvmciRuntime = runtime; + initCompilerFactory = factory; + Instance.forceStaticInitializer(); } /** * Gets the singleton {@link HotSpotGraalRuntime} object. */ public static HotSpotGraalRuntime runtime() { - assert instance != null; - return instance; + assert Instance.instance != null; + return Instance.instance; } @Override @@ -99,71 +115,11 @@ return true; } - public static class Options { - - // @formatter:off - @Option(help = "The runtime configuration to use", type = OptionType.Expert) - static final OptionValue<String> GraalRuntime = new OptionValue<>(""); - // @formatter:on - } - - private static HotSpotBackendFactory findFactory(String architecture) { - HotSpotBackendFactory basic = null; - HotSpotBackendFactory selected = null; - HotSpotBackendFactory nonBasic = null; - int nonBasicCount = 0; - - assert GraalRuntime.getValue().equals(HotSpotJVMCIRuntime.Options.JVMCIRuntime.getValue()); - - for (HotSpotBackendFactory factory : Services.load(HotSpotBackendFactory.class)) { - if (factory.getArchitecture().equalsIgnoreCase(architecture)) { - if (factory.getGraalRuntimeName().equals(GraalRuntime.getValue())) { - assert selected == null || checkFactoryOverriding(selected, factory); - selected = factory; - } - if (factory.getGraalRuntimeName().equals("basic")) { - assert basic == null || checkFactoryOverriding(basic, factory); - basic = factory; - } else { - nonBasic = factory; - nonBasicCount++; - } - } - } - - if (selected != null) { - return selected; - } else { - if (!GraalRuntime.getValue().equals("")) { - // Fail fast if a non-default value for GraalRuntime was specified - // and the corresponding factory is not available - throw new JVMCIError("Specified runtime \"%s\" not available for the %s architecture", GraalRuntime.getValue(), architecture); - } else if (nonBasicCount == 1) { - // If there is exactly one non-basic runtime, select this one. - return nonBasic; - } else { - return basic; - } - } - } - - /** - * Checks that a factory overriding is valid. A factory B can only override/replace a factory A - * if the B.getClass() is a subclass of A.getClass(). This models the assumption that B is - * extends the behavior of A and has therefore understood the behavior expected of A. - * - * @param baseFactory - * @param overridingFactory - */ - private static boolean checkFactoryOverriding(HotSpotBackendFactory baseFactory, HotSpotBackendFactory overridingFactory) { - return baseFactory.getClass().isAssignableFrom(overridingFactory.getClass()); - } - /** * Gets the kind of a word value on the {@linkplain #getHostBackend() host} backend. */ public static Kind getHostWordKind() { - return instance.getHostBackend().getTarget().wordKind; + return runtime().getHostBackend().getTarget().wordKind; } private final HotSpotBackend hostBackend; @@ -173,9 +129,9 @@ private final HotSpotJVMCIRuntime jvmciRuntime; - private HotSpotGraalRuntime() { + private HotSpotGraalRuntime(HotSpotJVMCIRuntime jvmciRuntime, HotSpotGraalCompilerFactory compilerFactory) { - jvmciRuntime = (HotSpotJVMCIRuntime) JVMCI.getRuntime(); + this.jvmciRuntime = jvmciRuntime; HotSpotVMConfig config = getConfig(); CompileTheWorld.Options.overrideWithNativeOptions(config); @@ -189,26 +145,30 @@ printConfig(config); } - String hostArchitecture = config.getHostArchitectureName(); + CompilerConfiguration compilerConfiguration = compilerFactory.createCompilerConfiguration(); - HotSpotBackendFactory factory; - try (InitTimer t = timer("find factory:", hostArchitecture)) { - factory = findFactory(hostArchitecture); - } + JVMCIBackend hostJvmciBackend = jvmciRuntime.getHostJVMCIBackend(); + Architecture hostArchitecture = hostJvmciBackend.getTarget().arch; try (InitTimer t = timer("create backend:", hostArchitecture)) { - hostBackend = registerBackend(factory.createBackend(this, jvmciRuntime.getHostJVMCIBackend(), null)); + HotSpotBackendFactory factory = compilerFactory.getBackendFactory(hostArchitecture); + if (factory == null) { + throw new JVMCIError("No backend available for host architecture \"%s\"", hostArchitecture); + } + hostBackend = registerBackend(factory.createBackend(this, compilerConfiguration, jvmciRuntime.getHostJVMCIBackend(), null)); } - String[] gpuArchitectures = getGPUArchitectureNames(getCompilerToVM()); - for (String arch : gpuArchitectures) { - try (InitTimer t = timer("find factory:", arch)) { - factory = findFactory(arch); + for (JVMCIBackend jvmciBackend : jvmciRuntime.getBackends().values()) { + if (jvmciBackend == hostJvmciBackend) { + continue; } + + Architecture gpuArchitecture = jvmciBackend.getTarget().arch; + HotSpotBackendFactory factory = compilerFactory.getBackendFactory(gpuArchitecture); if (factory == null) { - throw new JVMCIError("No backend available for specified GPU architecture \"%s\"", arch); + throw new JVMCIError("No backend available for specified GPU architecture \"%s\"", gpuArchitecture); } - try (InitTimer t = timer("create backend:", arch)) { - registerBackend(factory.createBackend(this, null, hostBackend)); + try (InitTimer t = timer("create backend:", gpuArchitecture)) { + registerBackend(factory.createBackend(this, compilerConfiguration, null, hostBackend)); } } } @@ -273,19 +233,6 @@ return backend; } - /** - * Gets the names of the supported GPU architectures for the purpose of finding the - * corresponding {@linkplain HotSpotBackendFactory backend} objects. - */ - private static String[] getGPUArchitectureNames(CompilerToVM c2vm) { - String gpuList = c2vm.getGPUs(); - if (!gpuList.isEmpty()) { - String[] gpus = gpuList.split(","); - return gpus; - } - return new String[0]; - } - private static void printConfig(HotSpotVMConfig config) { Field[] fields = config.getClass().getDeclaredFields(); Map<String, Field> sortedFields = new TreeMap<>();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntimeProvider.java Wed Aug 12 13:57:35 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntimeProvider.java Mon Aug 17 19:36:19 2015 +0200 @@ -22,15 +22,15 @@ */ package com.oracle.graal.hotspot; +import com.oracle.graal.api.runtime.*; +import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.runtime.*; + import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.code.stack.*; import jdk.internal.jvmci.hotspot.*; import jdk.internal.jvmci.meta.*; -import com.oracle.graal.api.runtime.*; -import com.oracle.graal.hotspot.meta.*; -import com.oracle.graal.runtime.*; - //JaCoCo Exclude /**
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalVMEventListener.java Wed Aug 12 13:57:35 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalVMEventListener.java Mon Aug 17 19:36:19 2015 +0200 @@ -25,41 +25,22 @@ import java.lang.reflect.*; import java.util.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.hotspot.logging.*; + import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.hotspot.*; import jdk.internal.jvmci.service.*; -import com.oracle.graal.debug.*; -import com.oracle.graal.hotspot.logging.*; - @ServiceProvider(HotSpotVMEventListener.class) public class HotSpotGraalVMEventListener implements HotSpotVMEventListener { @Override - public void notifyCompileTheWorld() throws Throwable { - CompilerToVM compilerToVM = HotSpotJVMCIRuntime.runtime().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(); - ctw.compile(); - } - System.exit(0); - } - - @Override public void notifyShutdown() { HotSpotGraalRuntime.runtime().shutdown(); } @Override - public void compileMetaspaceMethod(long metaspaceMethod, int entryBCI, long jvmciEnv, int id) { - HotSpotResolvedJavaMethod method = HotSpotResolvedJavaMethodImpl.fromMetaspace(metaspaceMethod); - CompilationTask.compileMethod(method, entryBCI, jvmciEnv, id); - } - - @Override public void notifyInstall(HotSpotCodeCacheProvider codeCache, InstalledCode installedCode, CompilationResult compResult) { if (Debug.isDumpEnabled()) { Debug.dump(new Object[]{compResult, installedCode}, "After code installation");
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/DefaultSuitesProvider.java Wed Aug 12 13:57:35 2015 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/DefaultSuitesProvider.java Mon Aug 17 19:36:19 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -33,6 +33,8 @@ public class DefaultSuitesProvider implements SuitesProvider { + private final CompilerConfiguration compilerConfiguration; + private final DerivedOptionValue<Suites> defaultSuites; private final PhaseSuite<HighTierContext> defaultGraphBuilderSuite; private final DerivedOptionValue<LIRSuites> defaultLIRSuites; @@ -57,7 +59,8 @@ } - public DefaultSuitesProvider(Plugins plugins) { + public DefaultSuitesProvider(CompilerConfiguration compilerConfiguration, Plugins plugins) { + this.compilerConfiguration = compilerConfiguration; this.defaultGraphBuilderSuite = createGraphBuilderSuite(plugins); this.defaultSuites = new DerivedOptionValue<>(new SuitesSupplier()); this.defaultLIRSuites = new DerivedOptionValue<>(new LIRSuitesSupplier()); @@ -68,7 +71,7 @@ } public Suites createSuites() { - return Suites.createDefaultSuites(); + return Suites.createSuites(compilerConfiguration); } public PhaseSuite<HighTierContext> getDefaultGraphBuilderSuite() { @@ -86,7 +89,6 @@ } public LIRSuites createLIRSuites() { - return Suites.createDefaultLIRSuites(); + return Suites.createLIRSuites(compilerConfiguration); } - }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRSuites.java Wed Aug 12 13:57:35 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRSuites.java Mon Aug 17 19:36:19 2015 +0200 @@ -22,13 +22,13 @@ */ package com.oracle.graal.lir.phases; -import jdk.internal.jvmci.code.*; - import com.oracle.graal.lir.*; import com.oracle.graal.lir.gen.*; -import com.oracle.graal.lir.phases.AllocationPhase.AllocationContext; -import com.oracle.graal.lir.phases.PostAllocationOptimizationPhase.PostAllocationOptimizationContext; -import com.oracle.graal.lir.phases.PreAllocationOptimizationPhase.PreAllocationOptimizationContext; +import com.oracle.graal.lir.phases.AllocationPhase.*; +import com.oracle.graal.lir.phases.PostAllocationOptimizationPhase.*; +import com.oracle.graal.lir.phases.PreAllocationOptimizationPhase.*; + +import jdk.internal.jvmci.code.*; public class LIRSuites {
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java Wed Aug 12 13:57:35 2015 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java Mon Aug 17 19:36:19 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -22,34 +22,15 @@ */ package com.oracle.graal.phases.tiers; -import static com.oracle.graal.phases.tiers.Suites.Options.*; - -import java.util.*; - -import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.options.*; -import jdk.internal.jvmci.service.*; - import com.oracle.graal.lir.phases.*; import com.oracle.graal.phases.*; public final class Suites { - static class Options { - - // @formatter:off - @Option(help = "The compiler configuration to use", type = OptionType.User) - static final OptionValue<String> CompilerConfiguration = new OptionValue<>(""); - // @formatter:on - } - private final PhaseSuite<HighTierContext> highTier; private final PhaseSuite<MidTierContext> midTier; private final PhaseSuite<LowTierContext> lowTier; - private static final CompilerConfiguration defaultConfiguration; - private static final Map<String, CompilerConfiguration> configurations; - public PhaseSuite<HighTierContext> getHighTier() { return highTier; } @@ -62,93 +43,17 @@ return lowTier; } - static { - configurations = new HashMap<>(); - CompilerConfiguration basic = null; - CompilerConfiguration nonBasic = null; - int nonBasicCount = 0; - - for (CompilerConfiguration config : Services.load(CompilerConfiguration.class)) { - String name = config.getClass().getSimpleName(); - if (name.endsWith("CompilerConfiguration")) { - name = name.substring(0, name.length() - "CompilerConfiguration".length()); - } - name = name.toLowerCase(); - - configurations.put(name, config); - if (name.equals("economy")) { - // ignore economy configuration if not explicitely specified - } else if (name.equals("basic")) { - assert basic == null; - basic = config; - } else { - nonBasic = config; - nonBasicCount++; - } - } - - if (nonBasicCount == 1) { - /* - * There is exactly one non-basic configuration. We use this one as default. - */ - defaultConfiguration = nonBasic; - } else { - /* - * There is either no extended configuration available, or more than one. In that case, - * default to "basic". - */ - defaultConfiguration = basic; - if (defaultConfiguration == null) { - throw new JVMCIError("unable to find basic compiler configuration"); - } - } - } - public Suites(PhaseSuite<HighTierContext> highTier, PhaseSuite<MidTierContext> midTier, PhaseSuite<LowTierContext> lowTier) { this.highTier = highTier; this.midTier = midTier; this.lowTier = lowTier; } - private Suites(CompilerConfiguration config) { - highTier = config.createHighTier(); - midTier = config.createMidTier(); - lowTier = config.createLowTier(); - } - - public static Suites createDefaultSuites() { - String selected = CompilerConfiguration.getValue(); - if (selected.equals("")) { - return new Suites(defaultConfiguration); - } else { - return createSuites(selected); - } + public static Suites createSuites(CompilerConfiguration config) { + return new Suites(config.createHighTier(), config.createMidTier(), config.createLowTier()); } - public static Suites createSuites(String name) { - CompilerConfiguration config = configurations.get(name); - if (config == null) { - throw new JVMCIError("unknown compiler configuration: " + name); - } - return new Suites(config); - } - - public static LIRSuites createDefaultLIRSuites() { - String selected = CompilerConfiguration.getValue(); - if (selected.equals("")) { - return new LIRSuites(defaultConfiguration.createPreAllocationOptimizationStage(), defaultConfiguration.createAllocationStage(), - defaultConfiguration.createPostAllocationOptimizationStage()); - } else { - return createLIRSuites(selected); - } - } - - public static LIRSuites createLIRSuites(String name) { - CompilerConfiguration config = configurations.get(name); - if (config == null) { - throw new JVMCIError("unknown compiler configuration: " + name); - } + public static LIRSuites createLIRSuites(CompilerConfiguration config) { return new LIRSuites(config.createPreAllocationOptimizationStage(), config.createAllocationStage(), config.createPostAllocationOptimizationStage()); } - }
--- a/mx.graal/mx_graal.py Wed Aug 12 13:57:35 2015 +0200 +++ b/mx.graal/mx_graal.py Mon Aug 17 19:36:19 2015 +0200 @@ -43,7 +43,7 @@ class GraalJDKDeployedDist(JvmciJDKDeployedDist): def __init__(self): - JvmciJDKDeployedDist.__init__(self, 'GRAAL') + JvmciJDKDeployedDist.__init__(self, 'GRAAL', compilers=['graal', 'graal-economy']) def deploy(self, jdkDir): JvmciJDKDeployedDist.deploy(self, jdkDir) @@ -294,7 +294,7 @@ BootstrapTest('BootstrapWithSystemAssertionsNoCoop', 'fastdebug', ['-esa', '-XX:-UseCompressedOops']), BootstrapTest('BootstrapWithGCVecification', 'product', ['-XX:+UnlockDiagnosticVMOptions', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC'], suppress=['VerifyAfterGC:', 'VerifyBeforeGC:']), BootstrapTest('BootstrapWithG1GCVecification', 'product', ['-XX:+UnlockDiagnosticVMOptions', '-XX:-UseSerialGC', '-XX:+UseG1GC', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC'], suppress=['VerifyAfterGC:', 'VerifyBeforeGC:']), - BootstrapTest('BootstrapEconomyWithSystemAssertions', 'fastdebug', ['-esa', '-G:CompilerConfiguration=economy']), + BootstrapTest('BootstrapEconomyWithSystemAssertions', 'fastdebug', ['-esa', '-Djvmci.compiler=graal-economy']), BootstrapTest('BootstrapWithExceptionEdges', 'fastdebug', ['-esa', '-G:+StressInvokeWithExceptionNode']), BootstrapTest('BootstrapWithRegisterPressure', 'product', ['-esa', '-G:RegisterPressure=' + _registers]), BootstrapTest('BootstrapNonSSAWithRegisterPressure', 'product', ['-esa', '-G:-SSA_LIR', '-G:RegisterPressure=' + _registers]),
--- a/mx.graal/suite.py Wed Aug 12 13:57:35 2015 +0200 +++ b/mx.graal/suite.py Mon Aug 17 19:36:19 2015 +0200 @@ -6,7 +6,7 @@ "suites": [ { "name" : "jvmci", - "version" : "9c55f608b79e19647fb7a45afec3280b07bc47fa", + "version" : "a1b0a76567c79145782f810db06e53b0eb60fec8", "urls" : [ {"url" : "http://lafo.ssw.uni-linz.ac.at/hg/graal-jvmci-8", "kind" : "hg"}, {"url" : "http://lafo.ssw.uni-linz.ac.at/nexus/content/repositories/snapshots", "kind" : "binary"},