Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/util/GraphUtil.java @ 15002:06e50d290784
isAllowedUsageType on Nodes
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Mon, 07 Apr 2014 11:32:08 +0200 |
parents | 2eb56f87b01e |
children | e49f62425090 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
23 package com.oracle.graal.nodes.util; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 import java.util.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
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.graph.*; |
5203
09e87f5b81e4
Fix potential KillCFG problem
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5101
diff
changeset
|
29 import com.oracle.graal.graph.iterators.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
30 import com.oracle.graal.nodes.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
31 import com.oracle.graal.nodes.calc.*; |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
32 import com.oracle.graal.nodes.java.*; |
10762
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
33 import com.oracle.graal.nodes.spi.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 public class GraphUtil { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 |
5806
3842904e46c2
Kill unused floating nodes in Canonicalizer
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5693
diff
changeset
|
37 private static final NodePredicate FLOATING = new NodePredicate() { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
38 |
5806
3842904e46c2
Kill unused floating nodes in Canonicalizer
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5693
diff
changeset
|
39 @Override |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
40 public final boolean apply(Node n) { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
41 // isA(FloatingNode.class).or(VirtualState.class).or(CallTargetNode.class) |
5806
3842904e46c2
Kill unused floating nodes in Canonicalizer
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5693
diff
changeset
|
42 return n instanceof FloatingNode || n instanceof VirtualState || n instanceof CallTargetNode; |
3842904e46c2
Kill unused floating nodes in Canonicalizer
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5693
diff
changeset
|
43 } |
3842904e46c2
Kill unused floating nodes in Canonicalizer
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5693
diff
changeset
|
44 }; |
5305
527ff42e0b26
In canonicalizer, when cleaning node with no usages, use a better definition of 'floating' node
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5210
diff
changeset
|
45 |
11879
7e57add9c0d5
broadened types in SimplifierTool interface so that it can be moved to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
10762
diff
changeset
|
46 public static void killCFG(Node node) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 assert node.isAlive(); |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9389
diff
changeset
|
48 if (node instanceof AbstractEndNode) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 // We reached a control flow end. |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9389
diff
changeset
|
50 AbstractEndNode end = (AbstractEndNode) node; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 killEnd(end); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 // Normal control flow node. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
54 /* |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
55 * We do not take a successor snapshot because this iterator supports concurrent |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
56 * modifications as long as they do not change the size of the successor list. Not |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
57 * taking a snapshot allows us to see modifications to other branches that may happen |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
58 * while processing one branch. |
5203
09e87f5b81e4
Fix potential KillCFG problem
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5101
diff
changeset
|
59 */ |
09e87f5b81e4
Fix potential KillCFG problem
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5101
diff
changeset
|
60 for (Node successor : node.successors()) { |
11879
7e57add9c0d5
broadened types in SimplifierTool interface so that it can be moved to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
10762
diff
changeset
|
61 killCFG(successor); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
64 propagateKill(node); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
65 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
66 |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9389
diff
changeset
|
67 private static void killEnd(AbstractEndNode end) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 MergeNode merge = end.merge(); |
5589
728cf399b18d
fix NPE when using killCFG to delete an EndNode without a merge
Lukas Stadler <lukas.stadler@jku.at>
parents:
5563
diff
changeset
|
69 if (merge != null) { |
728cf399b18d
fix NPE when using killCFG to delete an EndNode without a merge
Lukas Stadler <lukas.stadler@jku.at>
parents:
5563
diff
changeset
|
70 merge.removeEnd(end); |
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
|
71 StructuredGraph graph = end.graph(); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
72 if (merge instanceof LoopBeginNode && merge.forwardEndCount() == 0) { // dead loop |
5589
728cf399b18d
fix NPE when using killCFG to delete an EndNode without a merge
Lukas Stadler <lukas.stadler@jku.at>
parents:
5563
diff
changeset
|
73 for (PhiNode phi : merge.phis().snapshot()) { |
728cf399b18d
fix NPE when using killCFG to delete an EndNode without a merge
Lukas Stadler <lukas.stadler@jku.at>
parents:
5563
diff
changeset
|
74 propagateKill(phi); |
728cf399b18d
fix NPE when using killCFG to delete an EndNode without a merge
Lukas Stadler <lukas.stadler@jku.at>
parents:
5563
diff
changeset
|
75 } |
728cf399b18d
fix NPE when using killCFG to delete an EndNode without a merge
Lukas Stadler <lukas.stadler@jku.at>
parents:
5563
diff
changeset
|
76 LoopBeginNode begin = (LoopBeginNode) merge; |
728cf399b18d
fix NPE when using killCFG to delete an EndNode without a merge
Lukas Stadler <lukas.stadler@jku.at>
parents:
5563
diff
changeset
|
77 // disconnect and delete loop ends & loop exits |
728cf399b18d
fix NPE when using killCFG to delete an EndNode without a merge
Lukas Stadler <lukas.stadler@jku.at>
parents:
5563
diff
changeset
|
78 for (LoopEndNode loopend : begin.loopEnds().snapshot()) { |
728cf399b18d
fix NPE when using killCFG to delete an EndNode without a merge
Lukas Stadler <lukas.stadler@jku.at>
parents:
5563
diff
changeset
|
79 loopend.predecessor().replaceFirstSuccessor(loopend, null); |
728cf399b18d
fix NPE when using killCFG to delete an EndNode without a merge
Lukas Stadler <lukas.stadler@jku.at>
parents:
5563
diff
changeset
|
80 loopend.safeDelete(); |
728cf399b18d
fix NPE when using killCFG to delete an EndNode without a merge
Lukas Stadler <lukas.stadler@jku.at>
parents:
5563
diff
changeset
|
81 } |
6318
8886fdfde36c
Factor out code that kills loop exits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5811
diff
changeset
|
82 begin.removeExits(); |
7245
1e099e2c6197
Fix for KillCFG while killing infinite empty loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6539
diff
changeset
|
83 FixedNode loopBody = begin.next(); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
84 if (loopBody != null) { // for small infinite loops, the body may be killed while |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
85 // killing the loop ends |
7245
1e099e2c6197
Fix for KillCFG while killing infinite empty loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6539
diff
changeset
|
86 killCFG(loopBody); |
1e099e2c6197
Fix for KillCFG while killing infinite empty loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6539
diff
changeset
|
87 } |
5589
728cf399b18d
fix NPE when using killCFG to delete an EndNode without a merge
Lukas Stadler <lukas.stadler@jku.at>
parents:
5563
diff
changeset
|
88 begin.safeDelete(); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
89 } else if (merge instanceof LoopBeginNode && ((LoopBeginNode) merge).loopEnds().isEmpty()) { // not |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
90 // a |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
91 // loop |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
92 // anymore |
5589
728cf399b18d
fix NPE when using killCFG to delete an EndNode without a merge
Lukas Stadler <lukas.stadler@jku.at>
parents:
5563
diff
changeset
|
93 graph.reduceDegenerateLoopBegin((LoopBeginNode) merge); |
728cf399b18d
fix NPE when using killCFG to delete an EndNode without a merge
Lukas Stadler <lukas.stadler@jku.at>
parents:
5563
diff
changeset
|
94 } else if (merge.phiPredecessorCount() == 1) { // not a merge anymore |
728cf399b18d
fix NPE when using killCFG to delete an EndNode without a merge
Lukas Stadler <lukas.stadler@jku.at>
parents:
5563
diff
changeset
|
95 graph.reduceTrivialMerge(merge); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
96 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
97 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
98 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
99 |
5203
09e87f5b81e4
Fix potential KillCFG problem
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5101
diff
changeset
|
100 public static NodePredicate isFloatingNode() { |
5305
527ff42e0b26
In canonicalizer, when cleaning node with no usages, use a better definition of 'floating' node
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5210
diff
changeset
|
101 return FLOATING; |
5203
09e87f5b81e4
Fix potential KillCFG problem
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5101
diff
changeset
|
102 } |
09e87f5b81e4
Fix potential KillCFG problem
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5101
diff
changeset
|
103 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 public static void propagateKill(Node node) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 if (node != null && node.isAlive()) { |
5203
09e87f5b81e4
Fix potential KillCFG problem
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5101
diff
changeset
|
106 List<Node> usagesSnapshot = node.usages().filter(isFloatingNode()).snapshot(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
107 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
108 // null out remaining usages |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
109 node.replaceAtUsages(null); |
5487
9743ae819f73
Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5305
diff
changeset
|
110 node.replaceAtPredecessor(null); |
5305
527ff42e0b26
In canonicalizer, when cleaning node with no usages, use a better definition of 'floating' node
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5210
diff
changeset
|
111 killWithUnusedFloatingInputs(node); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
112 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
113 for (Node usage : usagesSnapshot) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
114 if (!usage.isDeleted()) { |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4309
diff
changeset
|
115 if (usage instanceof PhiNode) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4309
diff
changeset
|
116 usage.replaceFirstInput(node, null); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4309
diff
changeset
|
117 } else { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4309
diff
changeset
|
118 propagateKill(usage); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4309
diff
changeset
|
119 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
120 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
121 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
122 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
123 } |
4619
a09b44a28e7f
clenup unused floating nodes on killCFG
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
124 |
5305
527ff42e0b26
In canonicalizer, when cleaning node with no usages, use a better definition of 'floating' node
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5210
diff
changeset
|
125 public static void killWithUnusedFloatingInputs(Node node) { |
13320
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12665
diff
changeset
|
126 if (node.recordsUsages()) { |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11879
diff
changeset
|
127 List<Node> floatingInputs = node.inputs().filter(isFloatingNode()).snapshot(); |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11879
diff
changeset
|
128 node.safeDelete(); |
4619
a09b44a28e7f
clenup unused floating nodes on killCFG
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
129 |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11879
diff
changeset
|
130 for (Node in : floatingInputs) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11879
diff
changeset
|
131 if (in.isAlive() && (!in.recordsUsages() || in.usages().isEmpty())) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11879
diff
changeset
|
132 killWithUnusedFloatingInputs(in); |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11879
diff
changeset
|
133 } |
4619
a09b44a28e7f
clenup unused floating nodes on killCFG
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
134 } |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11879
diff
changeset
|
135 } else { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11879
diff
changeset
|
136 assert node.inputs().isEmpty(); |
4619
a09b44a28e7f
clenup unused floating nodes on killCFG
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
137 } |
a09b44a28e7f
clenup unused floating nodes on killCFG
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
138 } |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
139 |
13794
2eb56f87b01e
add GraphUtil.removeFixedWithUnusedInputs
Lukas Stadler <lukas.stadler@jku.at>
parents:
13320
diff
changeset
|
140 public static void removeFixedWithUnusedInputs(FixedWithNextNode fixed) { |
2eb56f87b01e
add GraphUtil.removeFixedWithUnusedInputs
Lukas Stadler <lukas.stadler@jku.at>
parents:
13320
diff
changeset
|
141 FixedNode next = fixed.next(); |
2eb56f87b01e
add GraphUtil.removeFixedWithUnusedInputs
Lukas Stadler <lukas.stadler@jku.at>
parents:
13320
diff
changeset
|
142 fixed.setNext(null); |
2eb56f87b01e
add GraphUtil.removeFixedWithUnusedInputs
Lukas Stadler <lukas.stadler@jku.at>
parents:
13320
diff
changeset
|
143 fixed.replaceAtPredecessor(next); |
2eb56f87b01e
add GraphUtil.removeFixedWithUnusedInputs
Lukas Stadler <lukas.stadler@jku.at>
parents:
13320
diff
changeset
|
144 killWithUnusedFloatingInputs(fixed); |
2eb56f87b01e
add GraphUtil.removeFixedWithUnusedInputs
Lukas Stadler <lukas.stadler@jku.at>
parents:
13320
diff
changeset
|
145 } |
2eb56f87b01e
add GraphUtil.removeFixedWithUnusedInputs
Lukas Stadler <lukas.stadler@jku.at>
parents:
13320
diff
changeset
|
146 |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
147 public static void checkRedundantPhi(PhiNode phiNode) { |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
148 if (phiNode.isDeleted() || phiNode.valueCount() == 1) { |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
149 return; |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
150 } |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
151 |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
152 ValueNode singleValue = phiNode.singleValue(); |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
153 if (singleValue != null) { |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
154 Collection<PhiNode> phiUsages = phiNode.usages().filter(PhiNode.class).snapshot(); |
7897
a58851061377
rename ValueProxyNode to ProxyNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7731
diff
changeset
|
155 Collection<ProxyNode> proxyUsages = phiNode.usages().filter(ProxyNode.class).snapshot(); |
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
|
156 phiNode.graph().replaceFloating(phiNode, singleValue); |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
157 for (PhiNode phi : phiUsages) { |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
158 checkRedundantPhi(phi); |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
159 } |
7897
a58851061377
rename ValueProxyNode to ProxyNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7731
diff
changeset
|
160 for (ProxyNode proxy : proxyUsages) { |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
161 checkRedundantProxy(proxy); |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
162 } |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
163 } |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
164 } |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
165 |
7897
a58851061377
rename ValueProxyNode to ProxyNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7731
diff
changeset
|
166 public static void checkRedundantProxy(ProxyNode vpn) { |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
167 AbstractBeginNode proxyPoint = vpn.proxyPoint(); |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
168 if (proxyPoint instanceof LoopExitNode) { |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
169 LoopExitNode exit = (LoopExitNode) proxyPoint; |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
170 LoopBeginNode loopBegin = exit.loopBegin(); |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
171 ValueNode vpnValue = vpn.value(); |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
172 for (ValueNode v : loopBegin.stateAfter().values()) { |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
173 ValueNode v2 = v; |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
174 if (loopBegin.isPhiAtMerge(v2)) { |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
175 v2 = ((PhiNode) v2).valueAt(loopBegin.forwardEnd()); |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
176 } |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
177 if (vpnValue == v2) { |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
178 Collection<PhiNode> phiUsages = vpn.usages().filter(PhiNode.class).snapshot(); |
7897
a58851061377
rename ValueProxyNode to ProxyNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7731
diff
changeset
|
179 Collection<ProxyNode> proxyUsages = vpn.usages().filter(ProxyNode.class).snapshot(); |
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
|
180 vpn.graph().replaceFloating(vpn, vpnValue); |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
181 for (PhiNode phi : phiUsages) { |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
182 checkRedundantPhi(phi); |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
183 } |
7897
a58851061377
rename ValueProxyNode to ProxyNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7731
diff
changeset
|
184 for (ProxyNode proxy : proxyUsages) { |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
185 checkRedundantProxy(proxy); |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
186 } |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
187 return; |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
188 } |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
189 } |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
190 } |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
191 } |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
192 |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
193 public static void normalizeLoopBegin(LoopBeginNode begin) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
194 // Delete unnecessary loop phi functions, i.e., phi functions where all inputs are either |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
195 // the same or the phi itself. |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
196 for (PhiNode phi : begin.phis().snapshot()) { |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
197 GraphUtil.checkRedundantPhi(phi); |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
198 } |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
199 for (LoopExitNode exit : begin.loopExits()) { |
7897
a58851061377
rename ValueProxyNode to ProxyNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7731
diff
changeset
|
200 for (ProxyNode vpn : exit.proxies().snapshot()) { |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
201 GraphUtil.checkRedundantProxy(vpn); |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
202 } |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
203 } |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
204 } |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5203
diff
changeset
|
205 |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
206 /** |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
207 * Gets an approximate source code location for a node if possible. |
15002
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13794
diff
changeset
|
208 * |
7310
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
209 * @return the StackTraceElements if an approximate source location is found, null otherwise |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
210 */ |
7310
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
211 public static StackTraceElement[] approxSourceStackTraceElement(Node node) { |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
212 ArrayList<StackTraceElement> elements = new ArrayList<>(); |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
213 Node n = node; |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
214 while (n != null) { |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
215 if (n instanceof MethodCallTargetNode) { |
7310
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
216 elements.add(((MethodCallTargetNode) n).targetMethod().asStackTraceElement(-1)); |
9089
5ab06146e985
Rename "node()" methods in interfaces to "asNode"
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7897
diff
changeset
|
217 n = ((MethodCallTargetNode) n).invoke().asNode(); |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
218 } |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
219 |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
220 if (n instanceof StateSplit) { |
7310
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
221 FrameState state = ((StateSplit) n).stateAfter(); |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
222 while (state != null) { |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
223 ResolvedJavaMethod method = state.method(); |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
224 if (method != null) { |
7310
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
225 elements.add(method.asStackTraceElement(state.bci - 1)); |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
226 } |
7310
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
227 state = state.outerFrameState(); |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
228 } |
7310
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
229 break; |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
230 } |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
231 n = n.predecessor(); |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
232 } |
7310
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
233 return elements.toArray(new StackTraceElement[elements.size()]); |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
234 } |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
235 |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
236 /** |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
237 * Gets an approximate source code location for a node, encoded as an exception, if possible. |
15002
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13794
diff
changeset
|
238 * |
7310
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
239 * @return the exception with the location |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
240 */ |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
241 public static RuntimeException approxSourceException(Node node, Throwable cause) { |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
242 final StackTraceElement[] elements = approxSourceStackTraceElement(node); |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
243 @SuppressWarnings("serial") |
9389
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9089
diff
changeset
|
244 RuntimeException exception = new RuntimeException((cause == null) ? null : cause.getMessage(), cause) { |
7310
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
245 |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
246 @Override |
7731
8b7996916df6
Make fillInStackTrace final and non-synchronized in exceptions that do not need stack trace.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
247 public final synchronized Throwable fillInStackTrace() { |
7310
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
248 setStackTrace(elements); |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
249 return this; |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
250 } |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
251 }; |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
252 return exception; |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
253 } |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
254 |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
255 /** |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
256 * Gets an approximate source code location for a node if possible. |
15002
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13794
diff
changeset
|
257 * |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
258 * @return a file name and source line number in stack trace format (e.g. "String.java:32") if |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
259 * an approximate source location is found, null otherwise |
7310
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
260 */ |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
261 public static String approxSourceLocation(Node node) { |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
262 StackTraceElement[] stackTraceElements = approxSourceStackTraceElement(node); |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
263 if (stackTraceElements != null && stackTraceElements.length > 0) { |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
264 StackTraceElement top = stackTraceElements[0]; |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
265 if (top.getFileName() != null && top.getLineNumber() >= 0) { |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
266 return top.getFileName() + ":" + top.getLineNumber(); |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
267 } |
79a7b761755c
Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7245
diff
changeset
|
268 } |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
269 return null; |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
270 } |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5487
diff
changeset
|
271 |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5693
diff
changeset
|
272 /** |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5693
diff
changeset
|
273 * Returns a string representation of the given collection of objects. |
15002
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13794
diff
changeset
|
274 * |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5693
diff
changeset
|
275 * @param objects The {@link Iterable} that will be used to iterate over the objects. |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5693
diff
changeset
|
276 * @return A string of the format "[a, b, ...]". |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5693
diff
changeset
|
277 */ |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
278 public static String toString(Iterable<?> objects) { |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5693
diff
changeset
|
279 StringBuilder str = new StringBuilder(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5693
diff
changeset
|
280 str.append("["); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5693
diff
changeset
|
281 for (Object o : objects) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5693
diff
changeset
|
282 str.append(o).append(", "); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5693
diff
changeset
|
283 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5693
diff
changeset
|
284 if (str.length() > 1) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5693
diff
changeset
|
285 str.setLength(str.length() - 2); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5693
diff
changeset
|
286 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5693
diff
changeset
|
287 str.append("]"); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5693
diff
changeset
|
288 return str.toString(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5693
diff
changeset
|
289 } |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6318
diff
changeset
|
290 |
6444
5ebe3e5a892b
fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents:
6436
diff
changeset
|
291 /** |
10762
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
292 * Gets the original value by iterating through all {@link ValueProxy ValueProxies}. |
15002
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13794
diff
changeset
|
293 * |
10762
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
294 * @param value The start value. |
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
295 * @return The first non-proxy value encountered. |
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
296 */ |
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
297 public static ValueNode unproxify(ValueNode value) { |
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
298 ValueNode result = value; |
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
299 while (result instanceof ValueProxy) { |
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
300 result = ((ValueProxy) result).getOriginalValue(); |
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
301 } |
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
302 return result; |
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
303 } |
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
304 |
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
305 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7310
diff
changeset
|
306 * Tries to find an original value of the given node by traversing through proxies and |
10762
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
307 * unambiguous phis. Note that this method will perform an exhaustive search through phis. It is |
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
308 * intended to be used during graph building, when phi nodes aren't yet canonicalized. |
15002
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13794
diff
changeset
|
309 * |
6444
5ebe3e5a892b
fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents:
6436
diff
changeset
|
310 * @param proxy The node whose original value should be determined. |
5ebe3e5a892b
fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents:
6436
diff
changeset
|
311 */ |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6318
diff
changeset
|
312 public static ValueNode originalValue(ValueNode proxy) { |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6318
diff
changeset
|
313 ValueNode v = proxy; |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6318
diff
changeset
|
314 do { |
10762
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
315 if (v instanceof ValueProxy) { |
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
316 v = ((ValueProxy) v).getOriginalValue(); |
6444
5ebe3e5a892b
fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents:
6436
diff
changeset
|
317 } else if (v instanceof PhiNode) { |
5ebe3e5a892b
fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents:
6436
diff
changeset
|
318 v = ((PhiNode) v).singleValue(); |
5ebe3e5a892b
fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents:
6436
diff
changeset
|
319 } else { |
5ebe3e5a892b
fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents:
6436
diff
changeset
|
320 break; |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6318
diff
changeset
|
321 } |
6444
5ebe3e5a892b
fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents:
6436
diff
changeset
|
322 } while (v != null); |
5ebe3e5a892b
fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents:
6436
diff
changeset
|
323 |
5ebe3e5a892b
fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents:
6436
diff
changeset
|
324 if (v == null) { |
12665
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
325 v = new OriginalValueSearch(proxy).result; |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
326 } |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
327 return v; |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
328 } |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
329 |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
330 /** |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
331 * Exhaustive search for {@link GraphUtil#originalValue(ValueNode)} when a simple search fails. |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
332 * This can happen in the presence of complicated phi/proxy/phi constructs. |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
333 */ |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
334 static class OriginalValueSearch { |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
335 ValueNode result; |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
336 |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
337 public OriginalValueSearch(ValueNode proxy) { |
6444
5ebe3e5a892b
fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents:
6436
diff
changeset
|
338 NodeWorkList worklist = proxy.graph().createNodeWorkList(); |
5ebe3e5a892b
fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents:
6436
diff
changeset
|
339 worklist.add(proxy); |
5ebe3e5a892b
fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents:
6436
diff
changeset
|
340 for (Node node : worklist) { |
10762
c483912aaf70
add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
341 if (node instanceof ValueProxy) { |
12665
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
342 ValueNode originalValue = ((ValueProxy) node).getOriginalValue(); |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
343 if (!process(originalValue, worklist)) { |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
344 return; |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
345 } |
6444
5ebe3e5a892b
fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents:
6436
diff
changeset
|
346 } else if (node instanceof PhiNode) { |
12665
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
347 for (Node value : ((PhiNode) node).values()) { |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
348 if (!process((ValueNode) value, worklist)) { |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
349 return; |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
350 } |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
351 } |
6444
5ebe3e5a892b
fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents:
6436
diff
changeset
|
352 } else { |
12665
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
353 if (!process((ValueNode) node, null)) { |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
354 return; |
6444
5ebe3e5a892b
fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents:
6436
diff
changeset
|
355 } |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6318
diff
changeset
|
356 } |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6318
diff
changeset
|
357 } |
6444
5ebe3e5a892b
fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents:
6436
diff
changeset
|
358 } |
12665
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
359 |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
360 /** |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
361 * Process a node as part of this search. |
15002
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13794
diff
changeset
|
362 * |
12665
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
363 * @param node the next node encountered in the search |
13320
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12665
diff
changeset
|
364 * @param worklist if non-null, {@code node} will be added to this list. Otherwise, |
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12665
diff
changeset
|
365 * {@code node} is treated as a candidate result. |
12665
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
366 * @return true if the search should continue, false if a definitive {@link #result} has |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
367 * been found |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
368 */ |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
369 private boolean process(ValueNode node, NodeWorkList worklist) { |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
370 if (node.isAlive()) { |
13320
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12665
diff
changeset
|
371 if (worklist == null) { |
12665
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
372 if (result == null) { |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
373 // Initial candidate result: continue search |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
374 result = node; |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
375 } else if (result != node) { |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
376 // Conflicts with existing candidate: stop search with null result |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
377 result = null; |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
378 return false; |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
379 } |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
380 } else { |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
381 worklist.add(node); |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
382 } |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
383 } |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
384 return true; |
9db9e37ee4b8
fixes for regression in Jython performance
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
385 } |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6318
diff
changeset
|
386 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
387 } |