Mercurial > hg > truffle
diff graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java @ 16895:06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 18 Aug 2014 14:04:21 +0200 |
parents | cbd42807a31f |
children | f90dcdbbb75e |
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Mon Aug 18 13:49:25 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Mon Aug 18 14:04:21 2014 +0200 @@ -59,7 +59,11 @@ * @param type the type being cast to * @param object the instruction producing the object */ - public CheckCastNode(ResolvedJavaType type, ValueNode object, JavaTypeProfile profile, boolean forStoreCheck) { + public static CheckCastNode create(ResolvedJavaType type, ValueNode object, JavaTypeProfile profile, boolean forStoreCheck) { + return new CheckCastNodeGen(type, object, profile, forStoreCheck); + } + + CheckCastNode(ResolvedJavaType type, ValueNode object, JavaTypeProfile profile, boolean forStoreCheck) { super(StampFactory.declared(type)); assert type != null; this.type = type; @@ -111,12 +115,12 @@ condition = LogicConstantNode.contradiction(graph()); stamp = StampFactory.declared(type); } else if (StampTool.isObjectNonNull(object)) { - condition = graph().addWithoutUnique(new InstanceOfNode(type, object, profile)); + condition = graph().addWithoutUnique(InstanceOfNode.create(type, object, profile)); } else { if (profile != null && profile.getNullSeen() == TriState.FALSE) { - FixedGuardNode nullCheck = graph().add(new FixedGuardNode(graph().unique(new IsNullNode(object)), UnreachedCode, InvalidateReprofile, true)); - PiNode nullGuarded = graph().unique(new PiNode(object, object().stamp().join(StampFactory.objectNonNull()), nullCheck)); - InstanceOfNode typeTest = graph().addWithoutUnique(new InstanceOfNode(type, nullGuarded, profile)); + FixedGuardNode nullCheck = graph().add(FixedGuardNode.create(graph().unique(IsNullNode.create(object)), UnreachedCode, InvalidateReprofile, true)); + PiNode nullGuarded = graph().unique(PiNode.create(object, object().stamp().join(StampFactory.objectNonNull()), nullCheck)); + InstanceOfNode typeTest = graph().addWithoutUnique(InstanceOfNode.create(type, nullGuarded, profile)); graph().addBeforeFixed(this, nullCheck); condition = typeTest; /* @@ -130,11 +134,11 @@ } else { // TODO (ds) replace with probability of null-seen when available double shortCircuitProbability = NOT_FREQUENT_PROBABILITY; - InstanceOfNode typeTest = graph().addWithoutUnique(new InstanceOfNode(type, object, profile)); - condition = LogicNode.or(graph().unique(new IsNullNode(object)), typeTest, shortCircuitProbability); + InstanceOfNode typeTest = graph().addWithoutUnique(InstanceOfNode.create(type, object, profile)); + condition = LogicNode.or(graph().unique(IsNullNode.create(object)), typeTest, shortCircuitProbability); } } - GuardingPiNode checkedObject = graph().add(new GuardingPiNode(theValue, condition, false, forStoreCheck ? ArrayStoreException : ClassCastException, InvalidateReprofile, stamp)); + GuardingPiNode checkedObject = graph().add(GuardingPiNode.create(theValue, condition, false, forStoreCheck ? ArrayStoreException : ClassCastException, InvalidateReprofile, stamp)); graph().replaceFixedWithFixed(this, checkedObject); checkedObject.lower(tool); } @@ -166,7 +170,7 @@ if (exactType != null && !exactType.equals(type)) { // Propagate more precise type information to usages of the checkcast. tool.assumptions().recordConcreteSubtype(type, exactType); - return new CheckCastNode(exactType, object, profile, forStoreCheck); + return CheckCastNode.create(exactType, object, profile, forStoreCheck); } } @@ -181,7 +185,7 @@ CheckCastNode ccn = (CheckCastNode) predecessor(); if (ccn != null && ccn.type != null && ccn == object && ccn.forStoreCheck == forStoreCheck && ccn.type.isAssignableFrom(type)) { StructuredGraph graph = ccn.graph(); - CheckCastNode newccn = graph.add(new CheckCastNode(type, ccn.object, ccn.profile, ccn.forStoreCheck)); + CheckCastNode newccn = graph.add(CheckCastNode.create(type, ccn.object, ccn.profile, ccn.forStoreCheck)); graph.replaceFixedWithFixed(ccn, newccn); replaceAtUsages(newccn); graph.removeFixed(this);