changeset 2771:056e392d63d4

Connected local variables to start node. No more need for frame state to emit locals.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Tue, 24 May 2011 09:49:04 +0200
parents 4f3053eef0de
children 3e3338a1abb9
files graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java graal/GraalCompiler/src/com/sun/c1x/ir/Local.java graal/GraalCompiler/src/com/sun/c1x/value/FrameStateBuilder.java
diffstat 4 files changed, 29 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java	Mon May 23 21:22:06 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java	Tue May 24 09:49:04 2011 +0200
@@ -273,23 +273,22 @@
         return x.operand();
     }
 
-    private void setOperandsForLocals(FrameState state) {
+    private void setOperandsForLocals() {
         CiCallingConvention args = compilation.frameMap().incomingArguments();
-        int javaIndex = 0;
-        for (int i = 0; i < args.locations.length; i++) {
-            CiValue src = args.locations[i];
-            assert src.isLegal() : "check";
+        for (Node node : compilation.graph.start().usages()) {
+            if (node instanceof Local) {
+                Local local = (Local) node;
+                int i = local.index();
 
-            CiVariable dest = newVariable(src.kind.stackKind());
-            lir.move(src, dest, src.kind);
+                CiValue src = args.locations[i];
+                assert src.isLegal() : "check";
 
-            // Assign new location to Local instruction for this local
-            Value instr = state.localAt(javaIndex);
-            Local local = ((Local) instr);
-            CiKind kind = src.kind.stackKind();
-            assert kind == local.kind.stackKind() : "local type check failed";
-            setResult(local, dest);
-            javaIndex += kind.jvmSlots;
+                CiVariable dest = newVariable(src.kind.stackKind());
+                lir.move(src, dest, src.kind);
+
+                assert src.kind.stackKind() == local.kind.stackKind() : "local type check failed";
+                setResult(local, dest);
+            }
         }
     }
 
@@ -894,7 +893,7 @@
             if (prologue != null) {
                 emitXir(prologue, null, null, null, false);
             }
-            setOperandsForLocals(ir.getHIRStartBlock().end().stateAfter());
+            setOperandsForLocals();
         }
     }
 
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Mon May 23 21:22:06 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Tue May 24 09:49:04 2011 +0200
@@ -962,7 +962,7 @@
         if (exactType == null && declaredType != null) {
             exactType = declaredType.exactType();
         }
-        if (exactType == null && receiver instanceof Local && ((Local) receiver).javaIndex() == 0) {
+        if (exactType == null && receiver instanceof Local && ((Local) receiver).index() == 0) {
             // the exact type isn't known, but the receiver is parameter 0 => use holder
             receiverType = compilation.method.holder();
             exactType = receiverType.exactType();
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Local.java	Mon May 23 21:22:06 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Local.java	Tue May 24 09:49:04 2011 +0200
@@ -33,15 +33,16 @@
  */
 public final class Local extends Value {
 
-    private static final int INPUT_COUNT = 0;
+    private static final int INPUT_COUNT = 1;
     private static final int SUCCESSOR_COUNT = 0;
 
-    private final int javaIndex;
+    private final int index;
     private RiType declaredType;
 
     public Local(CiKind kind, int javaIndex, Graph graph) {
         super(kind, INPUT_COUNT, SUCCESSOR_COUNT, graph);
-        this.javaIndex = javaIndex;
+        this.index = javaIndex;
+        this.inputs().set(0, graph.start());
     }
 
     @Override
@@ -53,8 +54,8 @@
      * Gets the index of this local.
      * @return the index
      */
-    public int javaIndex() {
-        return javaIndex;
+    public int index() {
+        return index;
     }
 
     /**
@@ -81,6 +82,6 @@
 
     @Override
     public void print(LogStream out) {
-        out.print("local[index ").print(javaIndex()).print(']');
+        out.print("local[index ").print(index()).print(']');
     }
 }
--- a/graal/GraalCompiler/src/com/sun/c1x/value/FrameStateBuilder.java	Mon May 23 21:22:06 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/value/FrameStateBuilder.java	Tue May 24 09:49:04 2011 +0200
@@ -49,13 +49,15 @@
         this.locals = new Value[method.maxLocals()];
         this.stack = new Value[method.maxStackSize()];
 
+        int javaIndex = 0;
         int index = 0;
         if (!isStatic(method.accessFlags())) {
             // add the receiver and assume it is non null
-            Local local = new Local(method.holder().kind(), index, graph);
+            Local local = new Local(method.holder().kind(), javaIndex, graph);
             local.setFlag(Value.Flag.NonNull, true);
             local.setDeclaredType(method.holder());
-            storeLocal(index, local);
+            storeLocal(javaIndex, local);
+            javaIndex = 1;
             index = 1;
         }
         RiSignature sig = method.signature();
@@ -68,8 +70,9 @@
             if (type.isResolved()) {
                 local.setDeclaredType(type);
             }
-            storeLocal(index, local);
-            index += kind.sizeInSlots();
+            storeLocal(javaIndex, local);
+            javaIndex += kind.sizeInSlots();
+            index++;
         }
         this.locks = new ArrayList<Value>();
     }