# HG changeset patch # User Stefan Anzinger # Date 1405996636 25200 # Node ID eda09bc52ab9071f8c017a9739a675bee909c003 # Parent cb416c08fe64db1f2d78387163aafdf39ea4f3d2 [SPARC] Fix handling of overflow parameter on stack. diff -r cb416c08fe64 -r eda09bc52ab9 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotPatchReturnAddressOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotPatchReturnAddressOp.java Mon Jul 21 11:16:25 2014 -0700 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotPatchReturnAddressOp.java Mon Jul 21 19:37:16 2014 -0700 @@ -29,7 +29,6 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.sparc.*; -import com.oracle.graal.asm.sparc.SPARCMacroAssembler.*; import com.oracle.graal.asm.sparc.SPARCAssembler.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.asm.*; diff -r cb416c08fe64 -r eda09bc52ab9 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java Mon Jul 21 11:16:25 2014 -0700 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java Mon Jul 21 19:37:16 2014 -0700 @@ -95,11 +95,6 @@ private final CalleeSaveLayout csl; - /** - * Offset where the extended arguments resides in the stack. - */ - private final int extendedArgumentOffset = 16 * 8; - private static Register findRegister(String name, Register[] all) { for (Register reg : all) { if (reg.name.equals(name)) { @@ -200,7 +195,7 @@ int currentGeneral = 0; int currentFloating = 0; - int currentStackOffset = extendedArgumentOffset; + int currentStackOffset = 0; for (int i = 0; i < parameterTypes.length; i++) { final Kind kind = parameterTypes[i].getKind(); @@ -240,8 +235,14 @@ } if (locations[i] == null) { + // Stack slot is always aligned to its size in bytes + int typeSize = target.getSizeInBytes(kind); + int modulus = currentStackOffset % typeSize; + if (modulus != 0) { + currentStackOffset += typeSize - modulus; + } locations[i] = StackSlot.get(target.getLIRKind(kind.getStackKind()), currentStackOffset, !type.out); - currentStackOffset += Math.max(target.getSizeInBytes(kind), target.wordSize); + currentStackOffset += typeSize; } } diff -r cb416c08fe64 -r eda09bc52ab9 graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java Mon Jul 21 11:16:25 2014 -0700 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java Mon Jul 21 19:37:16 2014 -0700 @@ -34,11 +34,15 @@ * *
  *   Base       Contents
- *
+ * 
  *            :                                :  -----
  *   caller   | incoming overflow argument n   |    ^
  *   frame    :     ...                        :    | positive
  *            | incoming overflow argument 0   |    | offsets
+ *            +--------------------------------+    |
+ *            |                                |    |
+ *            : register save area             :    |
+ *            |                                |    |
  *   ---------+--------------------------------+---------------------------
  *            | spill slot 0                   |    | negative   ^      ^
  *            :     ...                        :    v offsets    |      |
@@ -101,4 +105,16 @@
     protected StackSlot allocateNewSpillSlot(LIRKind kind, int additionalOffset) {
         return StackSlot.get(kind, -spillSize + additionalOffset, true);
     }
+
+    /**
+     * We must add the calleSaveAreaSize() when it is a in or out parameter
+     */
+    @Override
+    public int offsetForStackSlot(StackSlot slot) {
+        int offset = super.offsetForStackSlot(slot);
+        if (slot.getRawOffset() >= 0) { // If In or Out parameter
+            offset += calleeSaveAreaSize();
+        }
+        return offset;
+    }
 }
diff -r cb416c08fe64 -r eda09bc52ab9 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java	Mon Jul 21 11:16:25 2014 -0700
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java	Mon Jul 21 19:37:16 2014 -0700
@@ -201,8 +201,11 @@
      * @return the offset of the stack slot
      */
     public int offsetForStackSlot(StackSlot slot) {
-        assert (!slot.getRawAddFrameSize() && slot.getRawOffset() < outgoingSize) || (slot.getRawAddFrameSize() && slot.getRawOffset() < 0 && -slot.getRawOffset() <= spillSize) ||
-                        (slot.getRawAddFrameSize() && slot.getRawOffset() >= 0);
+        // @formatter:off
+        assert (!slot.getRawAddFrameSize() && slot.getRawOffset() <  outgoingSize) ||
+               ( slot.getRawAddFrameSize() && slot.getRawOffset() <  0 && -slot.getRawOffset() <= spillSize) ||
+               ( slot.getRawAddFrameSize() && slot.getRawOffset() >= 0);
+        // @formatter:on
         if (slot.isInCallerFrame()) {
             accessesCallerFrame = true;
         }