changeset 9717:f8e0bf2c70e2

consolidated the two RegisterConfig instances for HotSpotRuntime into one
author Doug Simon <doug.simon@oracle.com>
date Tue, 14 May 2013 22:02:23 +0200
parents b2ba1c6f9bf8
children 6623dda5fabb
files graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java
diffstat 4 files changed, 24 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java	Tue May 14 21:43:06 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java	Tue May 14 22:02:23 2013 +0200
@@ -34,7 +34,6 @@
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.phases.*;
 
-// @formatter:off
 public class AMD64HotSpotRegisterConfig implements RegisterConfig {
 
     private final Architecture architecture;
@@ -88,11 +87,13 @@
     }
 
     private static Register[] initAllocatable() {
+        // @formatter:off
         Register[] allocatable = {
                         rax, rbx, rcx, rdx, /*rsp,*/ rbp, rsi, rdi, r8, r9,  r10, r11, r12, r13, r14, /*r15, */
                         xmm0, xmm1, xmm2,  xmm3,  xmm4,  xmm5,  xmm6,  xmm7,
                         xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15
                     };
+        // @formatter:on
 
         if (GraalOptions.RegisterPressure != null) {
             String[] names = GraalOptions.RegisterPressure.split(",");
@@ -106,29 +107,18 @@
         return allocatable;
     }
 
-    public AMD64HotSpotRegisterConfig(Architecture architecture, HotSpotVMConfig config, boolean isNative) {
+    public AMD64HotSpotRegisterConfig(Architecture architecture, HotSpotVMConfig config) {
         this.architecture = architecture;
 
         if (config.windowsOs) {
-            javaGeneralParameterRegisters = new Register[] {rdx, r8, r9, rdi, rsi, rcx};
-            nativeGeneralParameterRegisters = new Register[] {rcx, rdx, r8, r9};
+            javaGeneralParameterRegisters = new Register[]{rdx, r8, r9, rdi, rsi, rcx};
+            nativeGeneralParameterRegisters = new Register[]{rcx, rdx, r8, r9};
         } else {
-            javaGeneralParameterRegisters = new Register[] {rsi, rdx, rcx, r8, r9, rdi};
-            nativeGeneralParameterRegisters = new Register[] {rdi, rsi, rdx, rcx, r8, r9};
+            javaGeneralParameterRegisters = new Register[]{rsi, rdx, rcx, r8, r9, rdi};
+            nativeGeneralParameterRegisters = new Register[]{rdi, rsi, rdx, rcx, r8, r9};
         }
 
-        if (isNative) {
-            Register[] regs = {
-                rax,  rcx,  rdx,   rbx,   rsp,   rbp,   rsi,   rdi,
-                r8,   r9,   r10,   r11,   r12,   r13,   r14,   r15,
-                xmm0, xmm1, xmm2,  xmm3,  xmm4,  xmm5,  xmm6,  xmm7,
-                xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15
-            };
-            csl = new CalleeSaveLayout(architecture, 0, -1, 8, regs);
-        } else {
-            csl = null;
-        }
-
+        csl = null;
         attributesMap = RegisterAttributes.createMap(this, AMD64.allRegisters);
     }
 
@@ -147,7 +137,8 @@
         if (type == Type.NativeCall) {
             return callingConvention(nativeGeneralParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
         }
-        // On x64, parameter locations are the same whether viewed from the caller or callee perspective   
+        // On x64, parameter locations are the same whether viewed
+        // from the caller or callee perspective
         return callingConvention(javaGeneralParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
     }
 
@@ -237,10 +228,6 @@
 
     @Override
     public String toString() {
-        String res = String.format(
-             "Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" +
-             "CallerSave:  " + Arrays.toString(getCallerSaveRegisters()) + "%n" +
-             "CalleeSave:  " + getCalleeSaveLayout() + "%n");
-        return res;
+        return String.format("Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave:  " + Arrays.toString(getCallerSaveRegisters()) + "%n");
     }
 }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java	Tue May 14 21:43:06 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java	Tue May 14 22:02:23 2013 +0200
@@ -93,7 +93,7 @@
     }
 
     @Override
-    protected RegisterConfig createRegisterConfig(boolean isNative) {
-        return new AMD64HotSpotRegisterConfig(graalRuntime.getTarget().arch, config, isNative);
+    protected RegisterConfig createRegisterConfig() {
+        return new AMD64HotSpotRegisterConfig(graalRuntime.getTarget().arch, config);
     }
 }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRuntime.java	Tue May 14 21:43:06 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRuntime.java	Tue May 14 22:02:23 2013 +0200
@@ -46,7 +46,7 @@
     }
 
     @Override
