changeset 10509:fcc5fb4e2b9e

New strategy for selecting the default runtime.
author Roland Schatz <roland.schatz@oracle.com>
date Mon, 24 Jun 2013 13:40:46 +0200
parents 3e9820de1c1c
children 9d995ba8b82c 97aa9042965f
files graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotGraalRuntimeFactory.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java mx/projects
diffstat 3 files changed, 78 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- /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 13:40:46 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";
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Mon Jun 24 13:17:33 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Mon Jun 24 13:40:46 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<String> GraalRuntime = new OptionValue<>(DEFAULT_GRAAL_RUNTIME);
+    private static final OptionValue<String> 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;
--- a/mx/projects	Mon Jun 24 13:17:33 2013 +0200
+++ b/mx/projects	Mon Jun 24 13:40:46 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