changeset 10508:3e9820de1c1c

New strategy for selecting the default compiler configuration.
author Roland Schatz <roland.schatz@oracle.com>
date Mon, 24 Jun 2013 13:17:33 +0200
parents 329c22feda1f
children fcc5fb4e2b9e
files graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java
diffstat 1 files changed, 40 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java	Mon Jun 24 11:56:24 2013 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java	Mon Jun 24 13:17:33 2013 +0200
@@ -36,7 +36,7 @@
 
         // @formatter:off
         @Option(help = "The compiler configuration to use")
-        static final OptionValue<String> CompilerConfiguration = new OptionValue<>("basic");
+        static final OptionValue<String> CompilerConfiguration = new OptionValue<>("");
         // @formatter:on
     }
 
@@ -44,6 +44,7 @@
     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() {
@@ -60,12 +61,48 @@
 
     static {
         configurations = new HashMap<>();
+        CompilerConfiguration basic = null;
+        CompilerConfiguration nonBasic = null;
+        int nonBasicCount = 0;
+
         for (CompilerConfiguration config : ServiceLoader.loadInstalled(CompilerConfiguration.class)) {
             String name = config.getClass().getSimpleName();
             if (name.endsWith("CompilerConfiguration")) {
                 name = name.substring(0, name.length() - "CompilerConfiguration".length());
             }
-            configurations.put(name.toLowerCase(), config);
+            name = name.toLowerCase();
+
+            configurations.put(name, config);
+            if (name.equals("basic")) {
+                assert basic == null;
+                basic = config;
+            } else {
+                nonBasic = config;
+                nonBasicCount++;
+            }
+        }
+
+        if (CompilerConfiguration.getValue().equals("")) {
+            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 GraalInternalError("unable to find basic compiler configuration");
+                }
+            }
+        } else {
+            defaultConfiguration = configurations.get(CompilerConfiguration.getValue());
+            if (defaultConfiguration == null) {
+                throw new GraalInternalError("unknown compiler configuration: " + CompilerConfiguration.getValue());
+            }
         }
     }
 
@@ -76,7 +113,7 @@
     }
 
     public static Suites createDefaultSuites() {
-        return createSuites(CompilerConfiguration.getValue());
+        return new Suites(defaultConfiguration);
     }
 
     public static Suites createSuites(String name) {