Mercurial > hg > graal-compiler
annotate graal/GraalCompiler/src/com/sun/c1x/graph/IR.java @ 2791:6d14aa4fbf90
Gotos removed (except for exception dispatch chains and edge splitting).
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 25 May 2011 20:03:05 +0200 |
parents | aeccd2af4e9e |
children | 2af109bec0c0 |
rev | line source |
---|---|
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
1 /* |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
4 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
8 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
13 * accompanied this code). |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
14 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
18 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
21 * questions. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
22 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
23 package com.sun.c1x.graph; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
24 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
25 import java.util.*; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
26 |
2744
45a58c9536de
Added BFS node iteration. Started drafting scheduling.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2736
diff
changeset
|
27 import com.oracle.max.graal.schedule.*; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
28 import com.sun.c1x.*; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
29 import com.sun.c1x.debug.*; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
30 import com.sun.c1x.ir.*; |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2716
diff
changeset
|
31 import com.sun.c1x.lir.*; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
32 import com.sun.c1x.observer.*; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
33 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
34 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
35 * This class implements the overall container for the HIR (high-level IR) graph |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
36 * and directs its construction, optimization, and finalization. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
37 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
38 public class IR { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
39 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
40 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
41 * The compilation associated with this IR. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
42 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
43 public final C1XCompilation compilation; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
44 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
45 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
46 * The start block of this IR. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
47 */ |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2716
diff
changeset
|
48 public LIRBlock startBlock; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
49 |
2564
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
50 private int maxLocks; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
51 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
52 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
53 * The linear-scan ordered list of blocks. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
54 */ |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2716
diff
changeset
|
55 private List<LIRBlock> orderedBlocks; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
56 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
57 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
58 * Creates a new IR instance for the specified compilation. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
59 * @param compilation the compilation |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
60 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
61 public IR(C1XCompilation compilation) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
62 this.compilation = compilation; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
63 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
64 |
2759
b72e6638b9e6
Removed the link from BlockBegin to LIRBlock.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2756
diff
changeset
|
65 public Map<Value, LIRBlock> valueToBlock; |
b72e6638b9e6
Removed the link from BlockBegin to LIRBlock.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2756
diff
changeset
|
66 |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
67 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
68 * Builds the graph, optimizes it, and computes the linear scan block order. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
69 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
70 public void build() { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
71 if (C1XOptions.PrintTimers) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
72 C1XTimers.HIR_CREATE.start(); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
73 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
74 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
75 buildGraph(); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
76 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
77 if (C1XOptions.PrintTimers) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
78 C1XTimers.HIR_CREATE.stop(); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
79 C1XTimers.HIR_OPTIMIZE.start(); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
80 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
81 |
2744
45a58c9536de
Added BFS node iteration. Started drafting scheduling.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2736
diff
changeset
|
82 Schedule schedule = new Schedule(this.compilation.graph); |
2760
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
83 List<Block> blocks = schedule.getBlocks(); |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
84 List<LIRBlock> lirBlocks = new ArrayList<LIRBlock>(); |
2760
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
85 Map<Block, LIRBlock> map = new HashMap<Block, LIRBlock>(); |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
86 for (Block b : blocks) { |
2777
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
87 LIRBlock block = new LIRBlock(b.blockID()); |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
88 block.setExceptionEntry(b.isExceptionEntry()); |
2777
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
89 map.put(b, block); |
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
90 block.setInstructions(b.getInstructions()); |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
91 block.setLinearScanNumber(b.blockID()); |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
92 lirBlocks.add(block); |
2760
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
93 } |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
94 |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
95 for (Block b : blocks) { |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
96 for (Block succ : b.getSuccessors()) { |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
97 if (succ.isExceptionEntry()) { |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
98 map.get(b).getExceptionHandlerSuccessors().add(map.get(succ)); |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
99 } else { |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
100 map.get(b).blockSuccessors().add(map.get(succ)); |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
101 } |
2760
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
102 } |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
103 |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
104 for (Block pred : b.getPredecessors()) { |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
105 map.get(b).blockPredecessors().add(map.get(pred)); |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
106 } |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
107 } |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
108 |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
109 |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
110 // TODO(tw): Schedule nodes within a block. |
2779
93ec3f067420
Changed CriticalEdgeFinder to use LIRBlock.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2778
diff
changeset
|
111 |
93ec3f067420
Changed CriticalEdgeFinder to use LIRBlock.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2778
diff
changeset
|
112 |
93ec3f067420
Changed CriticalEdgeFinder to use LIRBlock.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2778
diff
changeset
|
113 CriticalEdgeFinder finder = new CriticalEdgeFinder(lirBlocks, compilation.graph); |
93ec3f067420
Changed CriticalEdgeFinder to use LIRBlock.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2778
diff
changeset
|
114 finder.splitCriticalEdges(); |
2760
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
115 |
2744
45a58c9536de
Added BFS node iteration. Started drafting scheduling.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2736
diff
changeset
|
116 |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
117 orderedBlocks = lirBlocks; |
2777
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
118 |
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
119 valueToBlock = new HashMap<Value, LIRBlock>(); |
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
120 for (LIRBlock b : orderedBlocks) { |
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
121 for (Instruction i : b.getInstructions()) { |
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
122 valueToBlock.put(i, b); |
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
123 } |
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
124 } |
2789
aeccd2af4e9e
Fixes around critical edge split and placeholder removal after goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2788
diff
changeset
|
125 startBlock = lirBlocks.get(0); |
2777
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
126 assert startBlock != null; |
2789
aeccd2af4e9e
Fixes around critical edge split and placeholder removal after goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2788
diff
changeset
|
127 assert startBlock.blockPredecessors().size() == 0; |
2788
df4c5254c5cc
Towards goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2783
diff
changeset
|
128 |
2789
aeccd2af4e9e
Fixes around critical edge split and placeholder removal after goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2788
diff
changeset
|
129 /* if (startBlock.blockPredecessors().size() > 0) { |
2788
df4c5254c5cc
Towards goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2783
diff
changeset
|
130 LIRBlock oldStartBlock = startBlock; |
df4c5254c5cc
Towards goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2783
diff
changeset
|
131 startBlock = new LIRBlock(orderedBlocks.size()); |
df4c5254c5cc
Towards goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2783
diff
changeset
|
132 startBlock.blockSuccessors().add(oldStartBlock); |
2789
aeccd2af4e9e
Fixes around critical edge split and placeholder removal after goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2788
diff
changeset
|
133 |
2788
df4c5254c5cc
Towards goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2783
diff
changeset
|
134 orderedBlocks.add(startBlock); |
2789
aeccd2af4e9e
Fixes around critical edge split and placeholder removal after goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2788
diff
changeset
|
135 }*/ |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
136 |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
137 ComputeLinearScanOrder clso = new ComputeLinearScanOrder(lirBlocks.size(), startBlock); |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
138 orderedBlocks = clso.linearScanOrder(); |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
139 this.compilation.stats.loopCount = clso.numLoops(); |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
140 |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
141 int z = 0; |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
142 for (LIRBlock b : orderedBlocks) { |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
143 b.setLinearScanNumber(z++); |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
144 } |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
145 |
2788
df4c5254c5cc
Towards goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2783
diff
changeset
|
146 verifyAndPrint("After linear scan order"); |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
147 |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
148 if (C1XOptions.PrintTimers) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
149 C1XTimers.HIR_OPTIMIZE.stop(); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
150 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
151 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
152 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
153 private void buildGraph() { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
154 // Graph builder must set the startBlock and the osrEntryBlock |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2602
diff
changeset
|
155 new GraphBuilder(compilation, this, compilation.graph).build(); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
156 verifyAndPrint("After graph building"); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
157 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
158 if (C1XOptions.PrintCompilation) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
159 TTY.print(String.format("%3d blocks | ", this.numberOfBlocks())); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
160 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
161 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
162 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
163 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
164 * Gets the linear scan ordering of blocks as a list. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
165 * @return the blocks in linear scan order |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
166 */ |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2716
diff
changeset
|
167 public List<LIRBlock> linearScanOrder() { |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
168 return orderedBlocks; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
169 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
170 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
171 private void print(boolean cfgOnly) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
172 if (!TTY.isSuppressed()) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
173 TTY.println("IR for " + compilation.method); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
174 final InstructionPrinter ip = new InstructionPrinter(TTY.out()); |
2546
e1b3db8031ee
Removed liveness marking.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2531
diff
changeset
|
175 final BlockPrinter bp = new BlockPrinter(this, ip, cfgOnly); |
2783
9bc0c2eb00d6
Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2782
diff
changeset
|
176 //getHIRStartBlock().iteratePreOrder(bp); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
177 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
178 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
179 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
180 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
181 * Verifies the IR and prints it out if the relevant options are set. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
182 * @param phase the name of the phase for printing |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
183 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
184 public void verifyAndPrint(String phase) { |
2653
7c8ad40c1f88
No need for stateAfter on volatile field loads.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2616
diff
changeset
|
185 if (C1XOptions.PrintHIR && !TTY.isSuppressed()) { |
7c8ad40c1f88
No need for stateAfter on volatile field loads.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2616
diff
changeset
|
186 TTY.println(phase); |
7c8ad40c1f88
No need for stateAfter on volatile field loads.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2616
diff
changeset
|
187 print(false); |
7c8ad40c1f88
No need for stateAfter on volatile field loads.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2616
diff
changeset
|
188 } |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
189 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
190 if (compilation.compiler.isObserved()) { |
2719
ae1c50a03297
Fixed regression.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2718
diff
changeset
|
191 compilation.compiler.fireCompilationEvent(new CompilationEvent(compilation, phase, getHIRStartBlock(), true, false)); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
192 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
193 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
194 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
195 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
196 public int nextBlockNumber() { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
197 return compilation.stats.blockCount++; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
198 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
199 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
200 public int numberOfBlocks() { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
201 return compilation.stats.blockCount; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
202 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
203 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
204 public int numLoops() { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
205 return compilation.stats.loopCount; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
206 } |
2564
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
207 |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
208 /** |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
209 * Updates the maximum number of locks held at any one time. |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
210 * |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
211 * @param locks a lock count that will replace the current {@linkplain #maxLocks() max locks} if it is greater |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
212 */ |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
213 public void updateMaxLocks(int locks) { |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
214 if (locks > maxLocks) { |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
215 maxLocks = locks; |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
216 } |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
217 } |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
218 |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
219 /** |
2592
fec99fc30af1
checkstyle fixes, updated AccessArray + subclasses
Lukas Stadler <lukas.stadler@jku.at>
parents:
2582
diff
changeset
|
220 * Gets the number of locks. |
2564
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
221 * @return the number of locks |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
222 */ |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
223 public final int maxLocks() { |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
224 return maxLocks; |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
225 } |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2716
diff
changeset
|
226 |
2781
bda5972a40a5
remove unnecessary BlockBegin nodes in frontend
Lukas Stadler <lukas.stadler@jku.at>
parents:
2776
diff
changeset
|
227 public Instruction getHIRStartBlock() { |
bda5972a40a5
remove unnecessary BlockBegin nodes in frontend
Lukas Stadler <lukas.stadler@jku.at>
parents:
2776
diff
changeset
|
228 return (Instruction) compilation.graph.start().successors().get(0); |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2716
diff
changeset
|
229 } |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
230 } |