changeset 27224:c16b7f34bfd1

Make CallingConvention.Type extensible; remove unused stackOnly parameter
author Christian Wimmer <christian.wimmer@oracle.com>
date Fri, 22 Jan 2016 09:54:14 -0800
parents 0ab7a078bdd3
children 71106732d2da
files src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/CallingConvention.java src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/CodeUtil.java src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/RegisterConfig.java src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotRegisterConfig.java src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotRegisterConfig.java src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCallingConventionType.java
diffstat 7 files changed, 93 insertions(+), 65 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/CallingConvention.java	Fri Jan 22 09:20:30 2016 -0800
+++ b/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/CallingConvention.java	Fri Jan 22 09:54:14 2016 -0800
@@ -34,35 +34,9 @@
 public class CallingConvention {
 
     /**
-     * Constants denoting the type of a call for which a calling convention is requested.
+     * Marker interface denoting the type of a call for which a calling convention is requested.
      */
-    public enum Type {
-        /**
-         * A request for the outgoing argument locations at a call site to Java code.
-         */
-        JavaCall(true),
-
-        /**
-         * A request for the incoming argument locations.
-         */
-        JavaCallee(false),
-
-        /**
-         * A request for the outgoing argument locations at a call site to external native code that
-         * complies with the platform ABI.
-         */
-        NativeCall(true);
-
-        /**
-         * Determines if this is a request for the outgoing argument locations at a call site.
-         */
-        public final boolean out;
-
-        public static final Type[] VALUES = values();
-
-        private Type(boolean out) {
-            this.out = out;
-        }
+    public interface Type {
     }
 
     /**
--- a/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/CodeUtil.java	Fri Jan 22 09:20:30 2016 -0800
+++ b/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/CodeUtil.java	Fri Jan 22 09:54:14 2016 -0800
@@ -417,7 +417,7 @@
     /**
      * Create a calling convention from a {@link ResolvedJavaMethod}.
      */
-    public static CallingConvention getCallingConvention(CodeCacheProvider codeCache, CallingConvention.Type type, ResolvedJavaMethod method, boolean stackOnly) {
+    public static CallingConvention getCallingConvention(CodeCacheProvider codeCache, CallingConvention.Type type, ResolvedJavaMethod method) {
         Signature sig = method.getSignature();
         JavaType retType = sig.getReturnType(null);
         int sigCount = sig.getParameterCount(false);
@@ -434,6 +434,6 @@
         }
 
         RegisterConfig registerConfig = codeCache.getRegisterConfig();
-        return registerConfig.getCallingConvention(type, retType, argTypes, codeCache.getTarget(), stackOnly);
+        return registerConfig.getCallingConvention(type, retType, argTypes, codeCache.getTarget());
     }
 }
--- a/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/RegisterConfig.java	Fri Jan 22 09:20:30 2016 -0800
+++ b/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/RegisterConfig.java	Fri Jan 22 09:54:14 2016 -0800
@@ -57,9 +57,8 @@
      * @param returnType the return type (can be null for methods returning {@code void})
      * @param parameterTypes the types of the arguments of the call
      * @param target the target platform
-     * @param stackOnly ignore registers
      */
-    CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target, boolean stackOnly);
+    CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target);
 
     /**
      * Gets the ordered set of registers that are can be used to pass parameters according to a
--- a/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java	Fri Jan 22 09:20:30 2016 -0800
+++ b/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java	Fri Jan 22 09:54:14 2016 -0800
@@ -62,6 +62,7 @@
 import jdk.vm.ci.code.StackSlot;
 import jdk.vm.ci.code.TargetDescription;
 import jdk.vm.ci.common.JVMCIError;
+import jdk.vm.ci.hotspot.HotSpotCallingConventionType;
 import jdk.vm.ci.hotspot.HotSpotVMConfig;
 import jdk.vm.ci.meta.AllocatableValue;
 import jdk.vm.ci.meta.JavaKind;
@@ -191,13 +192,13 @@
     }
 
     @Override
-    public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target, boolean stackOnly) {
-        if (type == Type.NativeCall) {
-            return callingConvention(nativeGeneralParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
+    public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target) {
+        if (type == HotSpotCallingConventionType.NativeCall) {
+            return callingConvention(nativeGeneralParameterRegisters, returnType, parameterTypes, (HotSpotCallingConventionType) type, target);
         }
         // On x64, parameter locations are the same whether viewed
         // from the caller or callee perspective
-        return callingConvention(javaGeneralParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
+        return callingConvention(javaGeneralParameterRegisters, returnType, parameterTypes, (HotSpotCallingConventionType) type, target);
     }
 
     public Register[] getCallingConventionRegisters(Type type, JavaKind kind) {
@@ -209,7 +210,7 @@
             case Int:
             case Long:
             case Object:
-                return type == Type.NativeCall ? nativeGeneralParameterRegisters : javaGeneralParameterRegisters;
+                return type == HotSpotCallingConventionType.NativeCall ? nativeGeneralParameterRegisters : javaGeneralParameterRegisters;
             case Float:
             case Double:
                 return simdParameterRegisters;
@@ -218,7 +219,7 @@
         }
     }
 
-    private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, Type type, TargetDescription target, boolean stackOnly) {
+    private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, HotSpotCallingConventionType type, TargetDescription target) {
         AllocatableValue[] locations = new AllocatableValue[parameterTypes.length];
 
         int currentGeneral = 0;
@@ -236,14 +237,14 @@
                 case Int:
                 case Long:
                 case Object:
-                    if (!stackOnly && currentGeneral < generalParameterRegisters.length) {
+                    if (currentGeneral < generalParameterRegisters.length) {
                         Register register = generalParameterRegisters[currentGeneral++];
                         locations[i] = register.asValue(target.getLIRKind(kind));
                     }
                     break;
                 case Float:
                 case Double:
-                    if (!stackOnly && currentSIMD < simdParameterRegisters.length) {
+                    if (currentSIMD < simdParameterRegisters.length) {
                         Register register = simdParameterRegisters[currentSIMD++];
                         locations[i] = register.asValue(target.getLIRKind(kind));
                     }
--- a/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotRegisterConfig.java	Fri Jan 22 09:20:30 2016 -0800
+++ b/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotRegisterConfig.java	Fri Jan 22 09:54:14 2016 -0800
@@ -56,6 +56,7 @@
 import jdk.vm.ci.code.StackSlot;
 import jdk.vm.ci.code.TargetDescription;
 import jdk.vm.ci.common.JVMCIError;
+import jdk.vm.ci.hotspot.HotSpotCallingConventionType;
 import jdk.vm.ci.hotspot.HotSpotVMConfig;
 import jdk.vm.ci.meta.AllocatableValue;
 import jdk.vm.ci.meta.JavaKind;
@@ -190,13 +191,13 @@
     }
 
     @Override
-    public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target, boolean stackOnly) {
-        if (type == Type.NativeCall) {
-            return callingConvention(nativeGeneralParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
+    public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target) {
+        if (type == HotSpotCallingConventionType.NativeCall) {
+            return callingConvention(nativeGeneralParameterRegisters, returnType, parameterTypes, (HotSpotCallingConventionType) type, target);
         }
         // On x64, parameter locations are the same whether viewed
         // from the caller or callee perspective
-        return callingConvention(javaGeneralParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
+        return callingConvention(javaGeneralParameterRegisters, returnType, parameterTypes, (HotSpotCallingConventionType) type, target);
     }
 
     public Register[] getCallingConventionRegisters(Type type, JavaKind kind) {
@@ -208,7 +209,7 @@
             case Int:
             case Long:
             case Object:
-                return type == Type.NativeCall ? nativeGeneralParameterRegisters : javaGeneralParameterRegisters;
+                return type == HotSpotCallingConventionType.NativeCall ? nativeGeneralParameterRegisters : javaGeneralParameterRegisters;
             case Float:
             case Double:
                 return xmmParameterRegisters;
@@ -217,12 +218,12 @@
         }
     }
 
-    private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, Type type, TargetDescription target, boolean stackOnly) {
+    private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, HotSpotCallingConventionType type, TargetDescription target) {
         AllocatableValue[] locations = new AllocatableValue[parameterTypes.length];
 
         int currentGeneral = 0;
         int currentXMM = 0;
-        int currentStackOffset = type == Type.NativeCall && needsNativeStackHomeSpace ? generalParameterRegisters.length * target.wordSize : 0;
+        int currentStackOffset = type == HotSpotCallingConventionType.NativeCall && needsNativeStackHomeSpace ? generalParameterRegisters.length * target.wordSize : 0;
 
         for (int i = 0; i < parameterTypes.length; i++) {
             final JavaKind kind = parameterTypes[i].getJavaKind().getStackKind();
@@ -235,14 +236,14 @@
                 case Int:
                 case Long:
                 case Object:
-                    if (!stackOnly && currentGeneral < generalParameterRegisters.length) {
+                    if (currentGeneral < generalParameterRegisters.length) {
                         Register register = generalParameterRegisters[currentGeneral++];
                         locations[i] = register.asValue(target.getLIRKind(kind));
                     }
                     break;
                 case Float:
                 case Double:
-                    if (!stackOnly && currentXMM < xmmParameterRegisters.length) {
+                    if (currentXMM < xmmParameterRegisters.length) {
                         Register register = xmmParameterRegisters[currentXMM++];
                         locations[i] = register.asValue(target.getLIRKind(kind));
                     }
--- a/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotRegisterConfig.java	Fri Jan 22 09:20:30 2016 -0800
+++ b/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotRegisterConfig.java	Fri Jan 22 09:54:14 2016 -0800
@@ -22,9 +22,6 @@
  */
 package jdk.vm.ci.hotspot.sparc;
 
