changeset 10958:e2c63a0b799c

moved move logic into architecture specific FrameMap
author twisti
date Sun, 04 Aug 2013 11:16:01 -0700
parents c6e004578eb4
children 109747b3b337
files graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TargetDescription.java graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILFrameMap.java graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXFrameMap.java graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java
diffstat 6 files changed, 100 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TargetDescription.java	Thu Aug 01 15:23:05 2013 -0700
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TargetDescription.java	Sun Aug 04 11:16:01 2013 -0700
@@ -81,16 +81,4 @@
         this.implicitNullCheckLimit = implicitNullCheckLimit;
         this.inlineObjects = inlineObjects;
     }
-
-    /**
-     * Aligns the given frame size (without return instruction pointer) to the stack alignment size
-     * and return the aligned size (without return instruction pointer).
-     * 
-     * @param frameSize the initial frame size to be aligned
-     * @return the aligned frame size
-     */
-    public int alignFrameSize(int frameSize) {
-        int x = frameSize + arch.getReturnAddressSize() + (stackAlignment - 1);
-        return (x / stackAlignment) * stackAlignment - arch.getReturnAddressSize();
-    }
 }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java	Thu Aug 01 15:23:05 2013 -0700
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java	Sun Aug 04 11:16:01 2013 -0700
@@ -71,6 +71,25 @@
 
     public AMD64FrameMap(CodeCacheProvider runtime, TargetDescription target, RegisterConfig registerConfig) {
         super(runtime, target, registerConfig);
+        // (negative) offset relative to sp + total frame size
+        initialSpillSize = returnAddressSize() + calleeSaveAreaSize();
+        spillSize = initialSpillSize;
+    }
+
+    @Override
+    public int totalFrameSize() {
+        return frameSize() + returnAddressSize();
+    }
+
+    @Override
+    public int currentFrameSize() {
+        return alignFrameSize(outgoingSize + spillSize - returnAddressSize());
+    }
+
+    @Override
+    protected int alignFrameSize(int size) {
+        int x = size + returnAddressSize() + (target.stackAlignment - 1);
+        return (x / target.stackAlignment) * target.stackAlignment - returnAddressSize();
     }
 
     @Override
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILFrameMap.java	Thu Aug 01 15:23:05 2013 -0700
+++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILFrameMap.java	Sun Aug 04 11:16:01 2013 -0700
@@ -24,6 +24,7 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.*;
 
 /**
@@ -42,6 +43,21 @@
     }
 
     @Override
+    public int totalFrameSize() {
+        throw GraalInternalError.unimplemented();
+    }
+
+    @Override
+    public int currentFrameSize() {
+        throw GraalInternalError.unimplemented();
+    }
+
+    @Override
+    protected int alignFrameSize(int size) {
+        throw GraalInternalError.unimplemented();
+    }
+
+    @Override
     public int offsetToCalleeSaveArea() {
         return frameSize() - calleeSaveAreaSize();
     }
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXFrameMap.java	Thu Aug 01 15:23:05 2013 -0700
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXFrameMap.java	Sun Aug 04 11:16:01 2013 -0700
@@ -24,6 +24,7 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.*;
 
 /**
@@ -42,6 +43,21 @@
     }
 
     @Override
+    public int totalFrameSize() {
+        throw GraalInternalError.unimplemented();
+    }
+
+    @Override
+    public int currentFrameSize() {
+        throw GraalInternalError.unimplemented();
+    }
+
+    @Override
+    protected int alignFrameSize(int size) {
+        throw GraalInternalError.unimplemented();
+    }
+
+    @Override
     public int offsetToCalleeSaveArea() {
         return frameSize() - calleeSaveAreaSize();
     }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java	Thu Aug 01 15:23:05 2013 -0700
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java	Sun Aug 04 11:16:01 2013 -0700
@@ -38,22 +38,22 @@
  *   caller   | incoming overflow argument n   |    ^
  *   frame    :     ...                        :    | positive
  *            | incoming overflow argument 0   |    | offsets
- *   ---------+--------------------------------+---------------------
- *            | spill slot 0                   |    | negative   ^      |
+ *   ---------+--------------------------------+---------------------------
+ *            | spill slot 0                   |    | negative   ^      ^
  *            :     ...                        :    v offsets    |      |
- *            | spill slot n                   |  -----        total  frame
- *            +--------------------------------+               frame  size
+ *            | spill slot n                   |  -----        total    |
+ *            +--------------------------------+               frame    |
  *   current  | alignment padding              |               size     |
  *   frame    +--------------------------------+  -----          |      |
- *            | outgoing overflow argument n   |    ^            |      |
- *            :     ...                        :    | positive   |      |
- *            | outgoing overflow argument 0   |    | offsets    |      v
- *            +--------------------------------+    |            |
- *            | return address                 |    |            |
- *            +--------------------------------+    |            |    -----
- *            |                                |    |            |      ^
+ *            | outgoing overflow argument n   |    ^            |    frame
+ *            :     ...                        :    | positive   |    size
+ *            | outgoing overflow argument 0   |    | offsets    |      |
+ *            +--------------------------------+    |            |      |
+ *            | return address                 |    |            |      |
+ *            +--------------------------------+    |            |      |
+ *            |                                |    |            |      |
  *            : callee save area               :    |            |      |
- *            |                                |    |            v      |
+ *            |                                |    |            v      v
  *    %sp-->  +--------------------------------+---------------------------
  * 
  * </pre>
@@ -71,6 +71,25 @@
 
     public SPARCFrameMap(CodeCacheProvider runtime, TargetDescription target, RegisterConfig registerConfig) {
         super(runtime, target, registerConfig);
+        // offset relative to sp + total frame size
+        initialSpillSize = 0;
+        spillSize = initialSpillSize;
+    }
+
+    @Override
+    public int totalFrameSize() {
+        return frameSize();
+    }
+
+    @Override
+    public int currentFrameSize() {
+        return alignFrameSize(calleeSaveAreaSize() + returnAddressSize() + outgoingSize + spillSize);
+    }
+
+    @Override
+    protected int alignFrameSize(int size) {
+        int x = size + (target.stackAlignment - 1);
+        return (x / target.stackAlignment) * target.stackAlignment;
     }
 
     @Override
@@ -80,6 +99,6 @@
 
     @Override
     protected StackSlot allocateNewSpillSlot(PlatformKind kind, int additionalOffset) {
-        return StackSlot.get(kind, spillSize + additionalOffset, false);
+        return StackSlot.get(kind, -spillSize + additionalOffset, true);
     }
 }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java	Thu Aug 01 15:23:05 2013 -0700
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java	Sun Aug 04 11:16:01 2013 -0700
@@ -52,6 +52,11 @@
     private int frameSize;
 
     /**
+     * Initial size of the area occupied by spill slots and other stack-allocated memory blocks.
+     */
+    protected int initialSpillSize;
+
+    /**
      * Size of the area occupied by spill slots and other stack-allocated memory blocks.
      */
     protected int spillSize;
