# HG changeset patch # User Thomas Wuerthinger # Date 1379260818 -7200 # Node ID 932252b772c379a22da50528e6fd5cd06a15fecf # Parent e8dfad9a424f97566fc8f0a498ce2460afb22bfc# Parent fe748819e31c97bffeaae73da2511bc46f560218 Merge. diff -r e8dfad9a424f -r 932252b772c3 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Sun Sep 15 16:44:09 2013 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Sun Sep 15 18:00:18 2013 +0200 @@ -81,6 +81,11 @@ protected StructuredGraph currentGraph; + /** + * Head of placeholder list. + */ + protected BlockPlaceholderNode placeholders; + private final MetaAccessProvider runtime; private ConstantPool constantPool; private ResolvedJavaMethod method; @@ -109,13 +114,24 @@ /** * Node that marks the begin of block during bytecode parsing. When a block is identified the * first time as a jump target, the placeholder is created and used as the successor for the - * jump. When the block is seen the second time, a MergeNode is created to correctly merge the - * now two different predecessor states. + * jump. When the block is seen the second time, a {@link MergeNode} is created to correctly + * merge the now two different predecessor states. */ - private static class BlockPlaceholderNode extends FixedWithNextNode implements IterableNodeType { + private static class BlockPlaceholderNode extends FixedWithNextNode { + + // Cannot be explicitly declared as a Node type since it is not an input; + // would cause the !NODE_CLASS.isAssignableFrom(type) guarantee + // in NodeClass.FieldScanner.scanField() to fail. + private final Object nextPlaceholder; - public BlockPlaceholderNode() { + public BlockPlaceholderNode(GraphBuilderPhase builder) { super(StampFactory.forVoid()); + nextPlaceholder = builder.placeholders; + builder.placeholders = this; + } + + BlockPlaceholderNode nextPlaceholder() { + return (BlockPlaceholderNode) nextPlaceholder; } } @@ -236,9 +252,12 @@ connectLoopEndToBegin(); // remove Placeholders - for (BlockPlaceholderNode n : currentGraph.getNodes(BlockPlaceholderNode.class)) { - currentGraph.removeFixed(n); + for (BlockPlaceholderNode n = placeholders; n != null; n = n.nextPlaceholder()) { + if (!n.isDeleted()) { + currentGraph.removeFixed(n); + } } + placeholders = null; // remove dead FrameStates for (Node n : currentGraph.getNodes(FrameState.class)) { @@ -326,7 +345,7 @@ */ protected void handleUnresolvedInstanceOf(JavaType type, ValueNode object) { assert !graphBuilderConfig.eagerResolving(); - BlockPlaceholderNode successor = currentGraph.add(new BlockPlaceholderNode()); + BlockPlaceholderNode successor = currentGraph.add(new BlockPlaceholderNode(this)); DeoptimizeNode deopt = currentGraph.add(new DeoptimizeNode(InvalidateRecompile, Unresolved)); append(new IfNode(currentGraph.unique(new IsNullNode(object)), successor, deopt, 1)); lastInstr = successor; @@ -935,8 +954,8 @@ if (ObjectStamp.isObjectNonNull(receiver.stamp())) { return; } - BlockPlaceholderNode trueSucc = currentGraph.add(new BlockPlaceholderNode()); - BlockPlaceholderNode falseSucc = currentGraph.add(new BlockPlaceholderNode()); + BlockPlaceholderNode trueSucc = currentGraph.add(new BlockPlaceholderNode(this)); + BlockPlaceholderNode falseSucc = currentGraph.add(new BlockPlaceholderNode(this)); append(new IfNode(currentGraph.unique(new IsNullNode(receiver)), trueSucc, falseSucc, 0.01)); lastInstr = falseSucc; @@ -959,8 +978,8 @@ } private void emitBoundsCheck(ValueNode index, ValueNode length) { - BlockPlaceholderNode trueSucc = currentGraph.add(new BlockPlaceholderNode()); - BlockPlaceholderNode falseSucc = currentGraph.add(new BlockPlaceholderNode()); + BlockPlaceholderNode trueSucc = currentGraph.add(new BlockPlaceholderNode(this)); + BlockPlaceholderNode falseSucc = currentGraph.add(new BlockPlaceholderNode(this)); append(new IfNode(currentGraph.unique(new IntegerBelowThanNode(index, length)), trueSucc, falseSucc, 0.99)); lastInstr = trueSucc; @@ -1458,7 +1477,7 @@ // This is the first time we see this block as a branch target. // Create and return a placeholder that later can be replaced with a MergeNode when we // see this block again. - block.firstInstruction = currentGraph.add(new BlockPlaceholderNode()); + block.firstInstruction = currentGraph.add(new BlockPlaceholderNode(this)); Target target = checkLoopExit(block.firstInstruction, block, state); FixedNode result = target.fixed; block.entryState = target.state == state ? state.copy() : target.state;