# HG changeset patch # User Christian Humer # Date 1381769301 -7200 # Node ID 47eb670c163449c1e951b4efe4849ff4972043a4 # Parent 52caeb1c19a05c0749ff6ae16d3e4fda2c933d49# Parent 28d80a9260cdc955a9d3361fd73c4fc2377ff7b6 Merge. diff -r 52caeb1c19a0 -r 47eb670c1634 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardingPiNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardingPiNode.java Mon Oct 14 18:35:48 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardingPiNode.java Mon Oct 14 18:48:21 2013 +0200 @@ -77,9 +77,6 @@ @Override public void lower(LoweringTool tool) { - if (graph().getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) { - throw new GraalInternalError("Cannot create guards in after-guard lowering"); - } GuardingNode guard = tool.createGuard(condition, reason, action, negated); ValueAnchorNode anchor = graph().add(new ValueAnchorNode((ValueNode) guard)); PiNode pi = graph().unique(new PiNode(object, stamp(), (ValueNode) guard)); diff -r 52caeb1c19a0 -r 47eb670c1634 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Mon Oct 14 18:35:48 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Mon Oct 14 18:48:21 2013 +0200 @@ -91,13 +91,12 @@ * 2: B b = guardingPi(a instanceof B, a, stamp(B, non-null)) * * - * Note: we use {@link Graph#add} as opposed to {@link Graph#unique} for the new + * Note: we use {@link Graph#addWithoutUnique} as opposed to {@link Graph#unique} for the new * {@link InstanceOfNode} to maintain the invariant checked by * {@code LoweringPhase.checkUsagesAreScheduled()}. */ @Override public void lower(LoweringTool tool) { - InstanceOfNode typeTest = graph().addWithoutUnique(new InstanceOfNode(type, object, profile)); Stamp stamp = StampFactory.declared(type); if (stamp() instanceof ObjectStamp && object().stamp() instanceof ObjectStamp) { stamp = ((ObjectStamp) object().stamp()).castTo((ObjectStamp) stamp); @@ -108,17 +107,20 @@ condition = LogicConstantNode.contradiction(graph()); stamp = StampFactory.declared(type); } else if (ObjectStamp.isObjectNonNull(object)) { - condition = typeTest; + condition = graph().addWithoutUnique(new InstanceOfNode(type, object, profile)); } else { if (profile != null && profile.getNullSeen() == TriState.FALSE) { - FixedGuardNode nullGuard = graph().add(new FixedGuardNode(graph().unique(new IsNullNode(object)), UnreachedCode, DeoptimizationAction.InvalidateReprofile, true)); - graph().addBeforeFixed(this, nullGuard); + 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)); + graph().addBeforeFixed(this, nullCheck); condition = typeTest; stamp = stamp.join(StampFactory.objectNonNull()); - nullGuard.lower(tool); + nullCheck.lower(tool); } 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); } }