# HG changeset patch # User Lukas Stadler # Date 1304603388 -7200 # Node ID 4a4dab936c1e9a82170243a1dbf89ecd6a57ffe1 # Parent 092e628ddd5db056eef43be7dabf9f7edc5ca0ff new node layout: AccessField diff -r 092e628ddd5d -r 4a4dab936c1e graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Thu May 05 15:43:23 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Thu May 05 15:49:48 2011 +0200 @@ -704,7 +704,7 @@ void genGetField(int cpi, RiField field) { // Must copy the state here, because the field holder must still be on the stack. FrameState stateBefore = curState.immutableCopy(bci()); - LoadField load = new LoadField(apop(), field, stateBefore); + LoadField load = new LoadField(apop(), field, stateBefore, graph); appendOptimizedLoadField(field.kind(), load); } @@ -712,7 +712,7 @@ // Must copy the state here, because the field holder must still be on the stack. FrameState stateBefore = curState.immutableCopy(bci()); Value value = pop(field.kind().stackKind()); - appendOptimizedStoreField(new StoreField(apop(), field, value, stateBefore)); + appendOptimizedStoreField(new StoreField(apop(), field, value, stateBefore, graph)); } void genGetStatic(int cpi, RiField field) { @@ -726,7 +726,7 @@ push(constantValue.kind.stackKind(), appendConstant(constantValue)); } else { Value container = genResolveClass(RiType.Representation.StaticFields, holder, field.isResolved(), cpi); - LoadField load = new LoadField(container, field, null); + LoadField load = new LoadField(container, field, null, graph); appendOptimizedLoadField(field.kind(), load); } } @@ -735,7 +735,7 @@ RiType holder = field.holder(); Value container = genResolveClass(RiType.Representation.StaticFields, holder, field.isResolved(), cpi); Value value = pop(field.kind().stackKind()); - StoreField store = new StoreField(container, field, value, null); + StoreField store = new StoreField(container, field, value, null, graph); appendOptimizedStoreField(store); } diff -r 092e628ddd5d -r 4a4dab936c1e graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java Thu May 05 15:43:23 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java Thu May 05 15:49:48 2011 +0200 @@ -24,6 +24,7 @@ import java.lang.reflect.*; +import com.oracle.graal.graph.*; import com.sun.c1x.value.*; import com.sun.cri.ci.*; import com.sun.cri.ri.*; @@ -33,7 +34,32 @@ */ public abstract class AccessField extends StateSplit { - private Value object; + private static final int INPUT_COUNT = 1; + private static final int INPUT_OBJECT = 0; + + private static final int SUCCESSOR_COUNT = 0; + + @Override + protected int inputCount() { + return super.inputCount() + INPUT_COUNT; + } + + @Override + protected int successorCount() { + return super.successorCount() + SUCCESSOR_COUNT; + } + + /** + * The instruction that produces the receiver object of this field access (for instance field accesses). + */ + public Value object() { + return (Value) inputs().get(super.inputCount() + INPUT_OBJECT); + } + + public Value setObject(Value n) { + return (Value) inputs().set(super.inputCount() + INPUT_OBJECT, n); + } + protected final RiField field; /** @@ -41,24 +67,16 @@ * @param kind the result kind of the access * @param object the instruction producing the receiver object * @param field the compiler interface representation of the field - * @param isStatic indicates if the field is static * @param stateBefore the state before the field access - * @param isLoaded indicates if the class is loaded + * @param inputCount + * @param successorCount + * @param graph */ - public AccessField(CiKind kind, Value object, RiField field, FrameState stateBefore) { - super(kind, stateBefore); - this.object = object; - this.field = field; + public AccessField(CiKind kind, Value object, RiField field, FrameState stateBefore, int inputCount, int successorCount, Graph graph) { + super(kind, stateBefore, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph); assert object != null : "every field access must reference some object"; - } - - /** - * Gets the instruction that produces the receiver object of this field access - * (for instance field accesses). - * @return the instruction that produces the receiver object - */ - public Value object() { - return object; + this.field = field; + setObject(object); } /** @@ -92,9 +110,4 @@ public boolean isVolatile() { return isLoaded() && Modifier.isVolatile(field.accessFlags()); } - - @Override - public void inputValuesDo(ValueClosure closure) { - object = closure.apply(object); - } } diff -r 092e628ddd5d -r 4a4dab936c1e graal/GraalCompiler/src/com/sun/c1x/ir/LoadField.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/LoadField.java Thu May 05 15:43:23 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/LoadField.java Thu May 05 15:49:48 2011 +0200 @@ -22,6 +22,7 @@ */ package com.sun.c1x.ir; +import com.oracle.graal.graph.*; import com.sun.c1x.debug.*; import com.sun.c1x.value.*; import com.sun.cri.ci.*; @@ -32,16 +33,20 @@ */ public final class LoadField extends AccessField { + private static final int INPUT_COUNT = 0; + private static final int SUCCESSOR_COUNT = 0; + /** * Creates a new LoadField instance. * @param object the receiver object * @param field the compiler interface field * @param isStatic indicates if the field is static * @param stateBefore the state before the field access + * @param graph * @param isLoaded indicates if the class is loaded */ - public LoadField(Value object, RiField field, FrameState stateBefore) { - super(field.kind().stackKind(), object, field, stateBefore); + public LoadField(Value object, RiField field, FrameState stateBefore, Graph graph) { + super(field.kind().stackKind(), object, field, stateBefore, INPUT_COUNT, SUCCESSOR_COUNT, graph); } /** diff -r 092e628ddd5d -r 4a4dab936c1e graal/GraalCompiler/src/com/sun/c1x/ir/StoreField.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/StoreField.java Thu May 05 15:43:23 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/StoreField.java Thu May 05 15:49:48 2011 +0200 @@ -22,6 +22,7 @@ */ package com.sun.c1x.ir; +import com.oracle.graal.graph.*; import com.sun.c1x.debug.*; import com.sun.c1x.value.*; import com.sun.cri.ci.*; @@ -32,37 +33,43 @@ */ public final class StoreField extends AccessField { + private static final int INPUT_COUNT = 1; + private static final int INPUT_VALUE = 0; + + private static final int SUCCESSOR_COUNT = 0; + + @Override + protected int inputCount() { + return super.inputCount() + INPUT_COUNT; + } + + @Override + protected int successorCount() { + return super.successorCount() + SUCCESSOR_COUNT; + } + /** - * The value to store. + * The value that is written to the field. */ - Value value; + public Value value() { + return (Value) inputs().get(super.inputCount() + INPUT_VALUE); + } + + public Value setValue(Value n) { + return (Value) inputs().set(super.inputCount() + INPUT_VALUE, n); + } /** * Creates a new LoadField instance. * @param object the receiver object * @param field the compiler interface field * @param value the instruction representing the value to store to the field - * @param isStatic indicates if the field is static * @param stateBefore the state before the field access - * @param isLoaded indicates if the class is loaded + * @param graph */ - public StoreField(Value object, RiField field, Value value, FrameState stateBefore) { - super(CiKind.Void, object, field, stateBefore); - this.value = value; - } - - /** - * Gets the value that is written to the field. - * @return the value - */ - public Value value() { - return value; - } - - @Override - public void inputValuesDo(ValueClosure closure) { - super.inputValuesDo(closure); - value = closure.apply(value); + public StoreField(Value object, RiField field, Value value, FrameState stateBefore, Graph graph) { + super(CiKind.Void, object, field, stateBefore, INPUT_COUNT, SUCCESSOR_COUNT, graph); + setValue(value); } @Override