# HG changeset patch # User Miguel Garcia # Date 1398780987 -7200 # Node ID 62f455eba8c516ee7859e6d7332b6370adc15be6 # Parent 746c0bda7ba6fef3cf922820a3048b35da114856# Parent 81eee524bbec22300eb9b2a4345a09d287fb6097 Merge diff -r 746c0bda7ba6 -r 62f455eba8c5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java Tue Apr 29 14:51:51 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java Tue Apr 29 16:16:27 2014 +0200 @@ -53,7 +53,7 @@ * FloatingReadNodes depends solely on the scheduling algorithm. The FrameStates normally keep the * FloatingReadNodes above a certain point, so that they (most of the time...) magically do the * right thing. - * + * * The scheduling shouldn't depend on FrameStates, which is tested by this class. */ public class MemoryScheduleTest extends GraphScheduleTest { @@ -247,7 +247,7 @@ @Test public void testLoop5() { SchedulePhase schedule = getFinalSchedule("testLoop5Snippet", TestMode.WITHOUT_FRAMESTATES); - assertEquals(7, schedule.getCFG().getBlocks().length); + assertEquals(10, schedule.getCFG().getBlocks().length); assertReadWithinStartBlock(schedule, false); assertReadWithinAllReturnBlocks(schedule, false); } @@ -266,7 +266,7 @@ StructuredGraph graph = schedule.getCFG().getStartBlock().getBeginNode().graph(); assertEquals(1, graph.getNodes(ReturnNode.class).count()); ReturnNode ret = graph.getNodes(ReturnNode.class).first(); - assertTrue(ret.result() instanceof FloatingReadNode); + assertTrue(ret.result() + " should be a FloatingReadNode", ret.result() instanceof FloatingReadNode); assertEquals(schedule.getCFG().blockFor(ret), schedule.getCFG().blockFor(ret.result())); assertReadWithinAllReturnBlocks(schedule, true); } @@ -585,7 +585,7 @@ private SchedulePhase getFinalSchedule(final String snippet, final TestMode mode, final MemoryScheduling memsched, final SchedulingStrategy schedulingStrategy) { final StructuredGraph graph = parse(snippet); try (Scope d = Debug.scope("FloatingReadTest", graph)) { - try (OverrideScope s = OptionValue.override(OptScheduleOutOfLoops, schedulingStrategy == SchedulingStrategy.LATEST_OUT_OF_LOOPS)) { + try (OverrideScope s = OptionValue.override(OptScheduleOutOfLoops, schedulingStrategy == SchedulingStrategy.LATEST_OUT_OF_LOOPS, OptImplicitNullChecks, false)) { Assumptions assumptions = new Assumptions(false); HighTierContext context = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL); CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true); diff -r 746c0bda7ba6 -r 62f455eba8c5 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Tue Apr 29 14:51:51 2014 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Tue Apr 29 16:16:27 2014 +0200 @@ -888,37 +888,114 @@ return true; } + private static class SortState { + private Block block; + private NodeBitMap visited; + private NodeBitMap beforeLastLocation; + private List sortedInstructions; + private List reads; + + SortState(Block block, NodeBitMap visited, NodeBitMap beforeLastLocation, List sortedInstructions) { + this.block = block; + this.visited = visited; + this.beforeLastLocation = beforeLastLocation; + this.sortedInstructions = sortedInstructions; + this.reads = null; + } + + public Block currentBlock() { + return block; + } + + void markVisited(Node n) { + visited.mark(n); + } + + boolean isVisited(Node n) { + return visited.isMarked(n); + } + + void markBeforeLastLocation(FloatingReadNode n) { + beforeLastLocation.mark(n); + } + + void clearBeforeLastLocation(FloatingReadNode frn) { + beforeLastLocation.clear(frn); + } + + boolean isBeforeLastLocation(FloatingReadNode n) { + return beforeLastLocation.isMarked(n); + } + + void addRead(FloatingReadNode n) { + if (reads == null) { + reads = new ArrayList<>(); + } + reads.add(n); + } + + int readsSize() { + if (reads == null) { + return 0; + } + return reads.size(); + } + + void removeRead(ScheduledNode i) { + assert reads != null; + reads.remove(i); + } + + List readsSnapshot() { + assert reads != null; + return new ArrayList<>(reads); + } + + List getSortedInstructions() { + return sortedInstructions; + } + + boolean containsInstruction(ScheduledNode i) { + return sortedInstructions.contains(i); + } + + void addInstruction(ScheduledNode i) { + sortedInstructions.add(i); + } + } + /** * Sorts the nodes within a block by adding the nodes to a list in a post-order iteration over * all inputs. This means that a node is added to the list after all its inputs have been * processed. */ private List sortNodesWithinBlockLatest(Block b, NodeBitMap visited, NodeBitMap beforeLastLocation) { + SortState state = new SortState(b, visited, beforeLastLocation, new ArrayList<>(blockToNodesMap.get(b).size() + 2)); List instructions = blockToNodesMap.get(b); - List sortedInstructions = new ArrayList<>(blockToNodesMap.get(b).size() + 2); - List reads = new ArrayList<>(); if (memsched == MemoryScheduling.OPTIMAL) { for (ScheduledNode i : instructions) { if (i instanceof FloatingReadNode) { FloatingReadNode frn = (FloatingReadNode) i; if (frn.location().getLocationIdentity() != FINAL_LOCATION) { - reads.add(frn); + state.addRead(frn); if (nodesFor(b).contains(frn.getLastLocationAccess())) { - assert !beforeLastLocation.isMarked(frn); - beforeLastLocation.mark(frn); + assert !state.isBeforeLastLocation(frn); + state.markBeforeLastLocation(frn); } } } } } + for (ScheduledNode i : instructions) { - addToLatestSorting(b, i, sortedInstructions, visited, reads, beforeLastLocation); + addToLatestSorting(i, state); } - assert reads.size() == 0 : "not all reads are scheduled"; + assert state.readsSize() == 0 : "not all reads are scheduled"; // Make sure that last node gets really last (i.e. when a frame state successor hangs off // it). + List sortedInstructions = state.getSortedInstructions(); Node lastSorted = sortedInstructions.get(sortedInstructions.size() - 1); if (lastSorted != b.getEndNode()) { int idx = sortedInstructions.indexOf(b.getEndNode()); @@ -944,40 +1021,39 @@ return sortedInstructions; } - private void processKillLocation(Block b, Node node, LocationIdentity identity, List sortedInstructions, NodeBitMap visited, List reads, - NodeBitMap beforeLastLocation) { - for (FloatingReadNode frn : new ArrayList<>(reads)) { // TODO: change to iterator? + private void processKillLocation(Node node, LocationIdentity identity, SortState state) { + for (FloatingReadNode frn : state.readsSnapshot()) { LocationIdentity readLocation = frn.location().getLocationIdentity(); assert readLocation != FINAL_LOCATION; if (frn.getLastLocationAccess() == node) { assert identity == ANY_LOCATION || readLocation == identity : "location doesn't match: " + readLocation + ", " + identity; - beforeLastLocation.clear(frn); - } else if (!beforeLastLocation.isMarked(frn) && (readLocation == identity || (node != getCFG().graph.start() && ANY_LOCATION == identity))) { - reads.remove(frn); - addToLatestSorting(b, frn, sortedInstructions, visited, reads, beforeLastLocation); + state.clearBeforeLastLocation(frn); + } else if (!state.isBeforeLastLocation(frn) && (readLocation == identity || (node != getCFG().graph.start() && ANY_LOCATION == identity))) { + state.removeRead(frn); + addToLatestSorting(frn, state); } } } - private void addUnscheduledToLatestSorting(Block b, VirtualState state, List sortedInstructions, NodeBitMap visited, List reads, NodeBitMap beforeLastLocation) { + private void addUnscheduledToLatestSorting(VirtualState state, SortState sortState) { if (state != null) { // UnscheduledNodes should never be marked as visited. - if (visited.isMarked(state)) { + if (sortState.isVisited(state)) { throw new SchedulingError(); } for (Node input : state.inputs()) { if (input instanceof VirtualState) { - addUnscheduledToLatestSorting(b, (VirtualState) input, sortedInstructions, visited, reads, beforeLastLocation); + addUnscheduledToLatestSorting((VirtualState) input, sortState); } else { - addToLatestSorting(b, (ScheduledNode) input, sortedInstructions, visited, reads, beforeLastLocation); + addToLatestSorting((ScheduledNode) input, sortState); } } } } - private void addToLatestSorting(Block b, ScheduledNode i, List sortedInstructions, NodeBitMap visited, List reads, NodeBitMap beforeLastLocation) { - if (i == null || visited.isMarked(i) || cfg.getNodeToBlock().get(i) != b || i instanceof PhiNode) { + private void addToLatestSorting(ScheduledNode i, SortState state) { + if (i == null || state.isVisited(i) || cfg.getNodeToBlock().get(i) != state.currentBlock() || i instanceof PhiNode) { return; } @@ -988,45 +1064,45 @@ if (i instanceof LoopExitNode) { for (ProxyNode proxy : ((LoopExitNode) i).proxies()) { - addToLatestSorting(b, proxy, sortedInstructions, visited, reads, beforeLastLocation); + addToLatestSorting(proxy, state); } } for (Node input : i.inputs()) { if (input instanceof FrameState) { if (input != stateAfter) { - addUnscheduledToLatestSorting(b, (FrameState) input, sortedInstructions, visited, reads, beforeLastLocation); + addUnscheduledToLatestSorting((FrameState) input, state); } } else { if (!(i instanceof ProxyNode && input instanceof LoopExitNode)) { - addToLatestSorting(b, (ScheduledNode) input, sortedInstructions, visited, reads, beforeLastLocation); + addToLatestSorting((ScheduledNode) input, state); } } } - if (memsched == MemoryScheduling.OPTIMAL && reads.size() != 0) { + if (memsched == MemoryScheduling.OPTIMAL && state.readsSize() != 0) { if (i instanceof MemoryCheckpoint.Single) { LocationIdentity identity = ((MemoryCheckpoint.Single) i).getLocationIdentity(); - processKillLocation(b, i, identity, sortedInstructions, visited, reads, beforeLastLocation); + processKillLocation(i, identity, state); } else if (i instanceof MemoryCheckpoint.Multi) { for (LocationIdentity identity : ((MemoryCheckpoint.Multi) i).getLocationIdentities()) { - processKillLocation(b, i, identity, sortedInstructions, visited, reads, beforeLastLocation); + processKillLocation(i, identity, state); } } assert MemoryCheckpoint.TypeAssertion.correctType(i); } - addToLatestSorting(b, (ScheduledNode) i.predecessor(), sortedInstructions, visited, reads, beforeLastLocation); - visited.mark(i); - addUnscheduledToLatestSorting(b, stateAfter, sortedInstructions, visited, reads, beforeLastLocation); + addToLatestSorting((ScheduledNode) i.predecessor(), state); + state.markVisited(i); + addUnscheduledToLatestSorting(stateAfter, state); // Now predecessors and inputs are scheduled => we can add this node. - if (!sortedInstructions.contains(i)) { - sortedInstructions.add(i); + if (!state.containsInstruction(i)) { + state.addInstruction(i); } - if (i instanceof FloatingReadNode) { - reads.remove(i); + if (state.readsSize() != 0 && i instanceof FloatingReadNode) { + state.removeRead(i); } } diff -r 746c0bda7ba6 -r 62f455eba8c5 mx/mx_graal.py --- a/mx/mx_graal.py Tue Apr 29 14:51:51 2014 +0200 +++ b/mx/mx_graal.py Tue Apr 29 16:16:27 2014 +0200 @@ -163,7 +163,7 @@ rmIfExists(mx.distribution('GRAAL').path) def export(args): - """create archives of builds splitted by vmbuild and vm""" + """create archives of builds split by vmbuild and vm""" parser = ArgumentParser(prog='mx export') args = parser.parse_args(args) @@ -174,8 +174,7 @@ hgcfg = mx.HgConfig() hgcfg.check() - infos['revision'] = hgcfg.tip('.') - infos['revision_dirty'] = hgcfg.isDirty('.') + infos['revision'] = hgcfg.tip('.') + ('+' if hgcfg.isDirty('.') else '') # TODO: infos['repository'] infos['jdkversion'] = str(mx.java().version) diff -r 746c0bda7ba6 -r 62f455eba8c5 mxtool/mx.py --- a/mxtool/mx.py Tue Apr 29 14:51:51 2014 +0200 +++ b/mxtool/mx.py Tue Apr 29 16:16:27 2014 +0200 @@ -3996,7 +3996,13 @@ try: log('Generating {2} for {0} in {1}'.format(p.name, out, docDir)) projectJava = java(p.javaCompliance) - run([projectJava.javadoc, memory, + + # Once https://bugs.openjdk.java.net/browse/JDK-8041628 is fixed, + # this should be reverted to: + # javadocExe = java().javadoc + javadocExe = projectJava.javadoc + + run([javadocExe, memory, '-XDignore.symbol.file', '-classpath', cp, '-quiet',