# HG changeset patch # User Andreas Woess # Date 1372084832 -7200 # Node ID 9d995ba8b82c708fafc3176594bff988721122a1 # Parent fcc5fb4e2b9ea442e50ce3064efb7c119555aee4# Parent f40010b67b6e668c8b6772cdc19ae56f77a2bea6 Merge diff -r f40010b67b6e -r 9d995ba8b82c graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotGraalRuntimeFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotGraalRuntimeFactory.java Mon Jun 24 16:40:32 2013 +0200 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013, 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.amd64; + +import com.oracle.graal.api.runtime.*; +import com.oracle.graal.hotspot.*; + +@ServiceProvider(HotSpotGraalRuntimeFactory.class) +public class AMD64HotSpotGraalRuntimeFactory implements HotSpotGraalRuntimeFactory { + + @Override + public HotSpotGraalRuntime createRuntime() { + return new AMD64HotSpotGraalRuntime(); + } + + @Override + public String getArchitecture() { + return "AMD64"; + } + + @Override + public String getName() { + return "basic"; + } +} diff -r f40010b67b6e -r 9d995ba8b82c 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 Mon Jun 24 12:57:44 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Mon Jun 24 16:40:32 2013 +0200 @@ -89,25 +89,47 @@ runtime.compilerToVm = toVM; } - private static final String DEFAULT_GRAAL_RUNTIME = "basic"; - // @formatter:off @Option(help = "The runtime configuration to use") - private static final OptionValue GraalRuntime = new OptionValue<>(DEFAULT_GRAAL_RUNTIME); + private static final OptionValue GraalRuntime = new OptionValue<>(""); // @formatter:on protected static HotSpotGraalRuntimeFactory findFactory(String architecture) { + HotSpotGraalRuntimeFactory basic = null; + HotSpotGraalRuntimeFactory selected = null; + HotSpotGraalRuntimeFactory nonBasic = null; + int nonBasicCount = 0; + for (HotSpotGraalRuntimeFactory factory : ServiceLoader.loadInstalled(HotSpotGraalRuntimeFactory.class)) { - if (factory.getArchitecture().equals(architecture) && factory.getName().equals(GraalRuntime.getValue())) { - return factory; + if (factory.getArchitecture().equals(architecture)) { + if (factory.getName().equals(GraalRuntime.getValue())) { + assert selected == null; + selected = factory; + } + if (factory.getName().equals("basic")) { + assert basic == null; + basic = factory; + } else { + nonBasic = factory; + nonBasicCount++; + } } } - if (!DEFAULT_GRAAL_RUNTIME.equals(GraalRuntime.getValue())) { - // Fail fast if a non-default value for GraalRuntime was specified - // and the corresponding factory is not available - throw new GraalInternalError("Specified runtime \"%s\" not available for the %s architecture", GraalRuntime.getValue(), architecture); + + 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 GraalInternalError("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; + } } - return null; } private static Kind wordKind; diff -r f40010b67b6e -r 9d995ba8b82c 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 12:57:44 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java Mon Jun 24 16:40:32 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) { diff -r f40010b67b6e -r 9d995ba8b82c mx/projects --- a/mx/projects Mon Jun 24 12:57:44 2013 +0200 +++ b/mx/projects Mon Jun 24 16:40:32 2013 +0200 @@ -119,6 +119,7 @@ project@com.oracle.graal.hotspot.amd64@sourceDirs=src project@com.oracle.graal.hotspot.amd64@dependencies=com.oracle.graal.hotspot,com.oracle.graal.compiler.amd64,com.oracle.graal.replacements.amd64 project@com.oracle.graal.hotspot.amd64@checkstyle=com.oracle.graal.graph +project@com.oracle.graal.hotspot.amd64@annotationProcessors=com.oracle.graal.service.processor project@com.oracle.graal.hotspot.amd64@javaCompliance=1.7 project@com.oracle.graal.hotspot.amd64@workingSets=Graal,HotSpot,AMD64