# HG changeset patch # User Roland Schatz # Date 1372072653 -7200 # Node ID 3e9820de1c1cfcf7be67e60ee056d90c85d2abe7 # Parent 329c22feda1ff7e2f00a5e9a1f495d62906cc1c3 New strategy for selecting the default compiler configuration. diff -r 329c22feda1f -r 3e9820de1c1c graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java --- 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 CompilerConfiguration = new OptionValue<>("basic"); + static final OptionValue CompilerConfiguration = new OptionValue<>(""); // @formatter:on } @@ -44,6 +44,7 @@ private final PhaseSuite midTier; private final PhaseSuite lowTier; + private static final CompilerConfiguration defaultConfiguration; private static final Map configurations; public PhaseSuite 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) {