Mercurial > hg > truffle
annotate graal/GraalCompiler/src/com/sun/c1x/graph/IR.java @ 2863:4f64bd98f9dc
Canonicalization work
author | Gilles Duboscq <gilles.duboscq@oracle.com> |
---|---|
date | Tue, 07 Jun 2011 17:04:55 +0200 |
parents | a97605b0489b |
children | fc75fd3fa5e4 |
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 |
2842
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
25 import java.lang.reflect.*; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
26 import java.util.*; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
27 |
2801
2af109bec0c0
Make block contains a list of nodes instead a list of instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2789
diff
changeset
|
28 import com.oracle.graal.graph.*; |
2863
4f64bd98f9dc
Canonicalization work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2858
diff
changeset
|
29 import com.oracle.max.graal.opt.*; |
2744
45a58c9536de
Added BFS node iteration. Started drafting scheduling.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2736
diff
changeset
|
30 import com.oracle.max.graal.schedule.*; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
31 import com.sun.c1x.*; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
32 import com.sun.c1x.debug.*; |
2807
50b5db2c3e68
Fix for degenerated phis. Now jtt and DaCapo/fop passes with ArithmeticOp and Constant being flexible in the graph.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2805
diff
changeset
|
33 import com.sun.c1x.gen.*; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
34 import com.sun.c1x.ir.*; |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2716
diff
changeset
|
35 import com.sun.c1x.lir.*; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
36 import com.sun.c1x.observer.*; |
2840
75e0d39833a0
new CompilerGraph, create only one Return and one Unwind per CompilerGraph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2835
diff
changeset
|
37 import com.sun.c1x.value.*; |
2842
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
38 import com.sun.cri.ci.*; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
39 import com.sun.cri.ri.*; |
2507
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 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
42 * 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
|
43 * and directs its construction, optimization, and finalization. |
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 public class IR { |
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 compilation associated with this IR. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
49 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
50 public final C1XCompilation compilation; |
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 start block of this IR. |
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 public LIRBlock startBlock; |
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 * The linear-scan ordered list of blocks. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
59 */ |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2716
diff
changeset
|
60 private List<LIRBlock> orderedBlocks; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
61 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
62 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
63 * 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
|
64 * @param compilation the compilation |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
65 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
66 public IR(C1XCompilation compilation) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
67 this.compilation = compilation; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
68 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
69 |
2801
2af109bec0c0
Make block contains a list of nodes instead a list of instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2789
diff
changeset
|
70 public Map<Node, LIRBlock> valueToBlock; |
2759
b72e6638b9e6
Removed the link from BlockBegin to LIRBlock.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2756
diff
changeset
|
71 |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
72 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
73 * 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
|
74 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
75 public void build() { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
76 if (C1XOptions.PrintTimers) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
77 C1XTimers.HIR_CREATE.start(); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
78 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
79 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
80 buildGraph(); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
81 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
82 if (C1XOptions.PrintTimers) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
83 C1XTimers.HIR_CREATE.stop(); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
84 C1XTimers.HIR_OPTIMIZE.start(); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
85 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
86 |
2807
50b5db2c3e68
Fix for degenerated phis. Now jtt and DaCapo/fop passes with ArithmeticOp and Constant being flexible in the graph.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2805
diff
changeset
|
87 new PhiSimplifier(this); |
2834
bfce42cd9c07
Graph duplication now passes all tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
2827
diff
changeset
|
88 |
2863
4f64bd98f9dc
Canonicalization work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2858
diff
changeset
|
89 |
2834
bfce42cd9c07
Graph duplication now passes all tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
2827
diff
changeset
|
90 // Graph newGraph = new Graph(); |
bfce42cd9c07
Graph duplication now passes all tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
2827
diff
changeset
|
91 // HashMap<Node, Node> replacement = new HashMap<Node, Node>(); |
bfce42cd9c07
Graph duplication now passes all tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
2827
diff
changeset
|
92 // replacement.put(compilation.graph.start(), newGraph.start()); |
bfce42cd9c07
Graph duplication now passes all tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
2827
diff
changeset
|
93 // replacement.put(compilation.graph.end(), newGraph.end()); |
bfce42cd9c07
Graph duplication now passes all tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
2827
diff
changeset
|
94 // newGraph.addDuplicate(compilation.graph.getNodes(), replacement); |
bfce42cd9c07
Graph duplication now passes all tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
2827
diff
changeset
|
95 // compilation.graph = newGraph; |
bfce42cd9c07
Graph duplication now passes all tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
2827
diff
changeset
|
96 |
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
|
97 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
|
98 |
2863
4f64bd98f9dc
Canonicalization work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2858
diff
changeset
|
99 if (C1XOptions.OptCanonicalizer) { |
4f64bd98f9dc
Canonicalization work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2858
diff
changeset
|
100 new CanonicalizerPhase().apply(graph); |
4f64bd98f9dc
Canonicalization work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2858
diff
changeset
|
101 verifyAndPrint("After canonicalization"); |
4f64bd98f9dc
Canonicalization work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2858
diff
changeset
|
102 } |
4f64bd98f9dc
Canonicalization work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2858
diff
changeset
|
103 |
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
|
104 // Split critical edges. |
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
|
105 List<Node> nodes = graph.getNodes(); |
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
|
106 for (int i = 0; i < nodes.size(); ++i) { |
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
|
107 Node n = nodes.get(i); |
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
|
108 if (Schedule.trueSuccessorCount(n) > 1) { |
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
|
109 for (int j = 0; j < n.successors().size(); ++j) { |
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
|
110 Node succ = n.successors().get(j); |
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
|
111 if (Schedule.truePredecessorCount(succ) > 1) { |
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
|
112 Anchor a = new Anchor(null, 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
|
113 a.successors().setAndClear(1, n, j); |
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
|
114 n.successors().set(j, a); |
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
|
115 } |
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
|
116 } |
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
|
117 } |
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
|
118 } |
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
|
119 |
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
|
120 Schedule schedule = new Schedule(graph); |
2760
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
121 List<Block> blocks = schedule.getBlocks(); |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
122 List<LIRBlock> lirBlocks = new ArrayList<LIRBlock>(); |
2760
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
123 Map<Block, LIRBlock> map = new HashMap<Block, LIRBlock>(); |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
124 for (Block b : blocks) { |
2777
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
125 LIRBlock block = new LIRBlock(b.blockID()); |
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
126 map.put(b, block); |
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
127 block.setInstructions(b.getInstructions()); |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
128 block.setLinearScanNumber(b.blockID()); |
2805
c3f64b66fc78
Towards removing the next pointer from Constant and ArithmeticOp
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2801
diff
changeset
|
129 |
c3f64b66fc78
Towards removing the next pointer from Constant and ArithmeticOp
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2801
diff
changeset
|
130 block.setFirstInstruction(b.firstNode()); |
c3f64b66fc78
Towards removing the next pointer from Constant and ArithmeticOp
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2801
diff
changeset
|
131 block.setLastInstruction(b.lastNode()); |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
132 lirBlocks.add(block); |
2760
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
133 } |
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 for (Block b : blocks) { |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
136 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
|
137 map.get(b).blockSuccessors().add(map.get(succ)); |
2760
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 for (Block pred : b.getPredecessors()) { |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
141 map.get(b).blockPredecessors().add(map.get(pred)); |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
142 } |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
143 } |
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2759
diff
changeset
|
144 |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
145 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
|
146 valueToBlock = new HashMap<Node, LIRBlock>(); |
2777
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
147 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
|
148 for (Node i : b.getInstructions()) { |
2777
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
149 valueToBlock.put(i, b); |
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
150 } |
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
151 } |
2789
aeccd2af4e9e
Fixes around critical edge split and placeholder removal after goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2788
diff
changeset
|
152 startBlock = lirBlocks.get(0); |
2777
3e4d992fd312
towards replacing computelinearscanorder with scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2776
diff
changeset
|
153 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
|
154 assert startBlock.blockPredecessors().size() == 0; |
2788
df4c5254c5cc
Towards goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2783
diff
changeset
|
155 |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
156 ComputeLinearScanOrder clso = new ComputeLinearScanOrder(lirBlocks.size(), startBlock); |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
157 orderedBlocks = clso.linearScanOrder(); |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
158 this.compilation.stats.loopCount = clso.numLoops(); |
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 int z = 0; |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
161 for (LIRBlock b : orderedBlocks) { |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
162 b.setLinearScanNumber(z++); |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
163 } |
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
164 |
2788
df4c5254c5cc
Towards goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2783
diff
changeset
|
165 verifyAndPrint("After linear scan order"); |
2778
2ac7b30b7290
Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2777
diff
changeset
|
166 |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
167 if (C1XOptions.PrintTimers) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
168 C1XTimers.HIR_OPTIMIZE.stop(); |
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 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
172 private void buildGraph() { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
173 // Graph builder must set the startBlock and the osrEntryBlock |
2842
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
174 new GraphBuilder(compilation, compilation.method, compilation.graph).build(); |
2827
bd17ac598c6e
Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents:
2809
diff
changeset
|
175 |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
176 verifyAndPrint("After graph building"); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
177 |
2858
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
178 if (C1XOptions.Inline) { |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
179 List<Invoke> trivialInline = new ArrayList<Invoke>(); |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
180 List<Invoke> deoptInline = new ArrayList<Invoke>(); |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
181 List<RiMethod> deoptMethods = new ArrayList<RiMethod>(); |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
182 for (Node node : compilation.graph.getNodes()) { |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
183 if (node instanceof Invoke) { |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
184 Invoke invoke = (Invoke) node; |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
185 RiMethod target = invoke.target; |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
186 if (target.isResolved() && !Modifier.isNative(target.accessFlags())) { |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
187 if (target.canBeStaticallyBound()) { |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
188 trivialInline.add(invoke); |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
189 } else { |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
190 RiMethod concrete = invoke.target.holder().uniqueConcreteMethod(invoke.target); |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
191 if (concrete != null) { |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
192 deoptInline.add(invoke); |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
193 deoptMethods.add(concrete); |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
194 } |
2842
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
195 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
196 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
197 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
198 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
199 |
2858
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
200 int allowedInlinings = 50; |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
201 for (Invoke invoke : trivialInline) { |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
202 if (inlineMethod(invoke, invoke.target)) { |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
203 if (--allowedInlinings <= 0) { |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
204 break; |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
205 } |
2842
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
206 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
207 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
208 |
2858
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
209 for (int i = 0; i < deoptInline.size(); i++) { |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
210 Invoke invoke = deoptInline.get(i); |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
211 RiMethod method = deoptMethods.get(i); |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
212 if (inlineMethod(invoke, method)) { |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
213 if (C1XOptions.TraceInlining) { |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
214 System.out.println("registering concrete method assumption..."); |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
215 } |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
216 compilation.assumptions.recordConcreteMethod(invoke.target, method); |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
217 if (--allowedInlinings <= 0) { |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
218 break; |
a97605b0489b
Renamed Compare=>Materialize and introduced new C1XOption Inline.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2842
diff
changeset
|
219 } |
2842
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
220 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
221 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
222 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
223 |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
224 if (C1XOptions.PrintCompilation) { |
2842
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
225 TTY.print(String.format("%3d blocks | ", compilation.stats.blockCount)); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
226 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
227 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
228 |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
229 private boolean inlineMethod(Invoke invoke, RiMethod method) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
230 String name = invoke.id() + ": " + CiUtil.format("%H.%n(%p):%r", method, false) + " (" + method.code().length + " bytes)"; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
231 |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
232 if (method.code().length > 50) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
233 if (C1XOptions.TraceInlining) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
234 System.out.println("not inlining " + name + " because of code size"); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
235 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
236 return false; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
237 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
238 |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
239 Instruction exceptionEdge = invoke.exceptionEdge(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
240 if (exceptionEdge != null) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
241 if (C1XOptions.TraceInlining) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
242 System.out.println("not inlining " + name + " because of exceptionEdge"); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
243 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
244 return false; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
245 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
246 if (!method.holder().isInitialized()) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
247 if (C1XOptions.TraceInlining) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
248 System.out.println("not inlining " + name + " because of non-initialized class"); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
249 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
250 return false; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
251 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
252 |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
253 if (C1XOptions.TraceInlining) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
254 System.out.println("building graph: " + name); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
255 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
256 CompilerGraph graph = new CompilerGraph(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
257 new GraphBuilder(compilation, method, graph).build(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
258 |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
259 boolean withReceiver = !Modifier.isStatic(method.accessFlags()); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
260 |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
261 int argumentCount = method.signature().argumentCount(false); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
262 Value[] parameters = new Value[argumentCount + (withReceiver ? 1 : 0)]; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
263 int slot = withReceiver ? 1 : 0; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
264 int param = withReceiver ? 1 : 0; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
265 for (int i = 0; i < argumentCount; i++) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
266 parameters[param++] = invoke.argument(slot); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
267 slot += method.signature().argumentKindAt(i).sizeInSlots(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
268 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
269 if (withReceiver) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
270 parameters[0] = invoke.argument(0); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
271 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
272 |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
273 HashMap<Node, Node> replacements = new HashMap<Node, Node>(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
274 ArrayList<Node> nodes = new ArrayList<Node>(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
275 ArrayList<Node> frameStates = new ArrayList<Node>(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
276 Return returnNode = null; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
277 Unwind unwindNode = null; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
278 StartNode startNode = null; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
279 boolean invokes = false; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
280 for (Node node : graph.getNodes()) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
281 if (node != null) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
282 if (node instanceof StartNode) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
283 startNode = (StartNode) node; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
284 } else if (node instanceof Local) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
285 replacements.put(node, parameters[((Local) node).index()]); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
286 } else { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
287 nodes.add(node); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
288 if (node instanceof Return) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
289 returnNode = (Return) node; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
290 } else if (node instanceof Unwind) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
291 unwindNode = (Unwind) node; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
292 } else if (node instanceof FrameState) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
293 frameStates.add(node); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
294 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
295 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
296 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
297 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
298 if (unwindNode != null) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
299 if (C1XOptions.TraceInlining) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
300 System.out.println("not inlining " + name + " because of unwind node"); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
301 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
302 return false; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
303 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
304 if (invokes) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
305 if (C1XOptions.TraceInlining) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
306 System.out.println("not inlining " + name + " because of invokes"); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
307 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
308 return false; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
309 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
310 |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
311 if (C1XOptions.TraceInlining) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
312 System.out.println("inlining " + name + ": " + frameStates.size() + " frame states, " + nodes.size() + " nodes"); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
313 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
314 |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
315 Instruction pred; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
316 if (withReceiver) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
317 pred = new NullCheck(parameters[0], compilation.graph); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
318 } else { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
319 pred = new Merge(compilation.graph); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
320 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
321 assert invoke.predecessors().size() == 1; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
322 invoke.predecessors().get(0).successors().replace(invoke, pred); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
323 replacements.put(startNode, pred); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
324 |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
325 Map<Node, Node> duplicates = compilation.graph.addDuplicate(nodes, replacements); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
326 |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
327 if (returnNode != null) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
328 List<Node> usages = new ArrayList<Node>(invoke.usages()); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
329 for (Node usage : usages) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
330 if (returnNode.result() instanceof Local) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
331 usage.inputs().replace(invoke, replacements.get(returnNode.result())); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
332 } else { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
333 usage.inputs().replace(invoke, duplicates.get(returnNode.result())); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
334 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
335 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
336 Node returnDuplicate = duplicates.get(returnNode); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
337 returnDuplicate.inputs().clearAll(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
338 |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
339 assert returnDuplicate.predecessors().size() == 1; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
340 Node returnPred = returnDuplicate.predecessors().get(0); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
341 int index = returnDuplicate.predecessorsIndex().get(0); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
342 returnPred.successors().setAndClear(index, invoke, 0); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
343 |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
344 returnDuplicate.delete(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
345 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
346 FrameState stateAfter = invoke.stateAfter(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
347 if (frameStates.size() > 0) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
348 FrameState outerFrameState = stateAfter.duplicateModified(invoke.bci, invoke.kind); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
349 for (Node frameState : frameStates) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
350 ((FrameState) duplicates.get(frameState)).setOuterFrameState(outerFrameState); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
351 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
352 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
353 |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
354 invoke.successors().clearAll(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
355 invoke.inputs().clearAll(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
356 invoke.delete(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
357 |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
358 stateAfter.delete(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
359 |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
360 deleteUnused(exceptionEdge); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
361 |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
362 verifyAndPrint("After inlining " + CiUtil.format("%H.%n(%p):%r", method, false)); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
363 return true; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
364 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
365 |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
366 private void deleteUnused(Node node) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
367 if (node != null && node.predecessors().size() == 0) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
368 if (node instanceof ExceptionObject) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
369 Node successor = node.successors().get(0); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
370 node.successors().clearAll(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
371 if (successor instanceof ExceptionDispatch) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
372 ExceptionDispatch dispatch = (ExceptionDispatch) successor; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
373 Node succ1 = dispatch.catchSuccessor(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
374 Node succ2 = dispatch.otherSuccessor(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
375 if (succ1 instanceof Merge) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
376 ((Merge) succ1).removePhiPredecessor(dispatch); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
377 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
378 if (succ2 instanceof Merge) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
379 ((Merge) succ2).removePhiPredecessor(dispatch); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
380 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
381 dispatch.successors().clearAll(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
382 deleteUnused(succ1); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
383 deleteUnused(succ2); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
384 dispatch.delete(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
385 } else { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
386 assert successor instanceof Merge; |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
387 System.out.println("succ: " + successor.successors().get(0)); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
388 Node next = successor.successors().get(0); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
389 successor.successors().clearAll(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
390 deleteUnused(next); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
391 successor.delete(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
392 } |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
393 node.delete(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
394 } else if (node instanceof Unwind) { |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
395 node.delete(); |
7596ae867a7b
basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
2841
diff
changeset
|
396 } |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
397 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
398 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
399 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
400 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
401 * 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
|
402 * @return the blocks in linear scan order |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
403 */ |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2716
diff
changeset
|
404 public List<LIRBlock> linearScanOrder() { |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
405 return orderedBlocks; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
406 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
407 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
408 private void print(boolean cfgOnly) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
409 if (!TTY.isSuppressed()) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
410 TTY.println("IR for " + compilation.method); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
411 final InstructionPrinter ip = new InstructionPrinter(TTY.out()); |
2546
e1b3db8031ee
Removed liveness marking.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2531
diff
changeset
|
412 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
|
413 //getHIRStartBlock().iteratePreOrder(bp); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
414 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
415 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
416 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
417 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
418 * 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
|
419 * @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
|
420 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
421 public void verifyAndPrint(String phase) { |
2653
7c8ad40c1f88
No need for stateAfter on volatile field loads.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2616
diff
changeset
|
422 if (C1XOptions.PrintHIR && !TTY.isSuppressed()) { |
7c8ad40c1f88
No need for stateAfter on volatile field loads.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2616
diff
changeset
|
423 TTY.println(phase); |
7c8ad40c1f88
No need for stateAfter on volatile field loads.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2616
diff
changeset
|
424 print(false); |
7c8ad40c1f88
No need for stateAfter on volatile field loads.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2616
diff
changeset
|
425 } |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
426 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
427 if (compilation.compiler.isObserved()) { |
2809
b003ea36fa12
Add block structure to ideal graph visualizer
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2807
diff
changeset
|
428 compilation.compiler.fireCompilationEvent(new CompilationEvent(compilation, phase, compilation.graph, true, false)); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
429 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
430 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
431 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
432 public int numLoops() { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
433 return compilation.stats.loopCount; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
434 } |
2564
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
435 |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
436 /** |
2840
75e0d39833a0
new CompilerGraph, create only one Return and one Unwind per CompilerGraph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2835
diff
changeset
|
437 * 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
|
438 */ |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
439 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
|
440 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
|
441 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
|
442 if (node instanceof FrameState) { |
75e0d39833a0
new CompilerGraph, create only one Return and one Unwind per CompilerGraph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2835
diff
changeset
|
443 int lockCount = ((FrameState) node).locksSize(); |
75e0d39833a0
new CompilerGraph, create only one Return and one Unwind per CompilerGraph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2835
diff
changeset
|
444 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
|
445 maxLocks = lockCount; |
75e0d39833a0
new CompilerGraph, create only one Return and one Unwind per CompilerGraph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2835
diff
changeset
|
446 } |
75e0d39833a0
new CompilerGraph, create only one Return and one Unwind per CompilerGraph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2835
diff
changeset
|
447 } |
75e0d39833a0
new CompilerGraph, create only one Return and one Unwind per CompilerGraph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2835
diff
changeset
|
448 } |
2564
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
449 return maxLocks; |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
450 } |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2716
diff
changeset
|
451 |
2781
bda5972a40a5
remove unnecessary BlockBegin nodes in frontend
Lukas Stadler <lukas.stadler@jku.at>
parents:
2776
diff
changeset
|
452 public Instruction getHIRStartBlock() { |
bda5972a40a5
remove unnecessary BlockBegin nodes in frontend
Lukas Stadler <lukas.stadler@jku.at>
parents:
2776
diff
changeset
|
453 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
|
454 } |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
455 } |