diff graal/GraalCompiler/src/com/sun/c1x/value/FrameState.java @ 2666:6ca76b891d31

duplicateModified helper method
author Lukas Stadler <lukas.stadler@jku.at>
date Thu, 12 May 2011 11:00:31 +0200
parents 8c02ca1e9eb1
children 32e8315bb6e4
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/value/FrameState.java	Thu May 12 10:26:55 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/value/FrameState.java	Thu May 12 11:00:31 2011 +0200
@@ -86,7 +86,7 @@
             inputs().set(i, locals[i]);
         }
         for (int i = 0; i < stackSize; i++) {
-            inputs().set(i + localsSize, stack[i]);
+            inputs().set(localsSize + i, stack[i]);
         }
         for (int i = 0; i < locks.size(); i++) {
             inputs().set(locals.length + stackSize + i, locks.get(i));
@@ -116,6 +116,37 @@
         return other;
     }
 
+    /**
+     * Creates a copy of this frame state with one stack element of type popKind popped from the stack and the
+     * values in pushedValues pushed on the stack.
+     */
+    public FrameState duplicateModified(int bci, CiKind popKind, Value... pushedValues) {
+        int popSlots = popKind.sizeInSlots();
+        int pushSlots = 0;
+        for (Value v : pushedValues) {
+            pushSlots += v.kind.sizeInSlots();
+        }
+        FrameState other = new FrameState(bci, localsSize, stackSize - popSlots + pushSlots, locksSize(), graph());
+        for (int i = 0; i < localsSize; i++) {
+            other.inputs().set(i, localAt(i));
+        }
+        for (int i = 0; i < stackSize - popSlots; i++) {
+            other.inputs().set(localsSize + i, stackAt(i));
+        }
+        int slot = stackSize - popSlots;
+        for (Value v : pushedValues) {
+            assert v.kind.sizeInSlots() > 0;
+            if (v.kind.sizeInSlots() == 2) {
+                other.inputs().set(localsSize + slot++, null);
+            }
+            other.inputs().set(localsSize + slot++, v);
+        }
+        for (int i = 0; i < locksSize; i++) {
+            other.inputs().set(localsSize + i, lockAt(i));
+        }
+        return other;
+    }
+
     public boolean isCompatibleWith(FrameStateAccess other) {
         if (stackSize() != other.stackSize() || localsSize() != other.localsSize() || locksSize() != other.locksSize()) {
             return false;