changeset 10521:97aa9042965f

Merge
author Christos Kotselidis <christos.kotselidis@oracle.com>
date Mon, 24 Jun 2013 15:26:43 +0200
parents 590f8f159309 (current diff) fcc5fb4e2b9e (diff)
children 499f21a3bb81
files
diffstat 5 files changed, 120 insertions(+), 13 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 15:26:43 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 14:57:04 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Mon Jun 24 15:26:43 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/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java	Mon Jun 24 14:57:04 2013 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java	Mon Jun 24 15:26:43 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) {
--- a/mx/projects	Mon Jun 24 14:57:04 2013 +0200
+++ b/mx/projects	Mon Jun 24 15:26:43 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
 
--- a/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Mon Jun 24 14:57:04 2013 +0200
+++ b/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Mon Jun 24 15:26:43 2013 +0200
@@ -375,11 +375,13 @@
       __ testl(rcx, InvocationCounter::count_mask_value);
       __ jcc(Assembler::notZero, not_zero);
 
+      __ push(rax);
       __ push(rcx);
       __ call_VM(noreg, CAST_FROM_FN_PTR(address, graal_initialize_time), rdx, false);
       __ set_method_data_pointer_for_bcp();
       __ get_method(rbx);
       __ pop(rcx);
+      __ pop(rax);
 
       __ testl(rcx, InvocationCounter::count_mask_value);
       __ jcc(Assembler::zero, not_zero);