# HG changeset patch # User Doug Simon # Date 1375833164 -7200 # Node ID 6c098f64a7a6a007524b8eba1dce2017907bf7a5 # Parent a7c7b0bd055762daed3ddb870c4c4ddf7631d60c added support for handling volatile registers across native runtime calls diff -r a7c7b0bd0557 -r 6c098f64a7a6 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotGraalRuntime.java --- 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()}; + } } diff -r a7c7b0bd0557 -r 6c098f64a7a6 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotGraalRuntime.java --- 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]; + } } diff -r a7c7b0bd0557 -r 6c098f64a7a6 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkage.java --- 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; } /** diff -r a7c7b0bd0557 -r 6c098f64a7a6 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java --- 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; }