-import static jdk.vm.ci.code.CallingConvention.Type.JavaCall;
-import static jdk.vm.ci.code.CallingConvention.Type.JavaCallee;
-import static jdk.vm.ci.code.CallingConvention.Type.NativeCall;
 import static jdk.vm.ci.meta.JavaKind.Void;
 import static jdk.vm.ci.meta.Value.ILLEGAL;
 import static jdk.vm.ci.sparc.SPARC.REGISTER_SAFE_AREA_SIZE;
@@ -81,6 +78,7 @@
 import jdk.vm.ci.code.StackSlot;
 import jdk.vm.ci.code.TargetDescription;
 import jdk.vm.ci.common.JVMCIError;
+import jdk.vm.ci.hotspot.HotSpotCallingConventionType;
 import jdk.vm.ci.hotspot.HotSpotVMConfig;
 import jdk.vm.ci.meta.AllocatableValue;
 import jdk.vm.ci.meta.JavaKind;
@@ -200,12 +198,12 @@
     }
 
     @Override
-    public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target, boolean stackOnly) {
-        if (type == JavaCall || type == NativeCall) {
-            return callingConvention(cpuCallerParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
+    public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target) {
+        if (type == HotSpotCallingConventionType.JavaCall || type == HotSpotCallingConventionType.NativeCall) {
+            return callingConvention(cpuCallerParameterRegisters, returnType, parameterTypes, (HotSpotCallingConventionType) type, target);
         }
-        if (type == JavaCallee) {
-            return callingConvention(cpuCalleeParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
+        if (type == HotSpotCallingConventionType.JavaCallee) {
+            return callingConvention(cpuCalleeParameterRegisters, returnType, parameterTypes, (HotSpotCallingConventionType) type, target);
         }
         throw JVMCIError.shouldNotReachHere();
     }
@@ -219,7 +217,7 @@
             case Int:
             case Long:
             case Object:
-                return type == Type.JavaCallee ? cpuCalleeParameterRegisters : cpuCallerParameterRegisters;
+                return type == HotSpotCallingConventionType.JavaCallee ? cpuCalleeParameterRegisters : cpuCallerParameterRegisters;
             case Double:
             case Float:
                 return fpuFloatParameterRegisters;
@@ -228,7 +226,7 @@
         }
     }
 
-    private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, Type type, TargetDescription target, boolean stackOnly) {
+    private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, HotSpotCallingConventionType type, TargetDescription target) {
         AllocatableValue[] locations = new AllocatableValue[parameterTypes.length];
 
         int currentGeneral = 0;
@@ -246,13 +244,13 @@
                 case Int:
                 case Long:
                 case Object:
-                    if (!stackOnly && currentGeneral < generalParameterRegisters.length) {
+                    if (currentGeneral < generalParameterRegisters.length) {
                         Register register = generalParameterRegisters[currentGeneral++];
                         locations[i] = register.asValue(target.getLIRKind(kind));
                     }
                     break;
                 case Double:
-                    if (!stackOnly && currentFloating < fpuFloatParameterRegisters.length) {
+                    if (currentFloating < fpuFloatParameterRegisters.length) {
                         if (currentFloating % 2 != 0) {
                             // Make register number even to be a double reg
                             currentFloating++;
@@ -263,7 +261,7 @@
                     }
                     break;
                 case Float:
-                    if (!stackOnly && currentFloating < fpuFloatParameterRegisters.length) {
+                    if (currentFloating < fpuFloatParameterRegisters.length) {
                         Register register = fpuFloatParameterRegisters[currentFloating++];
                         locations[i] = register.asValue(target.getLIRKind(kind));
                     }
@@ -287,7 +285,7 @@
         AllocatableValue returnLocation = returnKind == Void ? ILLEGAL : getReturnRegister(returnKind, type).asValue(target.getLIRKind(returnKind.getStackKind()));
 
         int outArgSpillArea;
-        if (type == NativeCall && addNativeRegisterArgumentSlots) {
+        if (type == HotSpotCallingConventionType.NativeCall && addNativeRegisterArgumentSlots) {
             // Space for native callee which may spill our outgoing arguments
             outArgSpillArea = Math.min(locations.length, generalParameterRegisters.length) * target.wordSize;
         } else {
@@ -302,7 +300,7 @@
 
     @Override
     public Register getReturnRegister(JavaKind kind) {
-        return getReturnRegister(kind, JavaCallee);
+        return getReturnRegister(kind, HotSpotCallingConventionType.JavaCallee);
     }
 
     private static Register getReturnRegister(JavaKind kind, Type type) {
@@ -314,7 +312,7 @@
             case Int:
             case Long:
             case Object:
-                return type == JavaCallee ? i0 : o0;
+                return type == HotSpotCallingConventionType.JavaCallee ? i0 : o0;
             case Float:
                 return f0;
             case Double:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCallingConventionType.java	Fri Jan 22 09:54:14 2016 -0800
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2016, 2016, 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 jdk.vm.ci.hotspot;
+
+import jdk.vm.ci.code.CallingConvention;
+import jdk.vm.ci.code.CallingConvention.Type;
+
+public enum HotSpotCallingConventionType implements CallingConvention.Type {
+    /**
+     * A request for the outgoing argument locations at a call site to Java code.
+     */
+    JavaCall(true),
+
+    /**
+     * A request for the incoming argument locations.
+     */
+    JavaCallee(false),
+
+    /**
+     * A request for the outgoing argument locations at a call site to external native code that
+     * complies with the platform ABI.
+     */
+    NativeCall(true);
+
+    /**
+     * Determines if this is a request for the outgoing argument locations at a call site.
+     */
+    public final boolean out;
+
+    public static final Type[] VALUES = values();
+
+    private HotSpotCallingConventionType(boolean out) {
+        this.out = out;
+    }
+}