@@ -61,7 +66,7 @@
      * conventions for outgoing calls are retrieved. On some platforms, there is a minimum outgoing
      * size even if no overflow arguments are on the stack.
      */
-    private int outgoingSize;
+    protected int outgoingSize;
 
     /**
      * Determines if this frame has values on the stack for outgoing calls.
@@ -87,12 +92,11 @@
         this.target = target;
         this.registerConfig = registerConfig;
         this.frameSize = -1;
-        this.spillSize = returnAddressSize() + calleeSaveAreaSize();
         this.outgoingSize = runtime.getMinimumOutgoingSize();
         this.objectStackBlocks = new ArrayList<>();
     }
 
-    private int returnAddressSize() {
+    protected int returnAddressSize() {
         return target.arch.getReturnAddressSize();
     }
 
@@ -135,17 +139,21 @@
      * 
      * @return The total size of the frame (in bytes).
      */
-    public int totalFrameSize() {
-        return frameSize() + returnAddressSize();
-    }
+    public abstract int totalFrameSize();
 
     /**
      * Gets the current size of this frame. This is the size that would be returned by
      * {@link #frameSize()} if {@link #finish()} were called now.
      */
-    public int currentFrameSize() {
-        return target.alignFrameSize(outgoingSize + spillSize - returnAddressSize());
-    }
+    public abstract int currentFrameSize();
+
+    /**
+     * Aligns the given frame size to the stack alignment size and return the aligned size.
+     * 
+     * @param size the initial frame size to be aligned
+     * @return the aligned frame size
+     */
+    protected abstract int alignFrameSize(int size);
 
     /**
      * Computes the final size of this frame. After this method has been called, methods that change
@@ -162,7 +170,6 @@
             for (StackSlot s : freedSlots) {
                 total += target.arch.getSizeInBytes(s.getKind());
             }
-            int initialSpillSize = returnAddressSize() + calleeSaveAreaSize();
             if (total == spillSize - initialSpillSize) {
                 // reset spill area size
                 spillSize = initialSpillSize;