# HG changeset patch # User Bernhard Urban # Date 1398764429 -7200 # Node ID ab87fc35196bc76e982fecab21b7419a53315410 # Parent f8907fc0cbe61380c702a534ed74cd06612dafad SchedulePhase: use lazy init for worklist diff -r f8907fc0cbe6 -r ab87fc35196b 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 11:14:03 2014 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Tue Apr 29 11:40:29 2014 +0200 @@ -896,13 +896,16 @@ private List sortNodesWithinBlockLatest(Block b, NodeBitMap visited, NodeBitMap beforeLastLocation) { List instructions = blockToNodesMap.get(b); List sortedInstructions = new ArrayList<>(blockToNodesMap.get(b).size() + 2); - List reads = new ArrayList<>(); + List reads = null; if (memsched == MemoryScheduling.OPTIMAL) { for (ScheduledNode i : instructions) { if (i instanceof FloatingReadNode) { FloatingReadNode frn = (FloatingReadNode) i; if (frn.location().getLocationIdentity() != FINAL_LOCATION) { + if (reads == null) { + reads = new ArrayList<>(); + } reads.add(frn); if (nodesFor(b).contains(frn.getLastLocationAccess())) { assert !beforeLastLocation.isMarked(frn); @@ -915,7 +918,7 @@ for (ScheduledNode i : instructions) { addToLatestSorting(b, i, sortedInstructions, visited, reads, beforeLastLocation); } - assert reads.size() == 0 : "not all reads are scheduled"; + assert reads == null || reads.size() == 0 : "not all reads are scheduled"; // Make sure that last node gets really last (i.e. when a frame state successor hangs off // it). @@ -946,7 +949,7 @@ 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? + for (FloatingReadNode frn : new ArrayList<>(reads)) { LocationIdentity readLocation = frn.location().getLocationIdentity(); assert readLocation != FINAL_LOCATION; if (frn.getLastLocationAccess() == node) { @@ -1004,7 +1007,7 @@ } } - if (memsched == MemoryScheduling.OPTIMAL && reads.size() != 0) { + if (memsched == MemoryScheduling.OPTIMAL && reads != null) { if (i instanceof MemoryCheckpoint.Single) { LocationIdentity identity = ((MemoryCheckpoint.Single) i).getLocationIdentity(); processKillLocation(b, i, identity, sortedInstructions, visited, reads, beforeLastLocation);