# HG changeset patch # User Doug Simon # Date 1379081862 -7200 # Node ID 625662f170ee5ebea1b73a91aeda617a49e2339b # Parent 1aed684853f6db27c9aa34bc2c1a356a9b64c603# Parent 1ca5e39d043372a81586b12aa2da1da789e0f5a2 Merge. diff -r 1aed684853f6 -r 625662f170ee graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionTest.java Fri Sep 13 16:08:23 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionTest.java Fri Sep 13 16:17:42 2013 +0200 @@ -45,7 +45,7 @@ Constant b = Constant.forInt(i < 100 ? a.asInt() : rand.nextInt()); boolean result1 = c1.foldCondition(a, b, null, false); boolean result2 = c2.foldCondition(a, b, null, false); - if (result1 && implies) { + if (result1) { assertTrue(result2); } } @@ -60,7 +60,7 @@ for (Condition c1 : Condition.values()) { for (Condition c2 : Condition.values()) { Condition join = c1.join(c2); - assertTrue(join == c2.join(c1)); + assertEquals(join, c2.join(c1)); if (join != null) { for (int i = 0; i < 1000; i++) { Constant a = Constant.forInt(rand.nextInt()); @@ -70,6 +70,8 @@ boolean resultJoin = join.foldCondition(a, b, null, false); if (result1 && result2) { assertTrue(resultJoin); + } else { + assertFalse(resultJoin); } } } @@ -83,7 +85,7 @@ for (Condition c1 : Condition.values()) { for (Condition c2 : Condition.values()) { Condition meet = c1.meet(c2); - assertTrue(meet == c2.meet(c1)); + assertEquals(meet, c2.meet(c1)); if (meet != null) { for (int i = 0; i < 1000; i++) { Constant a = Constant.forInt(rand.nextInt()); @@ -93,6 +95,8 @@ boolean resultMeet = meet.foldCondition(a, b, null, false); if (result1 || result2) { assertTrue(resultMeet); + } else { + assertFalse(resultMeet); } } } diff -r 1aed684853f6 -r 625662f170ee graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest.java Fri Sep 13 16:08:23 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest.java Fri Sep 13 16:17:42 2013 +0200 @@ -229,4 +229,36 @@ assertEquals(0, graph.getNodes().filter(StoreFieldNode.class).count()); } + public static String testInstanceOfCheckCastSnippet(Object e) { + if (e instanceof Entry) { + return ((Entry) e).name; + } + return null; + } + + @Test + public void testInstanceOfCheckCast() { + StructuredGraph graph = parse("testInstanceOfCheckCastSnippet"); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), null, replacements)); + new ConditionalEliminationPhase(runtime()).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), null, replacements)); + + assertEquals(0, graph.getNodes().filter(CheckCastNode.class).count()); + } + + @Test + @Ignore + public void testInstanceOfCheckCastLowered() { + StructuredGraph graph = parse("testInstanceOfCheckCastSnippet"); + + CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true); + PhaseContext context = new PhaseContext(runtime(), null, replacements); + + new LoweringPhase(canonicalizer).apply(graph, context); + canonicalizer.apply(graph, context); + new ConditionalEliminationPhase(runtime()).apply(graph); + canonicalizer.apply(graph, context); + + assertEquals(0, graph.getNodes().filter(GuardNode.class).count()); + } } diff -r 1aed684853f6 -r 625662f170ee graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Fri Sep 13 16:08:23 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Fri Sep 13 16:17:42 2013 +0200 @@ -636,7 +636,7 @@ graph.replaceFixedWithFixed(storeIndexed, memoryWrite); } else if (n instanceof UnsafeLoadNode) { - if (graph.getGuardsPhase().ordinal() > StructuredGraph.GuardsPhase.FLOATING_GUARDS.ordinal()) { + if (graph.getGuardsPhase().ordinal() > StructuredGraph.GuardsStage.FLOATING_GUARDS.ordinal()) { UnsafeLoadNode load = (UnsafeLoadNode) n; assert load.kind() != Kind.Illegal; boolean compressible = (!load.object().isNullConstant() && load.accessKind() == Kind.Object); @@ -676,7 +676,7 @@ WriteNode hub = createWriteHub(graph, wordKind, storeHub.getObject(), storeHub.getValue()); graph.replaceFixed(storeHub, hub); } else if (n instanceof CommitAllocationNode) { - if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS) { CommitAllocationNode commit = (CommitAllocationNode) n; ValueNode[] allocations = new ValueNode[commit.getVirtualObjects().size()]; @@ -752,7 +752,7 @@ graph.removeFixed(commit); } } else if (n instanceof OSRStartNode) { - if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS) { OSRStartNode osrStart = (OSRStartNode) n; StartNode newStart = graph.add(new StartNode()); LocalNode buffer = graph.unique(new LocalNode(0, StampFactory.forKind(wordKind()))); @@ -781,31 +781,31 @@ } else if (n instanceof CheckCastDynamicNode) { checkcastDynamicSnippets.lower((CheckCastDynamicNode) n); } else if (n instanceof InstanceOfNode) { - if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS) { instanceofSnippets.lower((InstanceOfNode) n, tool); } } else if (n instanceof InstanceOfDynamicNode) { - if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS) { instanceofSnippets.lower((InstanceOfDynamicNode) n, tool); } } else if (n instanceof NewInstanceNode) { - if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.AFTER_FSA) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.AFTER_FSA) { newObjectSnippets.lower((NewInstanceNode) n); } } else if (n instanceof NewArrayNode) { - if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.AFTER_FSA) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.AFTER_FSA) { newObjectSnippets.lower((NewArrayNode) n); } } else if (n instanceof DynamicNewArrayNode) { - if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.AFTER_FSA) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.AFTER_FSA) { newObjectSnippets.lower((DynamicNewArrayNode) n); } } else if (n instanceof MonitorEnterNode) { - if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS) { monitorSnippets.lower((MonitorEnterNode) n, tool); } } else if (n instanceof MonitorExitNode) { - if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS) { monitorSnippets.lower((MonitorExitNode) n, tool); } } else if (n instanceof G1PreWriteBarrier) { @@ -823,7 +823,7 @@ } else if (n instanceof G1ArrayRangePostWriteBarrier) { writeBarrierSnippets.lower((G1ArrayRangePostWriteBarrier) n, tool); } else if (n instanceof NewMultiArrayNode) { - if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.AFTER_FSA) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.AFTER_FSA) { newObjectSnippets.lower((NewMultiArrayNode) n); } } else if (n instanceof LoadExceptionObjectNode) { @@ -844,7 +844,7 @@ } private static boolean addReadBarrier(UnsafeLoadNode load) { - if (useG1GC() && load.graph().getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS && load.object().kind() == Kind.Object && load.accessKind() == Kind.Object && + if (useG1GC() && load.graph().getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS && load.object().kind() == Kind.Object && load.accessKind() == Kind.Object && !ObjectStamp.isObjectAlwaysNull(load.object())) { ResolvedJavaType type = ObjectStamp.typeOrNull(load.object()); if (type != null && !type.isArray()) { diff -r 1aed684853f6 -r 625662f170ee graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopyNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopyNode.java Fri Sep 13 16:08:23 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopyNode.java Fri Sep 13 16:17:42 2013 +0200 @@ -93,7 +93,7 @@ @Override public void lower(LoweringTool tool) { - if (graph().getGuardsPhase() == StructuredGraph.GuardsPhase.AFTER_FSA) { + if (graph().getGuardsPhase() == StructuredGraph.GuardsStage.AFTER_FSA) { UnsafeArrayCopySnippets.Templates templates = tool.getReplacements().getSnippetTemplateCache(UnsafeArrayCopySnippets.Templates.class); templates.lower(this); } diff -r 1aed684853f6 -r 625662f170ee graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java Fri Sep 13 16:08:23 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java Fri Sep 13 16:17:42 2013 +0200 @@ -107,7 +107,7 @@ @Override public void lower(LoweringTool tool) { - if (graph().getGuardsPhase() == StructuredGraph.GuardsPhase.FLOATING_GUARDS) { + if (graph().getGuardsPhase() == StructuredGraph.GuardsStage.FLOATING_GUARDS) { GuardingNode guard = tool.createGuard(condition(), getReason(), getAction(), isNegated()); ValueAnchorNode newAnchor = graph().add(new ValueAnchorNode(guard.asNode())); this.replaceAtUsages(guard.asNode()); diff -r 1aed684853f6 -r 625662f170ee 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 Fri Sep 13 16:08:23 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardingPiNode.java Fri Sep 13 16:17:42 2013 +0200 @@ -77,7 +77,7 @@ @Override public void lower(LoweringTool tool) { - if (graph().getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS) { + if (graph().getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS) { throw new GraalInternalError("Cannot create guards in after-guard lowering"); } FixedGuardNode guard = graph().add(new FixedGuardNode(condition, reason, action, negated)); diff -r 1aed684853f6 -r 625662f170ee graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java Fri Sep 13 16:08:23 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java Fri Sep 13 16:17:42 2013 +0200 @@ -37,8 +37,33 @@ */ public class StructuredGraph extends Graph { - public static enum GuardsPhase { - FLOATING_GUARDS, FIXED_DEOPTS, AFTER_FSA + /** + * The different stages of the compilation of a {@link Graph} regarding the status of + * {@link GuardNode guards}, {@link DeoptimizingNode deoptimizations} and {@link FrameState + * framestates}. The stage of a graph progresses monotonously. + * + */ + public static enum GuardsStage { + /** + * During this stage, there can be {@link FloatingNode floating} {@link DeoptimizingNode} + * such as {@link GuardNode GuardNodes}. New {@link DeoptimizingNode DeoptimizingNodes} can + * be introduced without constraints. {@link FrameState} nodes are associated with + * {@link StateSplit} nodes. + */ + FLOATING_GUARDS, + /** + * During this stage, all {@link DeoptimizingNode DeoptimizingNodes} must be + * {@link FixedNode fixed} but new {@link DeoptimizingNode DeoptimizingNodes} can still be + * introduced. {@link FrameState} nodes are still associated with {@link StateSplit} nodes. + */ + FIXED_DEOPTS, + /** + * During this stage, all {@link DeoptimizingNode DeoptimizingNodes} must be + * {@link FixedNode fixed}. New {@link DeoptimizingNode DeoptimizingNodes} can not be + * introduced any more. {@link FrameState} nodes are now associated with + * {@link DeoptimizingNode} nodes. + */ + AFTER_FSA } public static final int INVOCATION_ENTRY_BCI = -1; @@ -52,7 +77,7 @@ private final ResolvedJavaMethod method; private final long graphId; private final int entryBCI; - private GuardsPhase guardsPhase = GuardsPhase.FLOATING_GUARDS; + private GuardsStage guardsPhase = GuardsStage.FLOATING_GUARDS; /** * Creates a new Graph containing a single {@link AbstractBeginNode} as the {@link #start() @@ -392,11 +417,11 @@ } } - public GuardsPhase getGuardsPhase() { + public GuardsStage getGuardsPhase() { return guardsPhase; } - public void setGuardsPhase(GuardsPhase guardsPhase) { + public void setGuardsPhase(GuardsStage guardsPhase) { assert guardsPhase.ordinal() >= this.guardsPhase.ordinal(); this.guardsPhase = guardsPhase; } diff -r 1aed684853f6 -r 625662f170ee graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/WriteBarrier.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/WriteBarrier.java Fri Sep 13 16:08:23 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/WriteBarrier.java Fri Sep 13 16:17:42 2013 +0200 @@ -54,7 +54,7 @@ @Override public void lower(LoweringTool generator) { - assert graph().getGuardsPhase() == StructuredGraph.GuardsPhase.AFTER_FSA; + assert graph().getGuardsPhase() == StructuredGraph.GuardsStage.AFTER_FSA; generator.getRuntime().lower(this, generator); } } diff -r 1aed684853f6 -r 625662f170ee graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java Fri Sep 13 16:08:23 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java Fri Sep 13 16:17:42 2013 +0200 @@ -59,7 +59,7 @@ @Override public void lower(LoweringTool tool) { - if (graph().getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS) { + if (graph().getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS) { tool.getRuntime().lower(this, tool); } } diff -r 1aed684853f6 -r 625662f170ee 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 Fri Sep 13 16:08:23 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Fri Sep 13 16:17:42 2013 +0200 @@ -159,7 +159,7 @@ if (ObjectStamp.isObjectAlwaysNull(object())) { return object(); } - if (tool.assumptions().useOptimisticAssumptions()) { + if (tool.assumptions() != null && tool.assumptions().useOptimisticAssumptions()) { ResolvedJavaType exactType = type.findUniqueConcreteSubtype(); if (exactType != null && exactType != type) { // Propagate more precise type information to usages of the checkcast. diff -r 1aed684853f6 -r 625662f170ee graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FrameStateAssignmentPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FrameStateAssignmentPhase.java Fri Sep 13 16:08:23 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FrameStateAssignmentPhase.java Fri Sep 13 16:17:42 2013 +0200 @@ -27,12 +27,22 @@ import com.oracle.graal.graph.*; import com.oracle.graal.graph.iterators.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.StructuredGraph.GuardsPhase; +import com.oracle.graal.nodes.StructuredGraph.GuardsStage; import com.oracle.graal.nodes.util.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.graph.*; import com.oracle.graal.phases.graph.ReentrantNodeIterator.NodeIteratorClosure; +/** + * This phase transfers {@link FrameState} nodes from {@link StateSplit} nodes to + * {@link DeoptimizingNode DeoptimizingNodes}. + * + * This allow to enter the {@link GuardsStage#AFTER_FSA AFTER_FSA} stage of the graph where no new + * node that may cause deoptimization can be introduced anymore. + *

