Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java @ 18845:f57d86eb036f
removed Node factory methods
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 12 Jan 2015 20:39:04 +0100 |
parents | 1518c3296cc8 |
children | ff232ff8d028 |
rev | line source |
---|---|
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
1 /* |
8988
02f57662b6c4
remove monitor limitation form TailDuplicationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
8558
diff
changeset
|
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
4 * |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
8 * |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
14 * |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
18 * |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
21 * questions. |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
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; |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
24 |
15259
d90e5c22ba55
Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
25 import static com.oracle.graal.compiler.common.GraalOptions.*; |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9643
diff
changeset
|
26 |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
27 import java.util.*; |
15470
c55f44b3c5e5
remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
28 import java.util.function.*; |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
29 |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15145
diff
changeset
|
30 import com.oracle.graal.compiler.common.*; |
15198
2c0cfbf454b5
Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
31 import com.oracle.graal.compiler.common.type.*; |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
32 import com.oracle.graal.debug.*; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
33 import com.oracle.graal.graph.Graph.DuplicationReplacement; |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14978
diff
changeset
|
34 import com.oracle.graal.graph.Graph.Mark; |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
35 import com.oracle.graal.graph.*; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16838
diff
changeset
|
36 import com.oracle.graal.nodeinfo.*; |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
37 import com.oracle.graal.nodes.*; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
38 import com.oracle.graal.nodes.VirtualState.NodeClosure; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
39 import com.oracle.graal.nodes.extended.*; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
40 import com.oracle.graal.nodes.java.*; |
7536
1563a48b798d
don't tail duplicate allocations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7255
diff
changeset
|
41 import com.oracle.graal.nodes.spi.*; |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
42 import com.oracle.graal.nodes.util.*; |
11875
35bdfb9ac12f
don't tail duplicate object allocations
Lukas Stadler <lukas.stadler@jku.at>
parents:
11711
diff
changeset
|
43 import com.oracle.graal.nodes.virtual.*; |
6525
2c913b643422
rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents:
6522
diff
changeset
|
44 import com.oracle.graal.phases.*; |
9238
8f01fe16e473
refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9234
diff
changeset
|
45 import com.oracle.graal.phases.graph.*; |
9329
fa188fbfe3fe
Perform only targeted canonicalization after tail duplication.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9238
diff
changeset
|
46 import com.oracle.graal.phases.tiers.*; |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
47 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
48 /** |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
49 * This class is a phase that looks for opportunities for tail duplication. The static method |
11573
8a3d99fc36cf
Pass canonicalizer into tail duplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
10706
diff
changeset
|
50 * {@link #tailDuplicate(MergeNode, TailDuplicationDecision, List, PhaseContext, CanonicalizerPhase)} |
8a3d99fc36cf
Pass canonicalizer into tail duplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
10706
diff
changeset
|
51 * can also be used to drive tail duplication from other places, e.g., inlining. |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
52 */ |
9329
fa188fbfe3fe
Perform only targeted canonicalization after tail duplication.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9238
diff
changeset
|
53 public class TailDuplicationPhase extends BasePhase<PhaseContext> { |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
54 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
55 /* |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
56 * Various metrics on the circumstances in which tail duplication was/wasn't performed. |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
57 */ |
10533
2faa1e7ef4f3
enable TailDuplication for MergeNodes without stateAfter
Lukas Stadler <lukas.stadler@jku.at>
parents:
10009
diff
changeset
|
58 private static final DebugMetric metricDuplicationConsidered = Debug.metric("DuplicationConsidered"); |
2faa1e7ef4f3
enable TailDuplication for MergeNodes without stateAfter
Lukas Stadler <lukas.stadler@jku.at>
parents:
10009
diff
changeset
|
59 private static final DebugMetric metricDuplicationPerformed = Debug.metric("DuplicationPerformed"); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
60 |
11573
8a3d99fc36cf
Pass canonicalizer into tail duplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
10706
diff
changeset
|
61 private final CanonicalizerPhase canonicalizer; |
8a3d99fc36cf
Pass canonicalizer into tail duplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
10706
diff
changeset
|
62 |
18255
415c79fefdb3
TailDuplicationPhase.DummyAnchorNode: add allowedUsageTypes.
Josef Eisl <josef.eisl@jku.at>
parents:
18190
diff
changeset
|
63 @NodeInfo(allowedUsageTypes = {InputType.Guard, InputType.Anchor}) |
18190
c8d83f6db9a2
Make TailDuplicationPhase.DummyAnchorNode an AnchoringNode.
Josef Eisl <josef.eisl@jku.at>
parents:
17450
diff
changeset
|
64 static class DummyAnchorNode extends FixedWithNextNode implements GuardingNode, AnchoringNode { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18383
diff
changeset
|
65 public DummyAnchorNode() { |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18383
diff
changeset
|
66 super(StampFactory.forVoid()); |
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:
16841
diff
changeset
|
67 } |
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:
16841
diff
changeset
|
68 |
15001 | 69 } |
70 | |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
71 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
72 * This interface is used by tail duplication to let clients decide if tail duplication should |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
73 * be performed. |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
74 */ |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
75 public interface TailDuplicationDecision { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
76 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
77 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
78 * Queries if tail duplication should be performed at the given merge. If this method |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
79 * returns true then the tail duplication will be performed, because all other checks have |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
80 * happened before. |
15001 | 81 * |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
82 * @param merge The merge at which tail duplication can be performed. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
83 * @param fixedNodeCount The size of the set of fixed nodes that forms the base for the |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
84 * duplicated set of nodes. |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
85 * @return true if the tail duplication should be performed, false otherwise. |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
86 */ |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
87 boolean doTransform(MergeNode merge, int fixedNodeCount); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
88 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
89 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
90 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
91 * A tail duplication decision closure that employs the default algorithm: Check if there are |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
92 * any phis on the merge whose stamps improve and that have usages within the duplicated set of |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
93 * fixed nodes. |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
94 */ |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
95 public static final TailDuplicationDecision DEFAULT_DECISION = new TailDuplicationDecision() { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
96 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
97 public boolean doTransform(MergeNode merge, int fixedNodeCount) { |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9643
diff
changeset
|
98 if (fixedNodeCount < TailDuplicationTrivialSize.getValue()) { |
5792
fa6ed51ac198
more aggressive tail duplication
Lukas Stadler <lukas.stadler@jku.at>
parents:
5786
diff
changeset
|
99 return true; |
fa6ed51ac198
more aggressive tail duplication
Lukas Stadler <lukas.stadler@jku.at>
parents:
5786
diff
changeset
|
100 } |
13367
413040ab993e
remove some usages of HashSet
Bernhard Urban <bernhard.urban@jku.at>
parents:
13320
diff
changeset
|
101 ArrayList<PhiNode> improvements = null; |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
102 for (PhiNode phi : merge.phis()) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
103 Stamp phiStamp = phi.stamp(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
104 for (ValueNode input : phi.values()) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
105 if (!input.stamp().equals(phiStamp)) { |
13367
413040ab993e
remove some usages of HashSet
Bernhard Urban <bernhard.urban@jku.at>
parents:
13320
diff
changeset
|
106 if (improvements == null) { |
413040ab993e
remove some usages of HashSet
Bernhard Urban <bernhard.urban@jku.at>
parents:
13320
diff
changeset
|
107 improvements = new ArrayList<>(); |
413040ab993e
remove some usages of HashSet
Bernhard Urban <bernhard.urban@jku.at>
parents:
13320
diff
changeset
|
108 } |
413040ab993e
remove some usages of HashSet
Bernhard Urban <bernhard.urban@jku.at>
parents:
13320
diff
changeset
|
109 if (!improvements.contains(phi)) { |
413040ab993e
remove some usages of HashSet
Bernhard Urban <bernhard.urban@jku.at>
parents:
13320
diff
changeset
|
110 improvements.add(phi); |
413040ab993e
remove some usages of HashSet
Bernhard Urban <bernhard.urban@jku.at>
parents:
13320
diff
changeset
|
111 } |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
112 break; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
113 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
114 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
115 } |
13367
413040ab993e
remove some usages of HashSet
Bernhard Urban <bernhard.urban@jku.at>
parents:
13320
diff
changeset
|
116 if (improvements == null) { |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
117 return false; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
118 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
119 FixedNode current = merge; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
120 int opportunities = 0; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
121 while (current instanceof FixedWithNextNode) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
122 current = ((FixedWithNextNode) current).next(); |
7536
1563a48b798d
don't tail duplicate allocations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7255
diff
changeset
|
123 if (current instanceof VirtualizableAllocation) { |
1563a48b798d
don't tail duplicate allocations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7255
diff
changeset
|
124 return false; |
1563a48b798d
don't tail duplicate allocations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7255
diff
changeset
|
125 } |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
126 for (PhiNode phi : improvements) { |
6433
4bd8711d824a
small fix to tail duplication heuristics
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
127 for (Node input : current.inputs()) { |
4bd8711d824a
small fix to tail duplication heuristics
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
128 if (input == phi) { |
4bd8711d824a
small fix to tail duplication heuristics
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
129 opportunities++; |
4bd8711d824a
small fix to tail duplication heuristics
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
130 } |
4bd8711d824a
small fix to tail duplication heuristics
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
131 if (input.inputs().contains(phi)) { |
4bd8711d824a
small fix to tail duplication heuristics
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
132 opportunities++; |
4bd8711d824a
small fix to tail duplication heuristics
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
133 } |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
134 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
135 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
136 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
137 return opportunities > 0; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
138 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
139 }; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
140 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
141 /** |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
142 * A tail duplication decision closure that always returns true. |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
143 */ |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
144 public static final TailDuplicationDecision TRUE_DECISION = new TailDuplicationDecision() { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
145 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
146 @Override |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
147 public boolean doTransform(MergeNode merge, int fixedNodeCount) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
148 return true; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
149 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
150 }; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
151 |
11573
8a3d99fc36cf
Pass canonicalizer into tail duplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
10706
diff
changeset
|
152 public TailDuplicationPhase(CanonicalizerPhase canonicalizer) { |
8a3d99fc36cf
Pass canonicalizer into tail duplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
10706
diff
changeset
|
153 this.canonicalizer = canonicalizer; |
8a3d99fc36cf
Pass canonicalizer into tail duplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
10706
diff
changeset
|
154 } |
8a3d99fc36cf
Pass canonicalizer into tail duplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
10706
diff
changeset
|
155 |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
156 @Override |
9329
fa188fbfe3fe
Perform only targeted canonicalization after tail duplication.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9238
diff
changeset
|
157 protected void run(StructuredGraph graph, PhaseContext phaseContext) { |
15470
c55f44b3c5e5
remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
158 if (graph.hasNode(MergeNode.class)) { |
c55f44b3c5e5
remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
159 ToDoubleFunction<FixedNode> nodeProbabilities = new FixedNodeProbabilityCache(); |
9234
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9051
diff
changeset
|
160 |
15470
c55f44b3c5e5
remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
161 // A snapshot is taken here, so that new MergeNode instances aren't considered for tail |
c55f44b3c5e5
remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
162 // duplication. |
c55f44b3c5e5
remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
163 for (MergeNode merge : graph.getNodes(MergeNode.class).snapshot()) { |
c55f44b3c5e5
remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
164 if (!(merge instanceof LoopBeginNode) && nodeProbabilities.applyAsDouble(merge) >= TailDuplicationProbability.getValue()) { |
c55f44b3c5e5
remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
165 tailDuplicate(merge, DEFAULT_DECISION, null, phaseContext, canonicalizer); |
c55f44b3c5e5
remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
166 } |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
167 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
168 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
169 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
170 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
171 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
172 * This method attempts to duplicate the tail of the given merge. The merge must not be a |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
173 * {@link LoopBeginNode}. If the merge is eligible for duplication (at least one fixed node in |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
174 * its tail, no {@link MonitorEnterNode}/ {@link MonitorExitNode}, non-null |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
175 * {@link MergeNode#stateAfter()}) then the decision callback is used to determine whether the |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
176 * tail duplication should actually be performed. If replacements is non-null, then this list of |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
177 * {@link PiNode}s is used to replace one value per merge end. |
15001 | 178 * |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
179 * @param merge The merge whose tail should be duplicated. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
180 * @param decision A callback that can make the final decision if tail duplication should occur |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
181 * or not. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
182 * @param replacements A list of {@link PiNode}s, or null. If this list is non-null then its |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
183 * size needs to match the merge's end count. Each entry can either be null or a |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
184 * {@link PiNode}, and is used to replace {@link PiNode#object()} with the |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
185 * {@link PiNode} in the duplicated branch that corresponds to the entry. |
9329
fa188fbfe3fe
Perform only targeted canonicalization after tail duplication.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9238
diff
changeset
|
186 * @param phaseContext |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
187 */ |
11573
8a3d99fc36cf
Pass canonicalizer into tail duplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
10706
diff
changeset
|
188 public static boolean tailDuplicate(MergeNode merge, TailDuplicationDecision decision, List<GuardedValueNode> replacements, PhaseContext phaseContext, CanonicalizerPhase canonicalizer) { |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
189 assert !(merge instanceof LoopBeginNode); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
190 assert replacements == null || replacements.size() == merge.forwardEndCount(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
191 FixedNode fixed = merge; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
192 int fixedCount = 0; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
193 while (fixed instanceof FixedWithNextNode) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
194 fixed = ((FixedWithNextNode) fixed).next(); |
11875
35bdfb9ac12f
don't tail duplicate object allocations
Lukas Stadler <lukas.stadler@jku.at>
parents:
11711
diff
changeset
|
195 if (fixed instanceof CommitAllocationNode) { |
35bdfb9ac12f
don't tail duplicate object allocations
Lukas Stadler <lukas.stadler@jku.at>
parents:
11711
diff
changeset
|
196 return false; |
35bdfb9ac12f
don't tail duplicate object allocations
Lukas Stadler <lukas.stadler@jku.at>
parents:
11711
diff
changeset
|
197 } |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
198 fixedCount++; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
199 } |
8988
02f57662b6c4
remove monitor limitation form TailDuplicationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
8558
diff
changeset
|
200 if (fixedCount > 1) { |
10533
2faa1e7ef4f3
enable TailDuplication for MergeNodes without stateAfter
Lukas Stadler <lukas.stadler@jku.at>
parents:
10009
diff
changeset
|
201 metricDuplicationConsidered.increment(); |
2faa1e7ef4f3
enable TailDuplication for MergeNodes without stateAfter
Lukas Stadler <lukas.stadler@jku.at>
parents:
10009
diff
changeset
|
202 if (decision.doTransform(merge, fixedCount)) { |
2faa1e7ef4f3
enable TailDuplication for MergeNodes without stateAfter
Lukas Stadler <lukas.stadler@jku.at>
parents:
10009
diff
changeset
|
203 metricDuplicationPerformed.increment(); |
11573
8a3d99fc36cf
Pass canonicalizer into tail duplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
10706
diff
changeset
|
204 new DuplicationOperation(merge, replacements, canonicalizer).duplicate(phaseContext); |
10533
2faa1e7ef4f3
enable TailDuplication for MergeNodes without stateAfter
Lukas Stadler <lukas.stadler@jku.at>
parents:
10009
diff
changeset
|
205 return true; |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
206 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
207 } |
8558
43ab11ee5524
counters for LoopFullUnrollPhase and TailDuplicationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7539
diff
changeset
|
208 return false; |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
209 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
210 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
211 /** |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
212 * This class encapsulates one tail duplication operation on a specific {@link MergeNode}. |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
213 */ |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
214 private static class DuplicationOperation { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
215 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
216 private final MergeNode merge; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
217 private final StructuredGraph graph; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
218 |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18378
diff
changeset
|
219 private final Map<ValueNode, PhiNode> bottomPhis = Node.newMap(); |
10706
8d961f93725c
Use GuardedValueNode in the inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
10533
diff
changeset
|
220 private final List<GuardedValueNode> replacements; |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
221 |
11573
8a3d99fc36cf
Pass canonicalizer into tail duplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
10706
diff
changeset
|
222 private final CanonicalizerPhase canonicalizer; |
8a3d99fc36cf
Pass canonicalizer into tail duplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
10706
diff
changeset
|
223 |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
224 /** |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
225 * Initializes the tail duplication operation without actually performing any work. |
15001 | 226 * |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
227 * @param merge The merge whose tail should be duplicated. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
228 * @param replacements A list of replacement {@link PiNode}s, or null. If this is non-null, |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
229 * then the size of the list needs to match the number of end nodes at the merge. |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
230 */ |
11573
8a3d99fc36cf
Pass canonicalizer into tail duplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
10706
diff
changeset
|
231 public DuplicationOperation(MergeNode merge, List<GuardedValueNode> replacements, CanonicalizerPhase canonicalizer) { |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
232 this.merge = merge; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
233 this.replacements = replacements; |
9602
19c5a07c7843
Introduce a graph() method that returns a StructuredGraph, to make many explicit casts unnecessary
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9436
diff
changeset
|
234 this.graph = merge.graph(); |
11573
8a3d99fc36cf
Pass canonicalizer into tail duplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
10706
diff
changeset
|
235 this.canonicalizer = canonicalizer; |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
236 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
237 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
238 /** |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
239 * Performs the actual tail duplication: |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
240 * <ul> |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
241 * <li>Creates a new {@link ValueAnchorNode} at the beginning of the duplicated area, an |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
242 * transfers all dependencies from the merge to this anchor.</li> |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
243 * <li>Determines the set of fixed nodes to be duplicated.</li> |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
244 * <li>Creates the new merge at the bottom of the duplicated area.</li> |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
245 * <li>Determines the complete set of duplicated nodes.</li> |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
246 * <li>Performs the actual duplication.</li> |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
247 * </ul> |
15001 | 248 * |
9329
fa188fbfe3fe
Perform only targeted canonicalization after tail duplication.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9238
diff
changeset
|
249 * @param phaseContext |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
250 */ |
9329
fa188fbfe3fe
Perform only targeted canonicalization after tail duplication.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9238
diff
changeset
|
251 private void duplicate(PhaseContext phaseContext) { |
9234
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9051
diff
changeset
|
252 Debug.log("tail duplication at merge %s in %s", merge, graph.method()); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
253 |
12686
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
254 Mark startMark = graph.getMark(); |
9329
fa188fbfe3fe
Perform only targeted canonicalization after tail duplication.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9238
diff
changeset
|
255 |
15001 | 256 DummyAnchorNode anchor = addValueAnchor(); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
257 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
258 // determine the fixed nodes that should be duplicated (currently: all nodes up until |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
259 // the first control |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
260 // split, end node, deopt or return. |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
261 ArrayList<FixedNode> fixedNodes = new ArrayList<>(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
262 FixedNode fixed = merge.next(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
263 FrameState stateAfter = merge.stateAfter(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
264 while (fixed instanceof FixedWithNextNode) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
265 fixedNodes.add(fixed); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
266 if (fixed instanceof StateSplit && ((StateSplit) fixed).stateAfter() != null) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
267 stateAfter = ((StateSplit) fixed).stateAfter(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
268 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
269 fixed = ((FixedWithNextNode) fixed).next(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
270 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
271 |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9329
diff
changeset
|
272 AbstractEndNode endAfter = createNewMerge(fixed, stateAfter); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
273 MergeNode mergeAfter = endAfter.merge(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
274 fixedNodes.add(endAfter); |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18378
diff
changeset
|
275 final Set<Node> duplicatedNodes = buildDuplicatedNodeSet(fixedNodes, stateAfter); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
276 mergeAfter.clearEnds(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
277 expandDuplicated(duplicatedNodes, mergeAfter); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
278 |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9329
diff
changeset
|
279 List<AbstractEndNode> endSnapshot = merge.forwardEnds().snapshot(); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
280 List<PhiNode> phiSnapshot = merge.phis().snapshot(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
281 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
282 int endIndex = 0; |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9329
diff
changeset
|
283 for (final AbstractEndNode forwardEnd : merge.forwardEnds()) { |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
284 Map<Node, Node> duplicates; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
285 if (replacements == null || replacements.get(endIndex) == null) { |
11675
77d9f12797c5
Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11652
diff
changeset
|
286 duplicates = graph.addDuplicates(duplicatedNodes, graph, duplicatedNodes.size(), (DuplicationReplacement) null); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
287 } else { |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18378
diff
changeset
|
288 Map<Node, Node> replace = Node.newMap(); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
289 replace.put(replacements.get(endIndex).object(), replacements.get(endIndex)); |
11675
77d9f12797c5
Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11652
diff
changeset
|
290 duplicates = graph.addDuplicates(duplicatedNodes, graph, duplicatedNodes.size(), replace); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
291 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
292 for (Map.Entry<ValueNode, PhiNode> phi : bottomPhis.entrySet()) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
293 phi.getValue().initializeValueAt(merge.forwardEndIndex(forwardEnd), (ValueNode) duplicates.get(phi.getKey())); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
294 } |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9329
diff
changeset
|
295 mergeAfter.addForwardEnd((AbstractEndNode) duplicates.get(endAfter)); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
296 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
297 // re-wire the duplicated ValueAnchorNode to the predecessor of the corresponding |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
298 // EndNode |
15001 | 299 FixedWithNextNode anchorDuplicate = (FixedWithNextNode) duplicates.get(anchor); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
300 // move dependencies on the ValueAnchorNode to the previous BeginNode |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15019
diff
changeset
|
301 BeginNode prevBegin = BeginNode.prevBegin(forwardEnd); |
15001 | 302 anchorDuplicate.replaceAtUsages(InputType.Guard, prevBegin); |
303 anchorDuplicate.replaceAtUsages(InputType.Anchor, prevBegin); | |
304 assert anchorDuplicate.usages().isEmpty(); | |
305 | |
306 FixedNode next = anchorDuplicate.next(); | |
307 anchorDuplicate.setNext(null); | |
308 ((FixedWithNextNode) forwardEnd.predecessor()).setNext(next); | |
309 anchorDuplicate.safeDelete(); | |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
310 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
311 // re-wire the phi duplicates to the correct input |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
312 for (PhiNode phi : phiSnapshot) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
313 PhiNode phiDuplicate = (PhiNode) duplicates.get(phi); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
314 phiDuplicate.replaceAtUsages(phi.valueAt(forwardEnd)); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
315 phiDuplicate.safeDelete(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
316 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
317 endIndex++; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
318 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
319 GraphUtil.killCFG(merge); |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9329
diff
changeset
|
320 for (AbstractEndNode forwardEnd : endSnapshot) { |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
321 forwardEnd.safeDelete(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
322 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
323 for (PhiNode phi : phiSnapshot) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
324 // these phis should go away, but they still need to be anchored to a merge to be |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
325 // valid... |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
326 if (phi.isAlive()) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
327 phi.setMerge(mergeAfter); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
328 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
329 } |
11573
8a3d99fc36cf
Pass canonicalizer into tail duplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
10706
diff
changeset
|
330 canonicalizer.applyIncremental(graph, phaseContext, startMark); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
331 Debug.dump(graph, "After tail duplication at %s", merge); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
332 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
333 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
334 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
335 * Inserts a new ValueAnchorNode after the merge and transfers all dependency-usages (not |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
336 * phis) to this ValueAnchorNode. |
15001 | 337 * |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
338 * @return The new {@link ValueAnchorNode} that was created. |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
339 */ |
15001 | 340 private DummyAnchorNode addValueAnchor() { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18383
diff
changeset
|
341 DummyAnchorNode anchor = graph.add(new DummyAnchorNode()); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
342 graph.addAfterFixed(merge, anchor); |
15001 | 343 merge.replaceAtUsages(InputType.Guard, anchor); |
344 merge.replaceAtUsages(InputType.Anchor, anchor); | |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
345 return anchor; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
346 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
347 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
348 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
349 * Given a set of fixed nodes, this method determines the set of fixed and floating nodes |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
350 * that needs to be duplicated, i.e., all nodes that due to data flow and other dependencies |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
351 * needs to be duplicated. |
15001 | 352 * |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
353 * @param fixedNodes The set of fixed nodes that should be duplicated. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
354 * @param stateAfter The frame state of the merge that follows the set of fixed nodes. All |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
355 * {@link ValueNode}s reachable from this state are considered to be reachable |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
356 * from within the duplicated set of nodes. |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
357 * @return The set of nodes that need to be duplicated. |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
358 */ |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18378
diff
changeset
|
359 private Set<Node> buildDuplicatedNodeSet(final ArrayList<FixedNode> fixedNodes, FrameState stateAfter) { |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
360 final NodeBitMap aboveBound = graph.createNodeBitMap(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
361 final NodeBitMap belowBound = graph.createNodeBitMap(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
362 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
363 final Deque<Node> worklist = new ArrayDeque<>(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
364 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
365 // Build the set of nodes that have (transitive) usages within the duplicatedNodes. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
366 // This is achieved by iterating all nodes that are reachable via inputs from the the |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
367 // fixed nodes. |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
368 aboveBound.markAll(fixedNodes); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
369 worklist.addAll(fixedNodes); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
370 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
371 // the phis at the original merge should always be duplicated |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
372 for (PhiNode phi : merge.phis()) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
373 aboveBound.mark(phi); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
374 worklist.add(phi); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
375 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
376 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
377 NodeClosure<Node> aboveClosure = new NodeClosure<Node>() { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
378 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
379 @Override |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
380 public void apply(Node usage, Node node) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
381 if (node instanceof PhiNode && !fixedNodes.contains(((PhiNode) node).merge())) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
382 // stop iterating: phis belonging to outside merges are known to be outside. |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
383 } else if (node instanceof FixedNode) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
384 // stop iterating: fixed nodes within the given set are traversal roots |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
385 // anyway, and all other |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
386 // fixed nodes are known to be outside. |
13320
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
387 } else if (!aboveBound.isMarked(node)) { |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
388 worklist.add(node); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
389 aboveBound.mark(node); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
390 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
391 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
392 }; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
393 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
394 if (stateAfter != null) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
395 stateAfter.applyToNonVirtual(aboveClosure); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
396 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
397 while (!worklist.isEmpty()) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
398 Node current = worklist.remove(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
399 for (Node input : current.inputs()) { |
13320
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
400 aboveClosure.apply(current, input); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
401 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
402 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
403 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
404 // Build the set of nodes that have (transitive) inputs within the duplicatedNodes. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
405 // This is achieved by iterating all nodes that are reachable via usages from the fixed |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
406 // nodes. |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
407 belowBound.markAll(fixedNodes); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
408 worklist.addAll(fixedNodes); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
409 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
410 // the phis at the original merge should always be duplicated |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
411 for (PhiNode phi : merge.phis()) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
412 belowBound.mark(phi); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
413 worklist.add(phi); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
414 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
415 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
416 while (!worklist.isEmpty()) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
417 Node current = worklist.remove(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
418 for (Node usage : current.usages()) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
419 if (usage instanceof PhiNode && !fixedNodes.contains(((PhiNode) usage).merge())) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
420 // stop iterating: phis belonging to outside merges are known to be outside. |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
421 } else if (usage instanceof FixedNode) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
422 // stop iterating: fixed nodes within the given set are traversal roots |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
423 // anyway, and all other |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
424 // fixed nodes are known to be outside. |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
425 } else if (!belowBound.isMarked(usage)) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
426 worklist.add(usage); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
427 belowBound.mark(usage); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
428 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
429 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
430 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
431 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
432 // build the intersection |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
433 belowBound.intersect(aboveBound); |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18378
diff
changeset
|
434 Set<Node> result = Node.newSet(); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
435 for (Node node : belowBound) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
436 result.add(node); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
437 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
438 return result; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
439 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
440 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
441 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
442 * Creates a new merge and end node construct at the end of the duplicated area. While it is |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
443 * useless in itself (merge with only one end) it simplifies the later duplication step. |
15001 | 444 * |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
445 * @param successor The successor of the duplicated set of nodes, i.e., the first node that |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
446 * should not be duplicated. |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
447 * @param stateAfterMerge The frame state that should be used for the merge. |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
448 * @return The newly created end node. |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
449 */ |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9329
diff
changeset
|
450 private AbstractEndNode createNewMerge(FixedNode successor, FrameState stateAfterMerge) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18383
diff
changeset
|
451 MergeNode newBottomMerge = graph.add(new MergeNode()); |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18383
diff
changeset
|
452 AbstractEndNode newBottomEnd = graph.add(new EndNode()); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
453 newBottomMerge.addForwardEnd(newBottomEnd); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
454 newBottomMerge.setStateAfter(stateAfterMerge); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
455 ((FixedWithNextNode) successor.predecessor()).setNext(newBottomEnd); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
456 newBottomMerge.setNext(successor); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
457 return newBottomEnd; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
458 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
459 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
460 /** |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
461 * Expands the set of nodes to be duplicated by looking at a number of conditions: |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
462 * <ul> |
15006
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
463 * <li>Inputs of type {@link InputType#Value} into the duplicated set will be rerouted to a |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
464 * new phi node.</li> |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
465 * <li>Inputs of type {@link InputType#Association}, {@link InputType#Condition} and |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
466 * {@link InputType#State} into the duplicated set will be rerouted to a duplicated version |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
467 * of the inside node.</li> |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
468 * <li>Dependencies into the duplicated nodes will be replaced with dependencies on the |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
469 * merge.</li> |
15006
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
470 * <li>Inputs of type {@link InputType#Association}, {@link InputType#Condition} and |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
471 * {@link InputType#State} to outside the duplicated set will cause the outside node to be |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
472 * pulled into the duplicated set.</li> |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
473 * </ul> |
15001 | 474 * |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
475 * @param duplicatedNodes The set of duplicated nodes that will be modified (expanded). |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
476 * @param newBottomMerge The merge that follows the duplicated set of nodes. It will be used |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
477 * for newly created phis and to as a target for dependencies that pointed into |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7255
diff
changeset
|
478 * the duplicated set of nodes. |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
479 */ |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18378
diff
changeset
|
480 private void expandDuplicated(Set<Node> duplicatedNodes, MergeNode newBottomMerge) { |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
481 Deque<Node> worklist = new ArrayDeque<>(duplicatedNodes); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
482 |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
483 while (!worklist.isEmpty()) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
484 Node duplicated = worklist.remove(); |
15006
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
485 processUsages(duplicated, duplicatedNodes, newBottomMerge, worklist); |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
486 processInputs(duplicated, duplicatedNodes, worklist); |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
487 } |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
488 } |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
489 |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18378
diff
changeset
|
490 private void processUsages(Node duplicated, Set<Node> duplicatedNodes, MergeNode newBottomMerge, Deque<Node> worklist) { |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18378
diff
changeset
|
491 Set<Node> unique = Node.newSet(); |
15006
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
492 duplicated.usages().snapshotTo(unique); |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
493 Node newOutsideClone = null; |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
494 for (Node usage : unique) { |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
495 if (!duplicatedNodes.contains(usage)) { |
17008
81c9a1fc9072
select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents:
16919
diff
changeset
|
496 NodePosIterator iter = usage.inputs().iterator(); |
15006
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
497 while (iter.hasNext()) { |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
498 Position pos = iter.nextPosition(); |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
499 if (pos.get(usage) == duplicated) { |
17210
ef64e2682bb6
added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents:
17008
diff
changeset
|
500 switch (pos.getInputType()) { |
15019
3498761a33d8
differentiate between tightly coupling edges (Extension) and loosely coupling edges (Association)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15006
diff
changeset
|
501 case Extension: |
15006
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
502 case Condition: |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
503 case State: |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
504 // clone the offending node to the outside |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
505 if (newOutsideClone == null) { |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
506 newOutsideClone = duplicated.copyWithInputs(); |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
507 // this might cause other nodes to have outside usages |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
508 for (Node input : newOutsideClone.inputs()) { |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
509 if (duplicatedNodes.contains(input)) { |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
510 worklist.add(input); |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
511 } |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
512 } |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
513 } |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
514 pos.set(usage, newOutsideClone); |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
515 break; |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
516 case Guard: |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
517 case Anchor: |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
518 // re-route dependencies to the merge |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
519 pos.set(usage, newBottomMerge); |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
520 break; |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
521 case Value: |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
522 // introduce a new phi |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
523 ValueNode node = (ValueNode) duplicated; |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
524 PhiNode newPhi = bottomPhis.get(node); |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
525 if (newPhi == null) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18383
diff
changeset
|
526 newPhi = graph.addWithoutUnique(new ValuePhiNode(node.stamp().unrestricted(), newBottomMerge)); |
15006
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
527 bottomPhis.put(node, newPhi); |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
528 newPhi.addInput(node); |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
529 } |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
530 pos.set(usage, newPhi); |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
531 break; |
15019
3498761a33d8
differentiate between tightly coupling edges (Extension) and loosely coupling edges (Association)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15006
diff
changeset
|
532 case Association: |
15006
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
533 default: |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
534 throw GraalInternalError.shouldNotReachHere(); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
535 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
536 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
537 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
538 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
539 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
540 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
541 |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18378
diff
changeset
|
542 private void processInputs(Node duplicated, Set<Node> duplicatedNodes, Deque<Node> worklist) { |
15006
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
543 // check if this node has an input that lies outside and cannot be shared |
17008
81c9a1fc9072
select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents:
16919
diff
changeset
|
544 NodePosIterator iter = duplicated.inputs().iterator(); |
15006
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
545 while (iter.hasNext()) { |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
546 Position pos = iter.nextPosition(); |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
547 Node input = pos.get(duplicated); |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
548 if (input != null && !duplicatedNodes.contains(input)) { |
17210
ef64e2682bb6
added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents:
17008
diff
changeset
|
549 switch (pos.getInputType()) { |
15019
3498761a33d8
differentiate between tightly coupling edges (Extension) and loosely coupling edges (Association)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15006
diff
changeset
|
550 case Extension: |
15006
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
551 case Condition: |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
552 case State: |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
553 if (input != merge) { |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
554 duplicatedNodes.add(input); |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
555 worklist.add(input); |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
556 } |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
557 break; |
15019
3498761a33d8
differentiate between tightly coupling edges (Extension) and loosely coupling edges (Association)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15006
diff
changeset
|
558 case Association: |
15006
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
559 case Guard: |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
560 case Anchor: |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
561 case Value: |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
562 // no change needed |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
563 break; |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
564 default: |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
565 throw GraalInternalError.shouldNotReachHere(); |
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
566 } |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
567 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
568 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
569 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
570 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
571 } |