-    protected RegisterConfig createRegisterConfig(boolean isNative) {
+    protected RegisterConfig createRegisterConfig() {
         // SPARC: Create register configuration.
         return null;
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Tue May 14 21:43:06 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Tue May 14 22:02:23 2013 +0200
@@ -104,8 +104,7 @@
 
     public final HotSpotVMConfig config;
 
-    protected final RegisterConfig javaABI;
-    protected final RegisterConfig nativeABI;
+    protected final RegisterConfig regConfig;
     protected final HotSpotGraalRuntime graalRuntime;
 
     private CheckCastSnippets.Templates checkcastSnippets;
@@ -181,8 +180,7 @@
     public HotSpotRuntime(HotSpotVMConfig c, HotSpotGraalRuntime graalRuntime) {
         this.config = c;
         this.graalRuntime = graalRuntime;
-        javaABI = createRegisterConfig(false);
-        nativeABI = createRegisterConfig(true);
+        regConfig = createRegisterConfig();
     }
 
     protected HotSpotRuntimeCallTarget register(HotSpotRuntimeCallTarget call) {
@@ -195,7 +193,7 @@
      * Registers the details for linking a call to a {@link Stub}.
      */
     protected RuntimeCallTarget registerStubCall(Descriptor descriptor) {
-        return register(HotSpotRuntimeCallTarget.create(descriptor, 0L, PRESERVES_REGISTERS, JavaCallee, javaABI, this, graalRuntime.getCompilerToVM()));
+        return register(HotSpotRuntimeCallTarget.create(descriptor, 0L, PRESERVES_REGISTERS, JavaCallee, regConfig, this, graalRuntime.getCompilerToVM()));
     }
 
     /**
@@ -204,14 +202,14 @@
     protected RuntimeCallTarget registerCRuntimeCall(Descriptor descriptor, long address) {
         Class<?> resultType = descriptor.getResultType();
         assert resultType.isPrimitive() || Word.class.isAssignableFrom(resultType) : "C runtime call must return object thread local storage: " + descriptor;
-        return register(HotSpotRuntimeCallTarget.create(descriptor, address, DESTROYS_REGISTERS, NativeCall, nativeABI, this, graalRuntime.getCompilerToVM()));
+        return register(HotSpotRuntimeCallTarget.create(descriptor, address, DESTROYS_REGISTERS, NativeCall, regConfig, this, graalRuntime.getCompilerToVM()));
     }
 
     /**
      * Registers the details for a call to a stub that never returns.
      */
     protected RuntimeCallTarget registerNoReturnStub(Descriptor descriptor, long address, CallingConvention.Type ccType) {
-        return register(HotSpotRuntimeCallTarget.create(descriptor, address, PRESERVES_REGISTERS, ccType, javaABI, this, graalRuntime.getCompilerToVM()));
+        return register(HotSpotRuntimeCallTarget.create(descriptor, address, PRESERVES_REGISTERS, ccType, regConfig, this, graalRuntime.getCompilerToVM()));
     }
 
     /**
@@ -220,10 +218,10 @@
      * another thread.
      */
     protected RuntimeCallTarget registerLeafCall(Descriptor descriptor, long address, CallingConvention.Type ccType, RegisterEffect effect) {
-        return register(HotSpotRuntimeCallTarget.create(descriptor, address, effect, ccType, javaABI, this, graalRuntime.getCompilerToVM()));
+        return register(HotSpotRuntimeCallTarget.create(descriptor, address, effect, ccType, regConfig, this, graalRuntime.getCompilerToVM()));
     }
 
-    protected abstract RegisterConfig createRegisterConfig(boolean isNative);
+    protected abstract RegisterConfig createRegisterConfig();
 
     public void registerReplacements(Replacements replacements) {
         registerStubCall(VERIFY_OOP);
@@ -322,7 +320,7 @@
     }
 
     private void linkRuntimeCall(Descriptor descriptor, long address, Replacements replacements) {
-        RuntimeCallStub stub = new RuntimeCallStub(address, descriptor, true, this, replacements, nativeABI, graalRuntime.getCompilerToVM());
+        RuntimeCallStub stub = new RuntimeCallStub(address, descriptor, true, this, replacements, regConfig, graalRuntime.getCompilerToVM());
         HotSpotRuntimeCallTarget linkage = stub.getLinkage();
         HotSpotRuntimeCallTarget targetLinkage = stub.getTargetLinkage();
         linkage.setCompiledStub(stub);
@@ -353,7 +351,7 @@
         if (compResult != null) {
             HexCodeFile.addAnnotations(hcf, compResult.getAnnotations());
             addExceptionHandlersComment(compResult, hcf);
-            Register fp = javaABI.getFrameRegister();
+            Register fp = regConfig.getFrameRegister();
             RefMapFormatter slotFormatter = new RefMapFormatter(target.arch, target.wordSize, fp, 0);
             for (Infopoint infopoint : compResult.getInfopoints()) {
                 if (infopoint instanceof Call) {
@@ -457,7 +455,7 @@
 
     @Override
     public RegisterConfig lookupRegisterConfig() {
-        return javaABI;
+        return regConfig;
     }
 
     @Override