+ * This Phase processes the graph in post order, assigning the {@link FrameState} from the last + * {@link StateSplit} node to {@link DeoptimizingNode DeoptimizingNodes}. + */ public class FrameStateAssignmentPhase extends Phase { private static class FrameStateAssignmentClosure extends NodeIteratorClosure { @@ -79,7 +89,7 @@ assert checkFixedDeopts(graph); ReentrantNodeIterator.apply(new FrameStateAssignmentClosure(), graph.start(), null, null); - graph.setGuardsPhase(GuardsPhase.AFTER_FSA); + graph.setGuardsPhase(GuardsStage.AFTER_FSA); } private static boolean checkFixedDeopts(StructuredGraph graph) { diff -r 1aed684853f6 -r 625662f170ee graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java Fri Sep 13 16:08:23 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java Fri Sep 13 16:17:42 2013 +0200 @@ -29,7 +29,7 @@ import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.StructuredGraph.GuardsPhase; +import com.oracle.graal.nodes.StructuredGraph.GuardsStage; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.nodes.extended.*; @@ -43,9 +43,9 @@ * This phase lowers {@link GuardNode GuardNodes} into corresponding control-flow structure and * {@link DeoptimizeNode DeoptimizeNodes}. * - * This allow to enter a phase of the compiler where all node that may cause deoptimization are - * fixed. - * + * This allow to enter the {@link GuardsStage#FIXED_DEOPTS FIXED_DEOPTS} stage of the graph where + * all node that may cause deoptimization are fixed. + *

* It first makes a schedule in order to know where the control flow should be placed. Then, for * each block, it applies two passes. The first one tries to replace null-check guards with implicit * null checks performed by access to the objects that need to be null checked. The second phase @@ -189,7 +189,7 @@ processBlock(block, schedule, context.getTarget().implicitNullCheckLimit); } - graph.setGuardsPhase(GuardsPhase.FIXED_DEOPTS); + graph.setGuardsPhase(GuardsStage.FIXED_DEOPTS); } private static void processBlock(Block block, SchedulePhase schedule, int implicitNullCheckLimit) { diff -r 1aed684853f6 -r 625662f170ee graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java Fri Sep 13 16:08:23 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java Fri Sep 13 16:17:42 2013 +0200 @@ -95,7 +95,7 @@ @Override public GuardingNode createGuard(LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action, boolean negated) { - if (condition.graph().getGuardsPhase().ordinal() > StructuredGraph.GuardsPhase.FLOATING_GUARDS.ordinal()) { + if (condition.graph().getGuardsPhase().ordinal() > StructuredGraph.GuardsStage.FLOATING_GUARDS.ordinal()) { throw new GraalInternalError("Cannot create guards after guard lowering"); } if (OptEliminateGuards.getValue()) { diff -r 1aed684853f6 -r 625662f170ee graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerExactArithmeticSplitNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerExactArithmeticSplitNode.java Fri Sep 13 16:08:23 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerExactArithmeticSplitNode.java Fri Sep 13 16:17:42 2013 +0200 @@ -81,7 +81,7 @@ protected abstract Value generateArithmetic(LIRGeneratorTool generator); static void lower(LoweringTool tool, IntegerExactArithmeticNode node) { - if (node.asNode().graph().getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS) { + if (node.asNode().graph().getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS) { FloatingNode floatingNode = (FloatingNode) node; FixedWithNextNode previous = tool.lastFixedNode(); FixedNode next = previous.next(); diff -r 1aed684853f6 -r 625662f170ee graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomTypeCheckNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomTypeCheckNode.java Fri Sep 13 16:08:23 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomTypeCheckNode.java Fri Sep 13 16:17:42 2013 +0200 @@ -51,7 +51,7 @@ } public void lower(LoweringTool tool) { - if (graph().getGuardsPhase() == StructuredGraph.GuardsPhase.FLOATING_GUARDS) { + if (graph().getGuardsPhase() == StructuredGraph.GuardsStage.FLOATING_GUARDS) { this.replaceAtUsages(graph().unique(new IntegerEqualsNode(condition, ConstantNode.forInt(1, graph())))); this.safeDelete(); } diff -r 1aed684853f6 -r 625662f170ee graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/TypeCastNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/TypeCastNode.java Fri Sep 13 16:08:23 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/TypeCastNode.java Fri Sep 13 16:17:42 2013 +0200 @@ -60,7 +60,7 @@ } public void lower(LoweringTool tool) { - if (graph().getGuardsPhase() == StructuredGraph.GuardsPhase.FLOATING_GUARDS) { + if (graph().getGuardsPhase() == StructuredGraph.GuardsStage.FLOATING_GUARDS) { ValueAnchorNode valueAnchorNode = graph().add(new ValueAnchorNode()); UnsafeCastNode unsafeCast = graph().unique(new UnsafeCastNode(object, this.stamp(), (GuardingNode) valueAnchorNode)); this.replaceAtUsages(unsafeCast); diff -r 1aed684853f6 -r 625662f170ee graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Fri Sep 13 16:08:23 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Fri Sep 13 16:17:42 2013 +0200 @@ -423,6 +423,24 @@ return result; } + /** + * Get the nth parent of a node, where the 0th parent is the node itself. Returns null if there + * are less than n ancestors. + */ + public static Node getNthParent(Node node, int n) { + Node parent = node; + + for (int i = 0; i < n; i++) { + parent = parent.getParent(); + + if (parent == null) { + return null; + } + } + + return parent; + } + /** find annotation in class/interface hierarchy. */ public static T findAnnotation(Class clazz, Class annotationClass) { if (clazz.getAnnotation(annotationClass) != null) {