changeset 18427:9bf59aa9d8c6

Move allocateStackSlots logic from FrameMap to ForwardingFrameMapBuilder.
author Josef Eisl <josef.eisl@jku.at>
date Thu, 23 Oct 2014 18:07:31 +0200
parents b2b37b36a254
children 0826409daa24
files graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ForwardingFrameMapBuilder.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java
diffstat 2 files changed, 37 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ForwardingFrameMapBuilder.java	Thu Oct 23 17:48:46 2014 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ForwardingFrameMapBuilder.java	Thu Oct 23 18:07:31 2014 +0200
@@ -71,7 +71,37 @@
     }
 
     public StackSlot allocateStackSlots(int slots, BitSet objects, List<StackSlot> outObjectStackSlots) {
-        return frameMap.allocateStackSlots(slots, objects, outObjectStackSlots);
+        if (slots == 0) {
+            return null;
+        }
+        frameMap.spillSize += (slots * frameMap.getTarget().wordSize);
+
+        if (!objects.isEmpty()) {
+            assert objects.length() <= slots;
+            StackSlot result = null;
+            for (int slotIndex = 0; slotIndex < slots; slotIndex++) {
+                StackSlot objectSlot = null;
+                if (objects.get(slotIndex)) {
+                    objectSlot = frameMap.allocateNewSpillSlot(LIRKind.reference(Kind.Object), slotIndex * frameMap.getTarget().wordSize);
+                    frameMap.addObjectStackSlot(objectSlot);
+                    if (outObjectStackSlots != null) {
+                        outObjectStackSlots.add(objectSlot);
+                    }
+                }
+                if (slotIndex == 0) {
+                    if (objectSlot != null) {
+                        result = objectSlot;
+                    } else {
+                        result = frameMap.allocateNewSpillSlot(LIRKind.value(frameMap.getTarget().wordKind), 0);
+                    }
+                }
+            }
+            assert result != null;
+            return result;
+
+        } else {
+            return frameMap.allocateNewSpillSlot(LIRKind.value(frameMap.getTarget().wordKind), 0);
+        }
     }
 
     public RegisterConfig getRegisterConfig() {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java	Thu Oct 23 17:48:46 2014 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java	Thu Oct 23 18:07:31 2014 +0200
@@ -272,11 +272,9 @@
      *            for guaranteeing that each such object pointer slot is initialized before any
      *            instruction that uses a reference map. Without this guarantee, the garbage
      *            collector could see garbage object values.
-     * @param outObjectStackSlots if non-null, the object pointer slots allocated are added to this
-     *            list
      * @return the first reserved stack slot (i.e., at the lowest address)
      */
-    public StackSlot allocateStackSlots(int slots, BitSet objects, List<StackSlot> outObjectStackSlots) {
+    protected StackSlot allocateStackSlots(int slots, BitSet objects) {
         assert frameSize == -1 : "frame size must not yet be fixed";
         if (slots == 0) {
             return null;
@@ -290,10 +288,7 @@
                 StackSlot objectSlot = null;
                 if (objects.get(slotIndex)) {
                     objectSlot = allocateNewSpillSlot(LIRKind.reference(Kind.Object), slotIndex * getTarget().wordSize);
-                    objectStackSlots.add(objectSlot);
-                    if (outObjectStackSlots != null) {
-                        outObjectStackSlots.add(objectSlot);
-                    }
+                    addObjectStackSlot(objectSlot);
                 }
                 if (slotIndex == 0) {
                     if (objectSlot != null) {
@@ -311,6 +306,10 @@
         }
     }
 
+    protected void addObjectStackSlot(StackSlot objectSlot) {
+        objectStackSlots.add(objectSlot);
+    }
+
     public ReferenceMap initReferenceMap(boolean hasRegisters) {
         ReferenceMap refMap = getTarget().createReferenceMap(hasRegisters, frameSize() / getTarget().wordSize);
         for (StackSlot slot : objectStackSlots) {