Mercurial > hg > truffle
comparison graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java @ 2674:6ab73784566a
* BlockBegin.predecessors changed to List<BlockEnd>
* Node: add input/successor with given back edge index, allows for explicit ordering of predecessors/usages
* Graphviz: PDF output, option to omit FrameStates
* runscimark.sh: forward additional options to JVM
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Fri, 13 May 2011 15:18:41 +0200 |
parents | b2c1e959be46 |
children | 0ea5f12e873a |
comparison
equal
deleted
inserted
replaced
2673:98447ab8bd83 | 2674:6ab73784566a |
---|---|
74 BlockEnd old = this.end(); | 74 BlockEnd old = this.end(); |
75 if (old != end) { | 75 if (old != end) { |
76 if (old != null) { | 76 if (old != null) { |
77 // disconnect this block from its current successors | 77 // disconnect this block from its current successors |
78 for (BlockBegin s : old.blockSuccessors()) { | 78 for (BlockBegin s : old.blockSuccessors()) { |
79 s.blockPredecessors().remove(this); | 79 s.blockPredecessors().remove(this.end()); |
80 } | 80 } |
81 } | 81 } |
82 successors().set(super.successorCount() + SUCCESSOR_END, end); | 82 successors().set(super.successorCount() + SUCCESSOR_END, end); |
83 for (BlockBegin s : end.blockSuccessors()) { | 83 for (BlockBegin s : end.blockSuccessors()) { |
84 s.addPredecessor(this); | 84 s.addPredecessor(end); |
85 } | 85 } |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 private static final List<BlockBegin> NO_HANDLERS = Collections.emptyList(); | 89 private static final List<BlockBegin> NO_HANDLERS = Collections.emptyList(); |
118 private int blockFlags; | 118 private int blockFlags; |
119 | 119 |
120 /** | 120 /** |
121 * The {@link BlockBegin} nodes for which this node is a successor. | 121 * The {@link BlockBegin} nodes for which this node is a successor. |
122 */ | 122 */ |
123 private final List<BlockBegin> predecessors; | 123 private final List<BlockEnd> predecessors; |
124 | 124 |
125 private int depthFirstNumber; | 125 private int depthFirstNumber; |
126 private int linearScanNumber; | 126 private int linearScanNumber; |
127 private int loopDepth; | 127 private int loopDepth; |
128 private int loopIndex; | 128 private int loopIndex; |
143 public BlockBegin(int bci, int blockID, Graph graph) { | 143 public BlockBegin(int bci, int blockID, Graph graph) { |
144 super(CiKind.Illegal, INPUT_COUNT, SUCCESSOR_COUNT, graph); | 144 super(CiKind.Illegal, INPUT_COUNT, SUCCESSOR_COUNT, graph); |
145 this.blockID = blockID; | 145 this.blockID = blockID; |
146 depthFirstNumber = -1; | 146 depthFirstNumber = -1; |
147 linearScanNumber = -1; | 147 linearScanNumber = -1; |
148 predecessors = new ArrayList<BlockBegin>(2); | 148 predecessors = new ArrayList<BlockEnd>(2); |
149 loopIndex = -1; | 149 loopIndex = -1; |
150 setBCI(bci); | 150 setBCI(bci); |
151 } | 151 } |
152 | 152 |
153 /** | 153 /** |
154 * Gets the list of predecessors of this block. | 154 * Gets the list of predecessors of this block. |
155 * @return the predecessor list | 155 * @return the predecessor list |
156 */ | 156 */ |
157 public List<BlockBegin> blockPredecessors() { | 157 public List<BlockEnd> blockPredecessors() { |
158 return predecessors; | 158 // return Collections.unmodifiableList(predecessors); |
159 return predecessors; | |
159 } | 160 } |
160 | 161 |
161 /** | 162 /** |
162 * Gets the dominator of this block. | 163 * Gets the dominator of this block. |
163 * @return the dominator block | 164 * @return the dominator block |
287 BlockBegin block; | 288 BlockBegin block; |
288 while ((block = queue.poll()) != null) { | 289 while ((block = queue.poll()) != null) { |
289 closure.apply(block); | 290 closure.apply(block); |
290 queueBlocks(queue, block.exceptionHandlerBlocks(), mark); | 291 queueBlocks(queue, block.exceptionHandlerBlocks(), mark); |
291 queueBlocks(queue, block.end().blockSuccessors(), mark); | 292 queueBlocks(queue, block.end().blockSuccessors(), mark); |
292 queueBlocks(queue, predecessors ? block.predecessors : null, mark); | 293 if (predecessors) { |
294 queueBlockEnds(queue, block.predecessors, mark); | |
295 } | |
293 } | 296 } |
294 } | 297 } |
295 | 298 |
296 private void queueBlocks(LinkedList<BlockBegin> queue, List<BlockBegin> list, IdentityHashMap<BlockBegin, BlockBegin> mark) { | 299 private void queueBlocks(LinkedList<BlockBegin> queue, List<BlockBegin> list, IdentityHashMap<BlockBegin, BlockBegin> mark) { |
297 if (list != null) { | 300 if (list != null) { |
298 for (BlockBegin b : list) { | 301 for (BlockBegin b : list) { |
302 if (!mark.containsKey(b)) { | |
303 queue.offer(b); | |
304 mark.put(b, b); | |
305 } | |
306 } | |
307 } | |
308 } | |
309 | |
310 private void queueBlockEnds(LinkedList<BlockBegin> queue, List<BlockEnd> list, IdentityHashMap<BlockBegin, BlockBegin> mark) { | |
311 if (list != null) { | |
312 for (BlockEnd end : list) { | |
313 BlockBegin b = end.begin(); | |
299 if (!mark.containsKey(b)) { | 314 if (!mark.containsKey(b)) { |
300 queue.offer(b); | 315 queue.offer(b); |
301 mark.put(b, b); | 316 mark.put(b, b); |
302 } | 317 } |
303 } | 318 } |
357 | 372 |
358 /** | 373 /** |
359 * Add a predecessor to this block. | 374 * Add a predecessor to this block. |
360 * @param pred the predecessor to add | 375 * @param pred the predecessor to add |
361 */ | 376 */ |
362 public void addPredecessor(BlockBegin pred) { | 377 public void addPredecessor(BlockEnd pred) { |
378 assert pred != null; | |
363 predecessors.add(pred); | 379 predecessors.add(pred); |
364 } | 380 } |
365 | 381 |
366 /** | 382 /** |
367 * Removes all occurrences of the specified block from the predecessor list of this block. | 383 * Removes all occurrences of the specified block from the predecessor list of this block. |
368 * @param pred the predecessor to remove | 384 * @param pred the predecessor to remove |
369 */ | 385 */ |
370 public void removePredecessor(BlockBegin pred) { | 386 public void removePredecessor(BlockEnd pred) { |
371 while (predecessors.remove(pred)) { | 387 while (predecessors.remove(pred)) { |
372 // the block may appear multiple times in the list | 388 // the block may appear multiple times in the list |
373 // XXX: this is not very efficient, consider Util.removeAllFromList | 389 // XXX: this is not very efficient, consider Util.removeAllFromList |
374 } | 390 } |
375 } | 391 } |
601 /** | 617 /** |
602 * Get the number of predecessors. | 618 * Get the number of predecessors. |
603 * @return the number of predecessors | 619 * @return the number of predecessors |
604 */ | 620 */ |
605 public int numberOfPreds() { | 621 public int numberOfPreds() { |
622 // assert predecessors.size() == predecessors().size(); | |
606 return predecessors.size(); | 623 return predecessors.size(); |
607 } | 624 } |
608 | 625 |
609 /** | 626 /** |
610 * @return the label associated with the block, used by the LIR | 627 * @return the label associated with the block, used by the LIR |
642 | 659 |
643 public BlockBegin exceptionHandlerAt(int i) { | 660 public BlockBegin exceptionHandlerAt(int i) { |
644 return exceptionHandlerBlocks.get(i); | 661 return exceptionHandlerBlocks.get(i); |
645 } | 662 } |
646 | 663 |
647 public BlockBegin predAt(int j) { | 664 public BlockEnd predAt(int j) { |
665 // assert predecessors.get(j) == predecessors().get(j); | |
648 return predecessors.get(j); | 666 return predecessors.get(j); |
649 } | 667 } |
650 | 668 |
651 public int firstLirInstructionId() { | 669 public int firstLirInstructionId() { |
652 return lirBlock.firstLirInstructionID; | 670 return lirBlock.firstLirInstructionID; |
662 | 680 |
663 public void setLastLirInstructionId(int lastLirInstructionId) { | 681 public void setLastLirInstructionId(int lastLirInstructionId) { |
664 lirBlock.lastLirInstructionID = lastLirInstructionId; | 682 lirBlock.lastLirInstructionID = lastLirInstructionId; |
665 } | 683 } |
666 | 684 |
667 public boolean isPredecessor(BlockBegin block) { | 685 public boolean isPredecessor(BlockEnd block) { |
668 return this.predecessors.contains(block); | 686 // assert predecessors.contains(block) == predecessors().contains(block); |
687 return predecessors.contains(block); | |
669 } | 688 } |
670 | 689 |
671 public void printWithoutPhis(LogStream out) { | 690 public void printWithoutPhis(LogStream out) { |
672 // print block id | 691 // print block id |
673 BlockEnd end = end(); | 692 BlockEnd end = end(); |
719 } | 738 } |
720 | 739 |
721 // print predecessors | 740 // print predecessors |
722 if (!blockPredecessors().isEmpty()) { | 741 if (!blockPredecessors().isEmpty()) { |
723 out.print(" pred:"); | 742 out.print(" pred:"); |
724 for (BlockBegin pred : blockPredecessors()) { | 743 for (BlockEnd pred : blockPredecessors()) { |
725 out.print(" B").print(pred.blockID); | 744 out.print(" B").print(pred.begin().blockID); |
726 } | 745 } |
727 } | 746 } |
728 } | 747 } |
729 | 748 |
730 @Override | 749 @Override |
847 if (value != null && value.hasSubst()) { | 866 if (value != null && value.hasSubst()) { |
848 sb.append("alias ").append(Util.valueString(value.subst())); | 867 sb.append("alias ").append(Util.valueString(value.subst())); |
849 } | 868 } |
850 return sb.toString(); | 869 return sb.toString(); |
851 } | 870 } |
871 | |
872 @Override | |
873 public String shortName() { | |
874 return "BlockBegin #" + blockID; | |
875 } | |
876 | |
877 | |
852 } | 878 } |