Mercurial > hg > truffle
annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConvertDeoptimizeToGuardPhase.java @ 17046:c72182ae4476
Remove redundant Begin nodes before LoopExit.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Thu, 04 Sep 2014 13:44:45 +0200 |
parents | 06c15e88d383 |
children | 37d6d174bc40 |
rev | line source |
---|---|
4548
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
6526
ee651c726397
split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
23 package com.oracle.graal.phases.common; |
4548
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 import java.util.*; |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 |
12407
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
27 import com.oracle.graal.api.meta.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
28 import com.oracle.graal.debug.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
29 import com.oracle.graal.graph.*; |
16404
fe985eebfcd9
ConvertDeoptimizeToGuardPhase: remove useless BeginNodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16207
diff
changeset
|
30 import com.oracle.graal.graph.spi.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
31 import com.oracle.graal.nodes.*; |
12407
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
32 import com.oracle.graal.nodes.calc.*; |
8382
496db8bf756d
Killing cfg path to deoptimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8276
diff
changeset
|
33 import com.oracle.graal.nodes.util.*; |
6526
ee651c726397
split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
34 import com.oracle.graal.phases.*; |
4548
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 |
11396
a268b0de65d6
Add some javadoc for GuardLoweringPhase, ConvertDeoptimizeToGuardPhase and DeoptimizeNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11335
diff
changeset
|
36 /** |
a268b0de65d6
Add some javadoc for GuardLoweringPhase, ConvertDeoptimizeToGuardPhase and DeoptimizeNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11335
diff
changeset
|
37 * This phase will find branches which always end with a {@link DeoptimizeNode} and replace their |
a268b0de65d6
Add some javadoc for GuardLoweringPhase, ConvertDeoptimizeToGuardPhase and DeoptimizeNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11335
diff
changeset
|
38 * {@link ControlSplitNode ControlSplitNodes} with {@link FixedGuardNode FixedGuardNodes}. |
15471
ef315dfdda35
new GraphUtil.predecessorIterable
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
39 * |
11459
c66cdfb7445b
ConvertDeoptimizeToGuardPhase: small javadoc fix
Bernhard Urban <bernhard.urban@jku.at>
parents:
11413
diff
changeset
|
40 * This is useful because {@link FixedGuardNode FixedGuardNodes} will be lowered to |
11413
2c3ca4b71965
Add more javadoc to ConvertDeoptimizeToGuardPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11396
diff
changeset
|
41 * {@link GuardNode GuardNodes} which can later be optimized more aggressively than control-flow |
2c3ca4b71965
Add more javadoc to ConvertDeoptimizeToGuardPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11396
diff
changeset
|
42 * constructs. |
15471
ef315dfdda35
new GraphUtil.predecessorIterable
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
43 * |
11396
a268b0de65d6
Add some javadoc for GuardLoweringPhase, ConvertDeoptimizeToGuardPhase and DeoptimizeNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11335
diff
changeset
|
44 * This is currently only done for branches that start from a {@link IfNode}. If it encounters a |
a268b0de65d6
Add some javadoc for GuardLoweringPhase, ConvertDeoptimizeToGuardPhase and DeoptimizeNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11335
diff
changeset
|
45 * branch starting at an other kind of {@link ControlSplitNode}, it will only bring the |
a268b0de65d6
Add some javadoc for GuardLoweringPhase, ConvertDeoptimizeToGuardPhase and DeoptimizeNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11335
diff
changeset
|
46 * {@link DeoptimizeNode} as close to the {@link ControlSplitNode} as possible. |
15471
ef315dfdda35
new GraphUtil.predecessorIterable
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
47 * |
11396
a268b0de65d6
Add some javadoc for GuardLoweringPhase, ConvertDeoptimizeToGuardPhase and DeoptimizeNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11335
diff
changeset
|
48 */ |
4548
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 public class ConvertDeoptimizeToGuardPhase extends Phase { |
16572
7531cdfed73c
ConvertDeoptimizeToGuardPhase: the SimplifierTool can be an instance field
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16462
diff
changeset
|
50 private SimplifierTool simplifierTool = GraphUtil.getDefaultSimplifier(null, null, null, false); |
4548
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14721
diff
changeset
|
52 private static BeginNode findBeginNode(FixedNode startNode) { |
15471
ef315dfdda35
new GraphUtil.predecessorIterable
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
53 return GraphUtil.predecessorIterable(startNode).filter(BeginNode.class).first(); |
4548
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 } |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 @Override |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 protected void run(final StructuredGraph graph) { |
16462
1a6989c482f6
assertion in ConvertDeoptimizeToGuardPhase
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16404
diff
changeset
|
58 assert graph.hasValueProxies() : "ConvertDeoptimizeToGuardPhase always creates proxies"; |
4682
7cb57ac24ab8
Better ConvertDeoptimizeToGuardPhase (experimental).
Andreas Woess <andreas.woess@jku.at>
parents:
4548
diff
changeset
|
59 if (graph.getNodes(DeoptimizeNode.class).isEmpty()) { |
4548
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
60 return; |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
61 } |
4682
7cb57ac24ab8
Better ConvertDeoptimizeToGuardPhase (experimental).
Andreas Woess <andreas.woess@jku.at>
parents:
4548
diff
changeset
|
62 for (DeoptimizeNode d : graph.getNodes(DeoptimizeNode.class)) { |
8384
0edb2a515cb1
Fixes a corner case when killing the control flowing into a deoptimize node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8382
diff
changeset
|
63 assert d.isAlive(); |
16572
7531cdfed73c
ConvertDeoptimizeToGuardPhase: the SimplifierTool can be an instance field
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16462
diff
changeset
|
64 visitDeoptBegin(BeginNode.prevBegin(d), d.action(), d.reason(), graph); |
12407
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
65 } |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
66 |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
67 for (FixedGuardNode fixedGuard : graph.getNodes(FixedGuardNode.class)) { |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
68 |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14721
diff
changeset
|
69 BeginNode pred = BeginNode.prevBegin(fixedGuard); |
12407
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
70 if (pred instanceof MergeNode) { |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
71 MergeNode merge = (MergeNode) pred; |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
72 if (fixedGuard.condition() instanceof CompareNode) { |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
73 CompareNode compare = (CompareNode) fixedGuard.condition(); |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
74 List<AbstractEndNode> mergePredecessors = merge.cfgPredecessors().snapshot(); |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
75 |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15471
diff
changeset
|
76 Constant[] xs = IfNode.constantValues(compare.getX(), merge, true); |
12407
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
77 if (xs == null) { |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
78 continue; |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
79 } |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15471
diff
changeset
|
80 Constant[] ys = IfNode.constantValues(compare.getY(), merge, true); |
12407
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
81 if (ys == null) { |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
82 continue; |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
83 } |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
84 for (int i = 0; i < mergePredecessors.size(); ++i) { |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
85 AbstractEndNode mergePredecessor = mergePredecessors.get(i); |
14721
ede5735ed267
deal with deleted ends in ConvertDeoptimizeToGuardPhase
Lukas Stadler <lukas.stadler@oracle.com>
parents:
12407
diff
changeset
|
86 if (!mergePredecessor.isAlive()) { |
ede5735ed267
deal with deleted ends in ConvertDeoptimizeToGuardPhase
Lukas Stadler <lukas.stadler@oracle.com>
parents:
12407
diff
changeset
|
87 break; |
ede5735ed267
deal with deleted ends in ConvertDeoptimizeToGuardPhase
Lukas Stadler <lukas.stadler@oracle.com>
parents:
12407
diff
changeset
|
88 } |
12407
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
89 if (xs[i] == null) { |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
90 continue; |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
91 } |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
92 if (ys[i] == null) { |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
93 continue; |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
94 } |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
95 if (xs[i].getKind() != Kind.Object && ys[i].getKind() != Kind.Object && |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
96 compare.condition().foldCondition(xs[i], ys[i], null, compare.unorderedIsTrue()) == fixedGuard.isNegated()) { |
16572
7531cdfed73c
ConvertDeoptimizeToGuardPhase: the SimplifierTool can be an instance field
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16462
diff
changeset
|
97 visitDeoptBegin(BeginNode.prevBegin(mergePredecessor), fixedGuard.getAction(), fixedGuard.getReason(), graph); |
12407
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
98 } |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
99 } |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
100 } |
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
101 } |
4548
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 } |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 new DeadCodeEliminationPhase().apply(graph); |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 } |
4682
7cb57ac24ab8
Better ConvertDeoptimizeToGuardPhase (experimental).
Andreas Woess <andreas.woess@jku.at>
parents:
4548
diff
changeset
|
106 |
16572
7531cdfed73c
ConvertDeoptimizeToGuardPhase: the SimplifierTool can be an instance field
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16462
diff
changeset
|
107 private void visitDeoptBegin(BeginNode deoptBegin, DeoptimizationAction deoptAction, DeoptimizationReason deoptReason, StructuredGraph graph) { |
4682
7cb57ac24ab8
Better ConvertDeoptimizeToGuardPhase (experimental).
Andreas Woess <andreas.woess@jku.at>
parents:
4548
diff
changeset
|
108 if (deoptBegin instanceof MergeNode) { |
7cb57ac24ab8
Better ConvertDeoptimizeToGuardPhase (experimental).
Andreas Woess <andreas.woess@jku.at>
parents:
4548
diff
changeset
|
109 MergeNode mergeNode = (MergeNode) deoptBegin; |
12407
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
110 Debug.log("Visiting %s", mergeNode); |
16404
fe985eebfcd9
ConvertDeoptimizeToGuardPhase: remove useless BeginNodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16207
diff
changeset
|
111 FixedNode next = mergeNode.next(); |
fe985eebfcd9
ConvertDeoptimizeToGuardPhase: remove useless BeginNodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16207
diff
changeset
|
112 while (mergeNode.isAlive()) { |
fe985eebfcd9
ConvertDeoptimizeToGuardPhase: remove useless BeginNodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16207
diff
changeset
|
113 AbstractEndNode end = mergeNode.forwardEnds().first(); |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14721
diff
changeset
|
114 BeginNode newBeginNode = findBeginNode(end); |
16572
7531cdfed73c
ConvertDeoptimizeToGuardPhase: the SimplifierTool can be an instance field
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16462
diff
changeset
|
115 visitDeoptBegin(newBeginNode, deoptAction, deoptReason, graph); |
4682
7cb57ac24ab8
Better ConvertDeoptimizeToGuardPhase (experimental).
Andreas Woess <andreas.woess@jku.at>
parents:
4548
diff
changeset
|
116 } |
16404
fe985eebfcd9
ConvertDeoptimizeToGuardPhase: remove useless BeginNodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16207
diff
changeset
|
117 assert next.isAlive(); |
fe985eebfcd9
ConvertDeoptimizeToGuardPhase: remove useless BeginNodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16207
diff
changeset
|
118 BeginNode newBeginNode = findBeginNode(next); |
16572
7531cdfed73c
ConvertDeoptimizeToGuardPhase: the SimplifierTool can be an instance field
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16462
diff
changeset
|
119 visitDeoptBegin(newBeginNode, deoptAction, deoptReason, graph); |
8382
496db8bf756d
Killing cfg path to deoptimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8276
diff
changeset
|
120 return; |
4682
7cb57ac24ab8
Better ConvertDeoptimizeToGuardPhase (experimental).
Andreas Woess <andreas.woess@jku.at>
parents:
4548
diff
changeset
|
121 } else if (deoptBegin.predecessor() instanceof IfNode) { |
7cb57ac24ab8
Better ConvertDeoptimizeToGuardPhase (experimental).
Andreas Woess <andreas.woess@jku.at>
parents:
4548
diff
changeset
|
122 IfNode ifNode = (IfNode) deoptBegin.predecessor(); |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14721
diff
changeset
|
123 BeginNode otherBegin = ifNode.trueSuccessor(); |
7767
4a6646d8eb87
separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
124 LogicNode conditionNode = ifNode.condition(); |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16572
diff
changeset
|
125 FixedGuardNode guard = graph.add(FixedGuardNode.create(conditionNode, deoptReason, deoptAction, deoptBegin == ifNode.trueSuccessor())); |
9360
412f6e6dad73
Allow FixedGuard usages for InstanceOf nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8441
diff
changeset
|
126 FixedWithNextNode pred = (FixedWithNextNode) ifNode.predecessor(); |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14721
diff
changeset
|
127 BeginNode survivingSuccessor; |
9360
412f6e6dad73
Allow FixedGuard usages for InstanceOf nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8441
diff
changeset
|
128 if (deoptBegin == ifNode.trueSuccessor()) { |
11308
77167d6f868c
Fix forward propagation of guarded nodes in ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
129 survivingSuccessor = ifNode.falseSuccessor(); |
9360
412f6e6dad73
Allow FixedGuard usages for InstanceOf nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8441
diff
changeset
|
130 } else { |
11308
77167d6f868c
Fix forward propagation of guarded nodes in ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
131 survivingSuccessor = ifNode.trueSuccessor(); |
77167d6f868c
Fix forward propagation of guarded nodes in ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
132 } |
77167d6f868c
Fix forward propagation of guarded nodes in ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
133 graph.removeSplitPropagate(ifNode, survivingSuccessor); |
11333
a07d9113d1f6
Fix in ConvertDeoptimizeToGuardPhase for the case where we need to insert a ProxyNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11308
diff
changeset
|
134 ProxyNode proxyGuard = null; |
11308
77167d6f868c
Fix forward propagation of guarded nodes in ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
135 for (Node n : survivingSuccessor.usages().snapshot()) { |
77167d6f868c
Fix forward propagation of guarded nodes in ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
136 if (n instanceof GuardNode || n instanceof ProxyNode) { |
77167d6f868c
Fix forward propagation of guarded nodes in ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
137 // Keep wired to the begin node. |
77167d6f868c
Fix forward propagation of guarded nodes in ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
138 } else { |
77167d6f868c
Fix forward propagation of guarded nodes in ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
139 // Rewire to the fixed guard. |
11333
a07d9113d1f6
Fix in ConvertDeoptimizeToGuardPhase for the case where we need to insert a ProxyNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11308
diff
changeset
|
140 if (survivingSuccessor instanceof LoopExitNode) { |
a07d9113d1f6
Fix in ConvertDeoptimizeToGuardPhase for the case where we need to insert a ProxyNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11308
diff
changeset
|
141 if (proxyGuard == null) { |
11335
ccbbb7dbca69
Make sure the created ProxyNode is of PhiType.Guard.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11333
diff
changeset
|
142 proxyGuard = ProxyNode.forGuard(guard, survivingSuccessor, graph); |
11333
a07d9113d1f6
Fix in ConvertDeoptimizeToGuardPhase for the case where we need to insert a ProxyNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11308
diff
changeset
|
143 } |
a07d9113d1f6
Fix in ConvertDeoptimizeToGuardPhase for the case where we need to insert a ProxyNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11308
diff
changeset
|
144 n.replaceFirstInput(survivingSuccessor, proxyGuard); |
a07d9113d1f6
Fix in ConvertDeoptimizeToGuardPhase for the case where we need to insert a ProxyNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11308
diff
changeset
|
145 } else { |
a07d9113d1f6
Fix in ConvertDeoptimizeToGuardPhase for the case where we need to insert a ProxyNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11308
diff
changeset
|
146 n.replaceFirstInput(survivingSuccessor, guard); |
a07d9113d1f6
Fix in ConvertDeoptimizeToGuardPhase for the case where we need to insert a ProxyNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11308
diff
changeset
|
147 } |
11308
77167d6f868c
Fix forward propagation of guarded nodes in ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
148 } |
6548
4dc9e468c8b0
The lowering currently does not support a FixedGuard as the usage of an InstanceOfNode
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
149 } |
12407
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
150 Debug.log("Converting deopt on %-5s branch of %s to guard for remaining branch %s.", deoptBegin == ifNode.trueSuccessor() ? "true" : "false", ifNode, otherBegin); |
9360
412f6e6dad73
Allow FixedGuard usages for InstanceOf nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8441
diff
changeset
|
151 FixedNode next = pred.next(); |
412f6e6dad73
Allow FixedGuard usages for InstanceOf nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8441
diff
changeset
|
152 pred.setNext(guard); |
412f6e6dad73
Allow FixedGuard usages for InstanceOf nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8441
diff
changeset
|
153 guard.setNext(next); |
17046
c72182ae4476
Remove redundant Begin nodes before LoopExit.
Roland Schatz <roland.schatz@oracle.com>
parents:
16895
diff
changeset
|
154 survivingSuccessor.simplify(simplifierTool); |
9360
412f6e6dad73
Allow FixedGuard usages for InstanceOf nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8441
diff
changeset
|
155 return; |
8382
496db8bf756d
Killing cfg path to deoptimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8276
diff
changeset
|
156 } |
496db8bf756d
Killing cfg path to deoptimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8276
diff
changeset
|
157 |
496db8bf756d
Killing cfg path to deoptimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8276
diff
changeset
|
158 // We could not convert the control split - at least cut off control flow after the split. |
8388
bcfe9832552a
Speical case ExceptionObjectNode in deopt to guard conversion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8387
diff
changeset
|
159 FixedWithNextNode deoptPred = deoptBegin; |
bcfe9832552a
Speical case ExceptionObjectNode in deopt to guard conversion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8387
diff
changeset
|
160 FixedNode next = deoptPred.next(); |
bcfe9832552a
Speical case ExceptionObjectNode in deopt to guard conversion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8387
diff
changeset
|
161 |
12407
53297646b011
Improve convert deoptimize to guard phase to recognize FixedGuardNode following MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11459
diff
changeset
|
162 if (!(next instanceof DeoptimizeNode)) { |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16572
diff
changeset
|
163 DeoptimizeNode newDeoptNode = graph.add(DeoptimizeNode.create(deoptAction, deoptReason)); |
8388
bcfe9832552a
Speical case ExceptionObjectNode in deopt to guard conversion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8387
diff
changeset
|
164 deoptPred.setNext(newDeoptNode); |
bcfe9832552a
Speical case ExceptionObjectNode in deopt to guard conversion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8387
diff
changeset
|
165 assert deoptPred == newDeoptNode.predecessor(); |
8382
496db8bf756d
Killing cfg path to deoptimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8276
diff
changeset
|
166 GraphUtil.killCFG(next); |
4682
7cb57ac24ab8
Better ConvertDeoptimizeToGuardPhase (experimental).
Andreas Woess <andreas.woess@jku.at>
parents:
4548
diff
changeset
|
167 } |
7cb57ac24ab8
Better ConvertDeoptimizeToGuardPhase (experimental).
Andreas Woess <andreas.woess@jku.at>
parents:
4548
diff
changeset
|
168 } |
4548
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
169 } |