Mercurial > hg > truffle
annotate graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java @ 3011:f00918f35c7f
inlining and runtime interface related changes:
added codeSize() and compilerStorage() to RiMethod
HotSpotMethodResolved uses reflective methods instead of vmIds and survives compilations
HotSpotResolvedType.isInitialized not represented as field (can change)
inlining stores graphs into method objects and reuses them
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Thu, 16 Jun 2011 20:36:17 +0200 |
parents | c6b89544fef5 |
children | 5ee0f57bb18c |
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 */ |
2874
d90bf514d647
Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2872
diff
changeset
|
23 package com.oracle.max.graal.compiler.graph; |
2507
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 |
2874
d90bf514d647
Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2872
diff
changeset
|
27 import com.oracle.max.graal.compiler.*; |
d90bf514d647
Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2872
diff
changeset
|
28 import com.oracle.max.graal.compiler.ir.*; |
d90bf514d647
Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2872
diff
changeset
|
29 import com.oracle.max.graal.compiler.lir.*; |
d90bf514d647
Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2872
diff
changeset
|
30 import com.oracle.max.graal.compiler.observer.*; |
2879
7f584bf507ed
Renamed and moved phase subclasses.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2875
diff
changeset
|
31 import com.oracle.max.graal.compiler.phases.*; |
2874
d90bf514d647
Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2872
diff
changeset
|
32 import com.oracle.max.graal.compiler.schedule.*; |
d90bf514d647
Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2872
diff
changeset
|
33 import com.oracle.max.graal.compiler.value.*; |
d90bf514d647
Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2872
diff
changeset
|
34 import com.oracle.max.graal.graph.*; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
35 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
36 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
37 * 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
|
38 * and directs its construction, optimization, and finalization. |
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 public class IR { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
41 |
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 * The compilation associated with this IR. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
44 */ |
2888
224412c24426
Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2887
diff
changeset
|
45 public final GraalCompilation compilation; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
46 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
47 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
48 * The start block of this IR. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
49 */ |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2716
diff
changeset
|
50 public LIRBlock startBlock; |
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 */ |
2888
224412c24426
Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2887
diff
changeset
|
61 public IR(GraalCompilation compilation) { |
2507
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 |
2801
2af109bec0c0
Make block contains a list of nodes instead a list of instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2789
diff
changeset
|
65 public Map<Node, LIRBlock> valueToBlock; |
2759
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() { |
3011
f00918f35c7f
inlining and runtime interface related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2992
diff
changeset
|
71 |
f00918f35c7f
inlining and runtime interface related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2992
diff
changeset
|
72 // Object stored = compilation.method.compilerStorage().get(CompilerGraph.class); |
f00918f35c7f
inlining and runtime interface related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2992
diff
changeset
|
73 // if (stored != null) { |
f00918f35c7f
inlining and runtime interface related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2992
diff
changeset
|
74 // Map<Node, Node> replacements = new HashMap<Node, Node>(); |
f00918f35c7f
inlining and runtime interface related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2992
diff
changeset
|
75 // CompilerGraph duplicate = (CompilerGraph) stored; |
f00918f35c7f
inlining and runtime interface related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2992
diff
changeset
|
76 // replacements.put(duplicate.start(), compilation.graph.start()); |
f00918f35c7f
inlining and runtime interface related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2992
diff
changeset
|
77 // compilation.graph.addDuplicate(duplicate.getNodes(), replacements); |
f00918f35c7f
inlining and runtime interface related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2992
diff
changeset
|
78 // } else { |
f00918f35c7f
inlining and runtime interface related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2992
diff
changeset
|
79 new GraphBuilderPhase(compilation, compilation.method, false, false).apply(compilation.graph); |
f00918f35c7f
inlining and runtime interface related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2992
diff
changeset
|
80 // } |
2960
49a8b14e9d24
Tentative change that adds successor tags.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2948
diff
changeset
|
81 |
2981
42681ed31c4d
Some LoopCounter work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2948
diff
changeset
|
82 //printGraph("After GraphBuilding", compilation.graph); |
2953
445233cd91df
added GraalOptions.TestGraphDuplication, fixed graph duplication
Lukas Stadler <lukas.stadler@jku.at>
parents:
2948
diff
changeset
|
83 |
445233cd91df
added GraalOptions.TestGraphDuplication, fixed graph duplication
Lukas Stadler <lukas.stadler@jku.at>
parents:
2948
diff
changeset
|
84 if (GraalOptions.TestGraphDuplication) { |
445233cd91df
added GraalOptions.TestGraphDuplication, fixed graph duplication
Lukas Stadler <lukas.stadler@jku.at>
parents:
2948
diff
changeset
|
85 new DuplicationPhase().apply(compilation.graph); |
2984 | 86 //printGraph("After Duplication", compilation.graph); |
2953
445233cd91df
added GraalOptions.TestGraphDuplication, fixed graph duplication
Lukas Stadler <lukas.stadler@jku.at>
parents:
2948
diff
changeset
|
87 } |
445233cd91df
added GraalOptions.TestGraphDuplication, fixed graph duplication
Lukas Stadler <lukas.stadler@jku.at>
parents:
2948
diff
changeset
|
88 |
2886
c3b8968233fa
Removed counting of deleted nodes for each phase.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2883
diff
changeset
|
89 new DeadCodeEliminationPhase().apply(compilation.graph); |
2981
42681ed31c4d
Some LoopCounter work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2948
diff
changeset
|
90 //printGraph("After DeadCodeElimination", compilation.graph); |
2886
c3b8968233fa
Removed counting of deleted nodes for each phase.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2883
diff
changeset
|
91 |
2888
224412c24426
Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2887
diff
changeset
|
92 if (GraalOptions.Inline) { |
2911 | 93 new InliningPhase(compilation, this, GraalOptions.TraceInlining).apply(compilation.graph); |
2981
42681ed31c4d
Some LoopCounter work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2948
diff
changeset
|
94 //printGraph("After Ininling", compilation.graph); |
2886
c3b8968233fa
Removed counting of deleted nodes for each phase.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2883
diff
changeset
|
95 } |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
96 |
2901
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2895
diff
changeset
|
97 if (GraalOptions.Time) { |
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2895
diff
changeset
|
98 GraalTimers.COMPUTE_LINEAR_SCAN_ORDER.start(); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
99 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
100 |
2838
adc4b3ec0a8c
Deleted LIR critical edge splitter and replaced with GraalIR edge splitter using Anchor nodes (=> simpler).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2835
diff
changeset
|
101 Graph graph = compilation.graph; |
adc4b3ec0a8c
Deleted LIR critical edge splitter and replaced with GraalIR edge splitter using Anchor nodes (=> simpler).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2835
diff
changeset
|
102 |
2888
224412c24426
Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2887
diff
changeset
|
103 if (GraalOptions.OptCanonicalizer) { |
2863
4f64bd98f9dc
Canonicalization work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2858
diff
changeset
|
104 new CanonicalizerPhase().apply(graph); |
2938
c7783b6773ea
fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents:
2932
diff
changeset
|
105 new DeadCodeEliminationPhase().apply(compilation.graph); |
2992
c6b89544fef5
Fix scheduling around loopcounters
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2984
diff
changeset
|
106 //printGraph("After Canonicalization", graph); |
2863
4f64bd98f9dc
Canonicalization work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2858
diff
changeset
|
107 } |
4f64bd98f9dc
Canonicalization work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2858
diff
changeset
|
108 |
2981
42681ed31c4d
Some LoopCounter work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2948
diff
changeset
|
109 new LoopPhase().apply(graph); |
42681ed31c4d
Some LoopCounter work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2948
diff
changeset
|
110 |
2945
41318fcb6b56
Added two algorithms for identifying Java-level blocks.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2919
diff
changeset
|
111 new LoweringPhase().apply(graph); |
41318fcb6b56
Added two algorithms for identifying Java-level blocks.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2919
diff
changeset
|
112 |
41318fcb6b56
Added two algorithms for identifying Java-level blocks.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2919
diff
changeset
|
113 IdentifyBlocksPhase schedule = new IdentifyBlocksPhase(true); |
2895
5fd2b31f50ee
Schedule now inherits Phase.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2888
diff
changeset
|
114 schedule.apply(graph); |
2901
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2895
diff
changeset
|
115 |
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2895
diff
changeset
|
116 |
2760
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
117 List<Block> blocks = schedule.getBlocks(); |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
118 List<LIRBlock> lirBlocks = new ArrayList<LIRBlock>(); |
2760
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
119 Map<Block, LIRBlock> map = new HashMap<Block, LIRBlock>(); |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
120 for (Block b : blocks) { |
2777
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
121 LIRBlock block = new LIRBlock(b.blockID()); |
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
122 map.put(b, block); |
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
123 block.setInstructions(b.getInstructions()); |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
124 block.setLinearScanNumber(b.blockID()); |
2805
c3f64b66fc78
Towards removing the next pointer from Constant and ArithmeticOp
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2801
diff
changeset
|
125 |
c3f64b66fc78
Towards removing the next pointer from Constant and ArithmeticOp
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2801
diff
changeset
|
126 block.setFirstInstruction(b.firstNode()); |
c3f64b66fc78
Towards removing the next pointer from Constant and ArithmeticOp
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2801
diff
changeset
|
127 block.setLastInstruction(b.lastNode()); |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
128 lirBlocks.add(block); |
2760
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
129 } |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
130 |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
131 for (Block b : blocks) { |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
132 for (Block succ : b.getSuccessors()) { |
2833
1cd59ca9ac86
Removed Throw HIR instruction. Removed special handling for exceptions in register allocator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2832
diff
changeset
|
133 map.get(b).blockSuccessors().add(map.get(succ)); |
2760
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
134 } |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
135 |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
136 for (Block pred : b.getPredecessors()) { |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
137 map.get(b).blockPredecessors().add(map.get(pred)); |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
138 } |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
139 } |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
140 |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
141 orderedBlocks = lirBlocks; |
2801
2af109bec0c0
Make block contains a list of nodes instead a list of instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2789
diff
changeset
|
142 valueToBlock = new HashMap<Node, LIRBlock>(); |
2777
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
143 for (LIRBlock b : orderedBlocks) { |
2801
2af109bec0c0
Make block contains a list of nodes instead a list of instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2789
diff
changeset
|
144 for (Node i : b.getInstructions()) { |
2777
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
145 valueToBlock.put(i, b); |
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
146 } |
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
147 } |
2967
60a58915c94d
Removed next pointer from EndNode to Merge. New scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2965
diff
changeset
|
148 startBlock = valueToBlock.get(graph.start()); |
2777
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
149 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
|
150 assert startBlock.blockPredecessors().size() == 0; |
2788
df4c5254c5cc
Towards goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2783
diff
changeset
|
151 |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
152 ComputeLinearScanOrder clso = new ComputeLinearScanOrder(lirBlocks.size(), startBlock); |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
153 orderedBlocks = clso.linearScanOrder(); |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
154 this.compilation.stats.loopCount = clso.numLoops(); |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
155 |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
156 int z = 0; |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
157 for (LIRBlock b : orderedBlocks) { |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
158 b.setLinearScanNumber(z++); |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
159 } |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
160 |
2901
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2895
diff
changeset
|
161 printGraph("After linear scan order", compilation.graph); |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
162 |
2901
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2895
diff
changeset
|
163 if (GraalOptions.Time) { |
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2895
diff
changeset
|
164 GraalTimers.COMPUTE_LINEAR_SCAN_ORDER.stop(); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
165 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
166 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
167 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
168 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
169 * 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
|
170 * @return the blocks in linear scan order |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
171 */ |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2716
diff
changeset
|
172 public List<LIRBlock> linearScanOrder() { |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
173 return orderedBlocks; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
174 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
175 |
2866
7f14e6b48a9c
added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
2842
diff
changeset
|
176 public void printGraph(String phase, Graph graph) { |
7f14e6b48a9c
added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
2842
diff
changeset
|
177 if (compilation.compiler.isObserved()) { |
7f14e6b48a9c
added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
2842
diff
changeset
|
178 compilation.compiler.fireCompilationEvent(new CompilationEvent(compilation, phase, graph, true, false)); |
7f14e6b48a9c
added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
2842
diff
changeset
|
179 } |
7f14e6b48a9c
added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
2842
diff
changeset
|
180 } |
7f14e6b48a9c
added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
2842
diff
changeset
|
181 |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
182 public int numLoops() { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
183 return compilation.stats.loopCount; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
184 } |
2564
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
185 |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
186 /** |
2840
75e0d39833a0
new CompilerGraph, create only one Return and one Unwind per CompilerGraph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2835
diff
changeset
|
187 * Gets the maximum number of locks in the graph's frame states. |
2564
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
188 */ |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
189 public final int maxLocks() { |
2840
75e0d39833a0
new CompilerGraph, create only one Return and one Unwind per CompilerGraph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2835
diff
changeset
|
190 int maxLocks = 0; |
75e0d39833a0
new CompilerGraph, create only one Return and one Unwind per CompilerGraph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2835
diff
changeset
|
191 for (Node node : compilation.graph.getNodes()) { |
75e0d39833a0
new CompilerGraph, create only one Return and one Unwind per CompilerGraph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2835
diff
changeset
|
192 if (node instanceof FrameState) { |
2910
7eec76f3e39e
adjust monitor index while inlining, renamed NodeWorklist to NodeFlood
Lukas Stadler <lukas.stadler@jku.at>
parents:
2883
diff
changeset
|
193 FrameState current = (FrameState) node; |
7eec76f3e39e
adjust monitor index while inlining, renamed NodeWorklist to NodeFlood
Lukas Stadler <lukas.stadler@jku.at>
parents:
2883
diff
changeset
|
194 int lockCount = 0; |
7eec76f3e39e
adjust monitor index while inlining, renamed NodeWorklist to NodeFlood
Lukas Stadler <lukas.stadler@jku.at>
parents:
2883
diff
changeset
|
195 while (current != null) { |
7eec76f3e39e
adjust monitor index while inlining, renamed NodeWorklist to NodeFlood
Lukas Stadler <lukas.stadler@jku.at>
parents:
2883
diff
changeset
|
196 lockCount += current.locksSize(); |
7eec76f3e39e
adjust monitor index while inlining, renamed NodeWorklist to NodeFlood
Lukas Stadler <lukas.stadler@jku.at>
parents:
2883
diff
changeset
|
197 current = current.outerFrameState(); |
7eec76f3e39e
adjust monitor index while inlining, renamed NodeWorklist to NodeFlood
Lukas Stadler <lukas.stadler@jku.at>
parents:
2883
diff
changeset
|
198 } |
2840
75e0d39833a0
new CompilerGraph, create only one Return and one Unwind per CompilerGraph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2835
diff
changeset
|
199 if (lockCount > maxLocks) { |
75e0d39833a0
new CompilerGraph, create only one Return and one Unwind per CompilerGraph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2835
diff
changeset
|
200 maxLocks = lockCount; |
75e0d39833a0
new CompilerGraph, create only one Return and one Unwind per CompilerGraph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2835
diff
changeset
|
201 } |
75e0d39833a0
new CompilerGraph, create only one Return and one Unwind per CompilerGraph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2835
diff
changeset
|
202 } |
75e0d39833a0
new CompilerGraph, create only one Return and one Unwind per CompilerGraph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2835
diff
changeset
|
203 } |
2564
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
204 return maxLocks; |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
205 } |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2716
diff
changeset
|
206 |
2781
bda5972a40a5
remove unnecessary BlockBegin nodes in frontend
Lukas Stadler <lukas.stadler@jku.at>
parents:
2776
diff
changeset
|
207 public Instruction getHIRStartBlock() { |
bda5972a40a5
remove unnecessary BlockBegin nodes in frontend
Lukas Stadler <lukas.stadler@jku.at>
parents:
2776
diff
changeset
|
208 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
|
209 } |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
210 } |