changeset 11239:6c098f64a7a6

added support for handling volatile registers across native runtime calls
author Doug Simon <doug.simon@oracle.com>
date Wed, 07 Aug 2013 01:52:44 +0200
parents a7c7b0bd0557
children 84589a49d184
files graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotGraalRuntime.java graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotGraalRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkage.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java
diffstat 4 files changed, 28 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotGraalRuntime.java	Tue Aug 06 23:36:36 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotGraalRuntime.java	Wed Aug 07 01:52:44 2013 +0200
@@ -22,8 +22,11 @@
  */
 package com.oracle.graal.hotspot.amd64;
 
+import static com.oracle.graal.amd64.AMD64.*;
+
 import com.oracle.graal.amd64.*;
 import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.*;
 
@@ -71,4 +74,9 @@
     protected HotSpotRuntime createRuntime() {
         return new AMD64HotSpotRuntime(config, this);
     }
+
+    @Override
+    protected Value[] getRuntimeCallVolatileRegisters() {
+        return new Value[]{r10.asValue(), r11.asValue()};
+    }
 }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotGraalRuntime.java	Tue Aug 06 23:36:36 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotGraalRuntime.java	Wed Aug 07 01:52:44 2013 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.hotspot.sparc;
 
 import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.sparc.*;
@@ -66,4 +67,10 @@
     protected HotSpotRuntime createRuntime() {
         return new SPARCHotSpotRuntime(config, this);
     }
+
+    @Override
+    protected Value[] getRuntimeCallVolatileRegisters() {
+        // TODO: is this correct?
+        return new Value[0];
+    }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkage.java	Tue Aug 06 23:36:36 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkage.java	Wed Aug 07 01:52:44 2013 +0200
@@ -124,7 +124,11 @@
                     boolean reexecutable, LocationIdentity... killedLocations) {
         CallingConvention outgoingCc = createCallingConvention(descriptor, outgoingCcType);
         CallingConvention incomingCc = incomingCcType == null ? null : createCallingConvention(descriptor, incomingCcType);
-        return new HotSpotForeignCallLinkage(descriptor, address, effect, transition, outgoingCc, incomingCc, reexecutable, killedLocations);
+        HotSpotForeignCallLinkage linkage = new HotSpotForeignCallLinkage(descriptor, address, effect, transition, outgoingCc, incomingCc, reexecutable, killedLocations);
+        if (outgoingCcType == Type.NativeCall) {
+            linkage.temporaries = graalRuntime().getRuntimeCallVolatileRegisters();
+        }
+        return linkage;
     }
 
     /**
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Tue Aug 06 23:36:36 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Wed Aug 07 01:52:44 2013 +0200
@@ -32,6 +32,7 @@
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.graph.*;
+import com.oracle.graal.hotspot.HotSpotForeignCallLinkage.RegisterEffect;
 import com.oracle.graal.hotspot.bridge.*;
 import com.oracle.graal.hotspot.logging.*;
 import com.oracle.graal.hotspot.meta.*;
@@ -253,6 +254,13 @@
 
     protected abstract HotSpotRuntime createRuntime();
 
+    /**
+     * Gets the registers that are treated volatile by foreign calls into the runtime. These
+     * registers must be spilled across all native foreign runtime calls, even for calls that are
+     * declared as {@link RegisterEffect#PRESERVES_REGISTERS register preserving}.
+     */
+    protected abstract Value[] getRuntimeCallVolatileRegisters();
+
     public HotSpotVMConfig getConfig() {
         return config;
     }