# HG changeset patch # User Thomas Wuerthinger # Date 1309357191 -7200 # Node ID f02897fb8c9e0e02702406e1668b3dbf152771e2 # Parent b6282786e163ec4f8af9c7c6aa13848f31b7f6c6 Removed explicit reference to RiType object in TypeCheck node. diff -r b6282786e163 -r f02897fb8c9e graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/CheckCast.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/CheckCast.java Wed Jun 29 15:45:20 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/CheckCast.java Wed Jun 29 16:19:51 2011 +0200 @@ -43,8 +43,8 @@ * @param object the instruction producing the object * @param graph */ - public CheckCast(RiType targetClass, Value targetClassInstruction, Value object, Graph graph) { - super(targetClass, targetClassInstruction, object, CiKind.Object, INPUT_COUNT, SUCCESSOR_COUNT, graph); + public CheckCast(Constant targetClassInstruction, Value object, Graph graph) { + super(targetClassInstruction, object, CiKind.Object, INPUT_COUNT, SUCCESSOR_COUNT, graph); } /** @@ -53,7 +53,7 @@ */ @Override public RiType declaredType() { - return targetClass; + return targetClass(); } /** @@ -62,7 +62,7 @@ */ @Override public RiType exactType() { - return targetClass.isResolved() ? targetClass.exactType() : null; + return targetClass().isResolved() ? targetClass().exactType() : null; } @Override @@ -72,16 +72,12 @@ @Override public int valueNumber() { - return targetClass.isResolved() ? Util.hash1(Bytecodes.CHECKCAST, object()) : 0; + return targetClass().isResolved() ? Util.hash1(Bytecodes.CHECKCAST, object()) : 0; } @Override public boolean valueEqual(Node i) { - if (i instanceof CheckCast) { - CheckCast o = (CheckCast) i; - return targetClass == o.targetClass && object() == o.object(); - } - return false; + return i instanceof CheckCast; } @Override @@ -96,7 +92,7 @@ @Override public Node copy(Graph into) { - CheckCast x = new CheckCast(targetClass, null, null, into); + CheckCast x = new CheckCast(null, null, into); return x; } } diff -r b6282786e163 -r f02897fb8c9e graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/GuardNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/GuardNode.java Wed Jun 29 15:45:20 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/GuardNode.java Wed Jun 29 16:19:51 2011 +0200 @@ -24,7 +24,6 @@ import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.debug.*; -import com.oracle.max.graal.compiler.ir.Deoptimize.*; import com.oracle.max.graal.compiler.phases.CanonicalizerPhase.*; import com.oracle.max.graal.graph.*; import com.sun.cri.ci.*; diff -r b6282786e163 -r f02897fb8c9e graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/InstanceOf.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/InstanceOf.java Wed Jun 29 15:45:20 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/InstanceOf.java Wed Jun 29 16:19:51 2011 +0200 @@ -27,7 +27,6 @@ import com.oracle.max.graal.graph.*; import com.sun.cri.bytecode.*; import com.sun.cri.ci.*; -import com.sun.cri.ri.*; /** * The {@code InstanceOf} instruction represents an instanceof test. @@ -43,8 +42,8 @@ * @param object the instruction producing the object input to this instruction * @param graph */ - public InstanceOf(RiType targetClass, Value targetClassInstruction, Value object, Graph graph) { - super(targetClass, targetClassInstruction, object, CiKind.Int, INPUT_COUNT, SUCCESSOR_COUNT, graph); + public InstanceOf(Constant targetClassInstruction, Value object, Graph graph) { + super(targetClassInstruction, object, CiKind.Int, INPUT_COUNT, SUCCESSOR_COUNT, graph); } @Override @@ -59,11 +58,7 @@ @Override public boolean valueEqual(Node i) { - if (i instanceof InstanceOf) { - InstanceOf o = (InstanceOf) i; - return targetClass == o.targetClass && object() == o.object(); - } - return false; + return i instanceof InstanceOf; } @Override @@ -73,7 +68,6 @@ @Override public Node copy(Graph into) { - InstanceOf x = new InstanceOf(targetClass, null, null, into); - return x; + return new InstanceOf(null, null, into); } } diff -r b6282786e163 -r f02897fb8c9e graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/TypeCheck.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/TypeCheck.java Wed Jun 29 15:45:20 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/TypeCheck.java Wed Jun 29 16:19:51 2011 +0200 @@ -61,16 +61,23 @@ /** * The instruction that loads the target class object that is used by this checkcast. */ - public Value targetClassInstruction() { - return (Value) inputs().get(super.inputCount() + INPUT_TARGET_CLASS_INSTRUCTION); + public Constant targetClassInstruction() { + return (Constant) inputs().get(super.inputCount() + INPUT_TARGET_CLASS_INSTRUCTION); + } + + private void setTargetClassInstruction(Constant n) { + inputs().set(super.inputCount() + INPUT_TARGET_CLASS_INSTRUCTION, n); } - public Value setTargetClassInstruction(Value n) { - return (Value) inputs().set(super.inputCount() + INPUT_TARGET_CLASS_INSTRUCTION, n); + + /** + * Gets the target class, i.e. the class being cast to, or the class being tested against. + * @return the target class + */ + public RiType targetClass() { + return (RiType) targetClassInstruction().asConstant().asObject(); } - final RiType targetClass; - /** * Creates a new TypeCheck instruction. * @param targetClass the class which is being casted to or checked against @@ -80,27 +87,9 @@ * @param successorCount * @param graph */ - public TypeCheck(RiType targetClass, Value targetClassInstruction, Value object, CiKind kind, int inputCount, int successorCount, Graph graph) { + public TypeCheck(Constant targetClassInstruction, Value object, CiKind kind, int inputCount, int successorCount, Graph graph) { super(kind, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph); - this.targetClass = targetClass; setObject(object); setTargetClassInstruction(targetClassInstruction); } - - /** - * Gets the target class, i.e. the class being cast to, or the class being tested against. - * @return the target class - */ - public RiType targetClass() { - return targetClass; - } - - /** - * Checks whether the target class of this instruction is loaded. - * @return {@code true} if the target class is loaded - */ - public boolean isLoaded() { - return targetClass != null; - } - } diff -r b6282786e163 -r f02897fb8c9e graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java Wed Jun 29 15:45:20 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java Wed Jun 29 16:19:51 2011 +0200 @@ -738,10 +738,10 @@ int cpi = stream().readCPI(); RiType type = constantPool.lookupType(cpi, CHECKCAST); boolean isInitialized = type.isResolved(); - Value typeInstruction = genTypeOrDeopt(RiType.Representation.ObjectHub, type, isInitialized, cpi); + Constant typeInstruction = genTypeOrDeopt(RiType.Representation.ObjectHub, type, isInitialized, cpi); Value object = frameState.apop(); if (typeInstruction != null) { - frameState.apush(append(new CheckCast(type, typeInstruction, object, graph))); + frameState.apush(append(new CheckCast(typeInstruction, object, graph))); } else { frameState.apush(appendConstant(CiConstant.NULL_OBJECT)); } @@ -751,10 +751,10 @@ int cpi = stream().readCPI(); RiType type = constantPool.lookupType(cpi, INSTANCEOF); boolean isInitialized = type.isResolved(); - Value typeInstruction = genTypeOrDeopt(RiType.Representation.ObjectHub, type, isInitialized, cpi); + Constant typeInstruction = genTypeOrDeopt(RiType.Representation.ObjectHub, type, isInitialized, cpi); Value object = frameState.apop(); if (typeInstruction != null) { - frameState.ipush(append(new InstanceOf(type, typeInstruction, object, graph))); + frameState.ipush(append(new InstanceOf(typeInstruction, object, graph))); } else { frameState.ipush(appendConstant(CiConstant.INT_0)); } @@ -869,7 +869,7 @@ } } - private Value genTypeOrDeopt(RiType.Representation representation, RiType holder, boolean initialized, int cpi) { + private Constant genTypeOrDeopt(RiType.Representation representation, RiType holder, boolean initialized, int cpi) { if (initialized) { return appendConstant(holder.getEncoding(representation)); } else { @@ -1119,8 +1119,8 @@ append(lookupSwitch); } - private Value appendConstant(CiConstant constant) { - return append(new Constant(constant, graph)); + private Constant appendConstant(CiConstant constant) { + return new Constant(constant, graph); } private Value append(FixedNode fixed) {