# HG changeset patch # User Thomas Wuerthinger # Date 1306765462 -7200 # Node ID 2b8ef0a0639153c66327ec4503e62559e1559740 # Parent 774d2bc061484254cb4dfddeaa4dd72455cd6fbb Clean up in the graph builder. diff -r 774d2bc06148 -r 2b8ef0a06391 graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Mon May 30 15:36:22 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Mon May 30 16:24:22 2011 +0200 @@ -59,25 +59,6 @@ */ public static final int TRACELEVEL_STATE = 2; - /** - * An enumeration of flags describing scope attributes. - */ - public enum Flag { - /** - * Scope is protected by an exception handler. - * This attribute is inherited by nested scopes. - */ - HasHandler, - - /** - * Code in scope cannot contain safepoints. - * This attribute is inherited by nested scopes. - */ - NoSafepoints; - - public final int mask = 1 << ordinal(); - } - private final IR ir; private final C1XCompilation compilation; private final CiStatistics stats; @@ -97,11 +78,6 @@ } }); - /** - * Mask of {@link Flag} values. - */ - private int flags; - // Exception handler list private List exceptionHandlers; @@ -114,8 +90,6 @@ private final Graph graph; - private Merge unwindBlock; - /** * Creates a new, initialized, {@code GraphBuilder} instance for a given compilation. * @@ -146,10 +120,6 @@ log.println("Compiling " + compilation.method); } - if (rootMethod.noSafepoints()) { - flags |= Flag.NoSafepoints.mask; - } - // 2. compute the block map, setup exception handlers and get the entrypoint(s) BlockMap blockMap = compilation.getBlockMap(rootMethod); @@ -177,8 +147,6 @@ exceptionHandlers.add(h); } } - flags |= Flag.HasHandler.mask; - } // 1. create the start block @@ -297,8 +265,6 @@ FrameState existingState = ((StateSplit) first).stateBefore(); if (existingState == null) { -// assert first instanceof Merge ^ !target.isLoopHeader : "isLoopHeader: " + target.isLoopHeader; - // copy state because it is modified FrameState duplicate = newState.duplicate(bci); @@ -422,13 +388,12 @@ StateSplit entry = new Placeholder(graph); entry.setStateBefore(entryState); ExceptionObject exception = new ExceptionObject(graph); - entry.appendNext(exception); + entry.setNext(exception); FrameState stateWithException = entryState.duplicateModified(bci, CiKind.Void, exception); Instruction successor = createTarget(dispatchBlock, stateWithException); BlockEnd end = new Anchor(successor, graph); - exception.appendNext(end); - + exception.setNext(end); if (x instanceof Invoke) { ((Invoke) x).setExceptionEdge(entry); } else { @@ -1043,15 +1008,11 @@ } private Value appendWithBCI(Instruction x) { - if (x.isAppended()) { - // the instruction has already been added - return x; - } + assert x.next() == null && x.predecessors().size() == 0 : "instruction should not have been appended yet"; + assert lastInstr.next() == null : "cannot append instruction to instruction which isn't end (" + lastInstr + "->" + lastInstr.next() + ")"; + lastInstr.setNext(x); - assert x.next() == null : "instruction should not have been appended yet"; - assert lastInstr.next() == null : "cannot append instruction to instruction which isn't end (" + lastInstr + "->" + lastInstr.next() + ")"; - - lastInstr = lastInstr.appendNext(x); + lastInstr = x; if (++stats.nodeCount >= C1XOptions.MaximumInstructionCount) { // bailout if we've exceeded the maximum inlining size throw new CiBailout("Method and/or inlining is too large"); @@ -1114,12 +1075,7 @@ assert lock != null; assert frameState.locksSize() > 0 && frameState.lockAt(frameState.locksSize() - 1) == lock; - if (lock instanceof Instruction) { - Instruction l = (Instruction) lock; - if (!l.isAppended()) { - lock = appendWithBCI(l); - } - } + // Exit the monitor and unwind the stack. genMonitorExit(lock); append(new Unwind(frameState.apop(), graph)); @@ -1210,13 +1166,7 @@ } private void appendGoto(Instruction target) { - //if (target instanceof BlockBegin && !((BlockBegin)target).isLoopHeader) { - // System.out.println("NOTOMITTED"); - //append(new Goto(target, graph)); - //} else { - // System.out.println("omitted"); - lastInstr.appendNext(target); - //} + lastInstr.setNext(target); } private void iterateBytecodesForBlock(Block block) { @@ -1525,7 +1475,6 @@ exceptionHandlers = new ArrayList(); } exceptionHandlers.add(handler); - flags |= Flag.HasHandler.mask; } /** @@ -1560,13 +1509,6 @@ * @return {@code true} if there are any exception handlers */ private boolean hasHandler() { - return (flags & Flag.HasHandler.mask) != 0; - } - - /** - * Checks whether this graph can contain safepoints. - */ - private boolean noSafepoints() { - return (flags & Flag.NoSafepoints.mask) != 0; + return Modifier.isSynchronized(compilation.method.accessFlags()) || (compilation.method.exceptionHandlers() != null && compilation.method.exceptionHandlers().length > 0); } } diff -r 774d2bc06148 -r 2b8ef0a06391 graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java Mon May 30 15:36:22 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java Mon May 30 16:24:22 2011 +0200 @@ -66,7 +66,7 @@ return (Instruction) successors().get(super.successorCount() + SUCCESSOR_NEXT); } - private Node setNext(Instruction next) { + public Node setNext(Instruction next) { return successors().set(super.successorCount() + SUCCESSOR_NEXT, next); } @@ -77,8 +77,6 @@ public static final int SYNCHRONIZATION_ENTRY_BCI = -1; - private boolean isAppended = false; - /** * Constructs a new instruction with the specified value type. * @param kind the value type for this instruction @@ -90,30 +88,6 @@ C1XMetrics.HIRInstructions++; } - /** - * Checks whether this instruction has already been added to its basic block. - * @return {@code true} if this instruction has been added to the basic block containing it - */ - public final boolean isAppended() { - return isAppended; - } - - - /** - * Sets the next instruction for this instruction. Note that it is illegal to - * set the next field of a phi, block end, or local instruction. - * @param next the next instruction - * @param bci the bytecode index of the next instruction - * @return the new next instruction - */ - public final Instruction appendNext(Instruction next) { - setNext(next); - if (next != null) { - assert !(this instanceof BlockEnd); - next.isAppended = true; - } - return next; - } /** * Gets the list of predecessors of this block. @@ -121,11 +95,7 @@ */ @SuppressWarnings({ "unchecked", "rawtypes" }) public List blockPredecessors() { - /*if (predecessors().size() == 1 && predecessors().get(0) == graph().start()) { - return Collections.EMPTY_LIST; - } else {)*/ - return (List) Collections.unmodifiableList(predecessors()); - //} + return (List) Collections.unmodifiableList(predecessors()); } /** @@ -133,12 +103,7 @@ * @return the number of predecessors */ public int numberOfPreds() { - // ignore the graph root - /*if (predecessors().size() == 1 && predecessors().get(0) == graph().start()) { - return 0; - } else {*/ - return predecessors().size(); - //} + return predecessors().size(); } public Instruction predAt(int j) { diff -r 774d2bc06148 -r 2b8ef0a06391 rundacapo.sh --- a/rundacapo.sh Mon May 30 15:36:22 2011 +0200 +++ b/rundacapo.sh Mon May 30 16:24:22 2011 +0200 @@ -15,4 +15,4 @@ echo "DACAPO is not defined. It must point to a Dacapo benchmark directory." exit 1; fi -${JDK7}/bin/java -client -d64 -graal -XX:-C1XBailoutIsFatal -XX:+PrintCompilation -C1X:+QuietBailout -Xms1g -Xmx2g -esa -classpath ${DACAPO}/dacapo-9.12-bach.jar Harness $* +${JDK7}/bin/java -client -d64 -graal -XX:+C1XBailoutIsFatal -XX:+PrintCompilation -C1X:-QuietBailout -Xms1g -Xmx2g -esa -classpath ${DACAPO}/dacapo-9.12-bach.jar Harness $*