changeset 18434:06624c98ed8b

Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
author Josef Eisl <josef.eisl@jku.at>
date Mon, 10 Nov 2014 19:43:16 +0100
parents a0cd3a1e7d7d
children a84639853ea6
files graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMapBuilder.java
diffstat 3 files changed, 38 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Mon Nov 10 18:40:52 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Mon Nov 10 19:43:16 2014 +0100
@@ -88,7 +88,7 @@
         /**
          * The slot reserved for saving RBP.
          */
-        final VirtualStackSlot reservedSlot;
+        final StackSlot reservedSlot;
 
         public SaveRbp(NoOp placeholder) {
             this.placeholder = placeholder;
@@ -106,7 +106,7 @@
             if (useStack) {
                 dst = reservedSlot;
             } else {
-                getResult().getFrameMapBuilder().freeSpillSlot(reservedSlot);
+                ((AMD64FrameMapBuilder) getResult().getFrameMapBuilder()).freeRBPSpillSlot();
                 dst = newVariable(LIRKind.value(Kind.Long));
             }
 
@@ -417,7 +417,7 @@
         boolean hasDebugInfo = getResult().getLIR().hasDebugInfo();
         AllocatableValue savedRbp = saveRbp.finalize(hasDebugInfo);
         if (hasDebugInfo) {
-            ((AMD64HotSpotLIRGenerationResult) getResult()).setDeoptimizationRescueSlot(getResult().getFrameMapBuilder().allocateSpillSlot(LIRKind.value(Kind.Long)));
+            ((AMD64HotSpotLIRGenerationResult) getResult()).setDeoptimizationRescueSlot(((AMD64FrameMapBuilder) getResult().getFrameMapBuilder()).allocateDeoptimizationRescueSlot());
         }
 
         for (AMD64HotSpotEpilogueOp op : epilogueOps) {
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java	Mon Nov 10 18:40:52 2014 +0100
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java	Mon Nov 10 19:43:16 2014 +0100
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.lir.amd64;
 
+import static com.oracle.graal.api.code.ValueUtil.*;
+
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.*;
@@ -70,6 +72,8 @@
  */
 public class AMD64FrameMap extends FrameMap {
 
+    private StackSlot rbpSpillSlot;
+
     public AMD64FrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig) {
         super(codeCache, registerConfig);
         // (negative) offset relative to sp + total frame size
@@ -101,4 +105,29 @@
     protected StackSlot allocateNewSpillSlot(LIRKind kind, int additionalOffset) {
         return StackSlot.get(kind, -spillSize + additionalOffset, true);
     }
+
+    /**
+     * For non-leaf methods, RBP is preserved in the special stack slot required by the HotSpot
+     * runtime for walking/inspecting frames of such methods.
+     */
+    StackSlot allocateRBPSpillSlot() {
+        assert spillSize == initialSpillSize : "RBP spill slot can only be allocated before getting other stack slots";
+        int size = spillSlotSize(LIRKind.value(Kind.Long));
+        spillSize = NumUtil.roundUp(spillSize + size, size);
+        rbpSpillSlot = allocateNewSpillSlot(LIRKind.value(Kind.Long), 0);
+        assert asStackSlot(rbpSpillSlot).getRawOffset() == -16 : asStackSlot(rbpSpillSlot).getRawOffset();
+        return rbpSpillSlot;
+    }
+
+    void freeRBPSpillSlot() {
+        int size = spillSlotSize(LIRKind.value(Kind.Long));
+        assert spillSize == NumUtil.roundUp(initialSpillSize + size, size) : "RBP spill slot can not be freed after allocation other stack slots";
+        spillSize = initialSpillSize;
+    }
+
+    public StackSlot allocateDeoptimizationRescueSlot() {
+        int size = spillSlotSize(LIRKind.value(Kind.Long));
+        spillSize = NumUtil.roundUp(spillSize + size, size);
+        return allocateNewSpillSlot(LIRKind.value(Kind.Long), 0);
+    }
 }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMapBuilder.java	Mon Nov 10 18:40:52 2014 +0100
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMapBuilder.java	Mon Nov 10 19:43:16 2014 +0100
@@ -22,18 +22,11 @@
  */
 package com.oracle.graal.lir.amd64;
 
-import static com.oracle.graal.api.code.ValueUtil.*;
-
-import java.util.*;
-
 import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
 import com.oracle.graal.lir.*;
 
 public class AMD64FrameMapBuilder extends DelayedFrameMapBuilder {
 
-    private TrackedVirtualStackSlot rbpSpillSlot;
-
     public AMD64FrameMapBuilder(FrameMapFactory factory, CodeCacheProvider codeCache, RegisterConfig registerConfig) {
         super(factory, codeCache, registerConfig);
     }
@@ -42,28 +35,15 @@
      * For non-leaf methods, RBP is preserved in the special stack slot required by the HotSpot
      * runtime for walking/inspecting frames of such methods.
      */
-    public VirtualStackSlot allocateRBPSpillSlot() {
-        rbpSpillSlot = (TrackedVirtualStackSlot) allocateSpillSlot(LIRKind.value(Kind.Long));
-        return rbpSpillSlot;
+    public StackSlot allocateRBPSpillSlot() {
+        return ((AMD64FrameMap) frameMap).allocateRBPSpillSlot();
     }
 
-    @Override
-    public void freeSpillSlot(VirtualStackSlot slot) {
-        assert slot != null;
-        if (slot.equals(rbpSpillSlot)) {
-            rbpSpillSlot = null;
-        } else {
-            super.freeSpillSlot(slot);
-        }
+    public void freeRBPSpillSlot() {
+        ((AMD64FrameMap) frameMap).freeRBPSpillSlot();
     }
 
-    @Override
-    protected void mapStackSlots(HashMap<VirtualStackSlot, StackSlot> mapping) {
-        if (rbpSpillSlot != null) {
-            StackSlot reservedSlot = rbpSpillSlot.transform();
-            assert asStackSlot(reservedSlot).getRawOffset() == -16 : asStackSlot(reservedSlot).getRawOffset();
-            mapping.put(rbpSpillSlot, reservedSlot);
-        }
-        super.mapStackSlots(mapping);
+    public StackSlot allocateDeoptimizationRescueSlot() {
+        return ((AMD64FrameMap) frameMap).allocateDeoptimizationRescueSlot();
     }
 }