# HG changeset patch # User Roland Schatz # Date 1444725494 -7200 # Node ID a1f3697dd1443d53cc0766f7d19c3b57a6be58a4 # Parent b058d6325c2e233eb986322df32b251e26811244 Option for specifying different compiler configurations for user and system compilations. diff -r b058d6325c2e -r a1f3697dd144 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompilerFactory.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompilerFactory.java Mon Oct 12 20:05:18 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompilerFactory.java Tue Oct 13 10:38:14 2015 +0200 @@ -24,7 +24,6 @@ import static jdk.vm.ci.inittimer.InitTimer.timer; import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.compiler.Compiler; import jdk.vm.ci.compiler.CompilerFactory; import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; import jdk.vm.ci.inittimer.InitTimer; @@ -69,7 +68,7 @@ @SuppressWarnings("try") @Override - public Compiler createCompiler(JVMCIRuntime runtime) { + public HotSpotGraalCompiler createCompiler(JVMCIRuntime runtime) { HotSpotJVMCIRuntime jvmciRuntime = (HotSpotJVMCIRuntime) runtime; try (InitTimer t = timer("HotSpotGraalRuntime.")) { Lazy.registerBackends(); diff -r b058d6325c2e -r a1f3697dd144 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntimeAccess.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntimeAccess.java Mon Oct 12 20:05:18 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntimeAccess.java Tue Oct 13 10:38:14 2015 +0200 @@ -22,9 +22,14 @@ */ package com.oracle.graal.hotspot; +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.compiler.CompilerFactory; import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider; +import jdk.vm.ci.options.Option; +import jdk.vm.ci.options.OptionValue; import jdk.vm.ci.service.ServiceProvider; +import jdk.vm.ci.service.Services; import com.oracle.graal.api.runtime.GraalRuntime; import com.oracle.graal.api.runtime.GraalRuntimeAccess; @@ -32,10 +37,31 @@ @ServiceProvider(GraalRuntimeAccess.class) public class HotSpotGraalRuntimeAccess implements GraalRuntimeAccess { + static class Options { + @Option(help = "") public static final OptionValue UserCompiler = new OptionValue<>(null); + } + @Override public GraalRuntime getRuntime() { - HotSpotJVMCIRuntimeProvider jvmciRuntime = HotSpotJVMCIRuntime.runtime(); - HotSpotGraalCompiler compiler = (HotSpotGraalCompiler) jvmciRuntime.getCompiler(); + HotSpotGraalCompiler compiler = getCompiler(Options.UserCompiler.getValue()); return compiler.getGraalRuntime(); } + + private static HotSpotGraalCompiler getCompiler(String config) { + HotSpotJVMCIRuntimeProvider jvmciRuntime = HotSpotJVMCIRuntime.runtime(); + if (config == null) { + // default: fall back to the JVMCI system compiler + return (HotSpotGraalCompiler) jvmciRuntime.getCompiler(); + } else { + for (CompilerFactory factory : Services.load(CompilerFactory.class)) { + if (factory instanceof HotSpotGraalCompilerFactory) { + HotSpotGraalCompilerFactory graalFactory = (HotSpotGraalCompilerFactory) factory; + if (config.equals(factory.getCompilerName())) { + return graalFactory.createCompiler(jvmciRuntime); + } + } + } + throw new JVMCIError("Graal compiler configuration '" + config + "' not found"); + } + } }