# HG changeset patch # User Thomas Wuerthinger # Date 1306223344 -7200 # Node ID 056e392d63d46d1ccd4bccf65cfcfe5a4034823c # Parent 4f3053eef0debf17bbb4a50727b45d4af58b5c4e Connected local variables to start node. No more need for frame state to emit locals. diff -r 4f3053eef0de -r 056e392d63d4 graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java --- 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(); } } diff -r 4f3053eef0de -r 056e392d63d4 graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java --- 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(); diff -r 4f3053eef0de -r 056e392d63d4 graal/GraalCompiler/src/com/sun/c1x/ir/Local.java --- 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(']'); } } diff -r 4f3053eef0de -r 056e392d63d4 graal/GraalCompiler/src/com/sun/c1x/value/FrameStateBuilder.java --- 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(); }