Mercurial > hg > truffle
annotate graal/com.oracle.max.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java @ 5060:4ed4295ce15f
Update import statements.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 08 Mar 2012 19:11:12 +0100 |
parents | ed559a528128 |
children |
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; |
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 |
4203
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
27 import com.oracle.max.cri.ri.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
28 import com.oracle.graal.graph.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
29 import com.oracle.graal.nodes.calc.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
30 import com.oracle.graal.nodes.java.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
31 import com.oracle.graal.nodes.util.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 |
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 * A graph that contains at least one distinguished node : the {@link #start() start} node. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 * This node is the start of the control flow of the graph. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 public class StructuredGraph extends Graph { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 private final BeginNode start; |
4203
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
40 private final RiResolvedMethod method; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 * Creates a new Graph containing a single {@link BeginNode} as the {@link #start() start} node. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 public StructuredGraph(String name) { |
4203
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
46 this(name, null); |
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
47 } |
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
48 |
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
49 public StructuredGraph(String name, RiResolvedMethod method) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 super(name); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 this.start = add(new BeginNode()); |
4203
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
52 this.method = method; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 * Creates a new Graph containing a single {@link BeginNode} as the {@link #start() start} node. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 public StructuredGraph() { |
4203
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
59 this((String) null); |
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
60 } |
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
61 |
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
62 public StructuredGraph(RiResolvedMethod method) { |
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
63 this(null, method); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
64 } |
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 public BeginNode start() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
67 return start; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 |
4203
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
70 public RiResolvedMethod method() { |
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
71 return method; |
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
72 } |
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
73 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 public StructuredGraph copy() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 return copy(name); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
77 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 @Override |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
80 public StructuredGraph copy(String newName) { |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
81 StructuredGraph copy = new StructuredGraph(newName); |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
82 HashMap<Node, Node> replacements = new HashMap<>(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 replacements.put(start, copy.start); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
84 copy.addDuplicates(getNodes(), replacements); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 return copy; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
88 public LocalNode getLocal(int index) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
89 for (LocalNode local : getNodes(LocalNode.class)) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
90 if (local.index() == index) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
91 return local; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
92 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
93 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
94 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
95 } |
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 public Iterable<Invoke> getInvokes() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
98 final Iterator<MethodCallTargetNode> callTargets = getNodes(MethodCallTargetNode.class).iterator(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
99 return new Iterable<Invoke>() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
100 private Invoke next; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
101 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 public Iterator<Invoke> iterator() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 return new Iterator<Invoke>() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
106 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
107 public boolean hasNext() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
108 if (next == null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
109 while (callTargets.hasNext()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
110 Invoke i = callTargets.next().invoke(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
111 if (i != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
112 next = i; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
113 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
114 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
115 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
116 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
119 } |
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 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
123 public Invoke next() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
124 try { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
125 return next; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 } finally { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 next = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
129 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
130 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
131 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
132 public void remove() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
133 throw new UnsupportedOperationException(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
134 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
135 }; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
136 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
137 }; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
138 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
139 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
140 public boolean hasLoops() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
141 return getNodes(LoopBeginNode.class).iterator().hasNext(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
142 } |
4305
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
143 |
4309
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4305
diff
changeset
|
144 public void removeFloating(FloatingNode node) { |
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4305
diff
changeset
|
145 assert node != null && node.isAlive() : "cannot remove " + node; |
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4305
diff
changeset
|
146 node.safeDelete(); |
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4305
diff
changeset
|
147 } |
4305
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
148 |
4309
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4305
diff
changeset
|
149 public void replaceFloating(FloatingNode node, ValueNode replacement) { |
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4305
diff
changeset
|
150 assert node != null && replacement != null && node.isAlive() && replacement.isAlive() : "cannot replace " + node + " with " + replacement; |
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4305
diff
changeset
|
151 node.replaceAtUsages(replacement); |
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4305
diff
changeset
|
152 node.safeDelete(); |
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4305
diff
changeset
|
153 } |
4305
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
154 |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
155 public void removeFixed(FixedWithNextNode node) { |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
156 assert node != null; |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
157 assert node.usages().isEmpty() : node + " " + node.usages(); |
4305
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
158 FixedNode next = node.next(); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
159 node.setNext(null); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
160 node.replaceAtPredecessors(next); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
161 node.safeDelete(); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
162 } |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
163 |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
164 public void replaceFixed(FixedWithNextNode node, Node replacement) { |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
165 if (replacement instanceof FixedWithNextNode) { |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
166 replaceFixedWithFixed(node, (FixedWithNextNode) replacement); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
167 } else { |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
168 assert replacement != null : "cannot replace " + node + " with null"; |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
169 assert replacement instanceof FloatingNode : "cannot replace " + node + " with " + replacement; |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
170 replaceFixedWithFloating(node, (FloatingNode) replacement); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
171 } |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
172 } |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
173 |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
174 public void replaceFixedWithFixed(FixedWithNextNode node, FixedWithNextNode replacement) { |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
175 assert node != null && replacement != null && node.isAlive() && replacement.isAlive() : "cannot replace " + node + " with " + replacement; |
4419
2302b1514e7e
set probability of nodes added to the cfg graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
4338
diff
changeset
|
176 replacement.setProbability(node.probability()); |
4305
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
177 FixedNode next = node.next(); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
178 node.setNext(null); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
179 replacement.setNext(next); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
180 node.replaceAndDelete(replacement); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
181 } |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
182 |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
183 public void replaceFixedWithFloating(FixedWithNextNode node, FloatingNode replacement) { |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
184 assert node != null && replacement != null && node.isAlive() && replacement.isAlive() : "cannot replace " + node + " with " + replacement; |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
185 FixedNode next = node.next(); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
186 node.setNext(null); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
187 node.replaceAtPredecessors(next); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
188 node.replaceAtUsages(replacement); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
189 node.safeDelete(); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
190 } |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
191 |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
192 public void removeSplit(ControlSplitNode node, int survivingSuccessor) { |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
193 assert node != null; |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
194 assert node.usages().isEmpty(); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
195 assert survivingSuccessor >= 0 && survivingSuccessor < node.blockSuccessorCount() : "invalid surviving successor " + survivingSuccessor + " for " + node; |
4338 | 196 BeginNode begin = node.blockSuccessor(survivingSuccessor); |
4599
97d11635f2bf
evacuate guards when deleting control splits
Lukas Stadler <lukas.stadler@jku.at>
parents:
4419
diff
changeset
|
197 begin.evacuateGuards(); |
4338 | 198 FixedNode next = begin.next(); |
199 begin.setNext(null); | |
4305
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
200 for (int i = 0; i < node.blockSuccessorCount(); i++) { |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
201 node.setBlockSuccessor(i, null); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
202 } |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
203 node.replaceAtPredecessors(next); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
204 node.safeDelete(); |
4621 | 205 begin.safeDelete(); |
4338 | 206 } |
207 | |
208 public void removeSplitPropagate(ControlSplitNode node, int survivingSuccessor) { | |
209 assert node != null; | |
210 assert node.usages().isEmpty(); | |
211 assert survivingSuccessor >= 0 && survivingSuccessor < node.blockSuccessorCount() : "invalid surviving successor " + survivingSuccessor + " for " + node; | |
212 BeginNode begin = node.blockSuccessor(survivingSuccessor); | |
4599
97d11635f2bf
evacuate guards when deleting control splits
Lukas Stadler <lukas.stadler@jku.at>
parents:
4419
diff
changeset
|
213 begin.evacuateGuards(); |
4338 | 214 FixedNode next = begin.next(); |
215 begin.setNext(null); | |
216 for (int i = 0; i < node.blockSuccessorCount(); i++) { | |
217 BeginNode successor = node.blockSuccessor(i); | |
218 node.setBlockSuccessor(i, null); | |
219 if (successor != begin && successor.isAlive()) { | |
220 GraphUtil.killCFG(successor); | |
221 } | |
222 } | |
223 if (next.isAlive()) { | |
224 node.replaceAtPredecessors(next); | |
225 node.safeDelete(); | |
226 begin.safeDelete(); | |
227 } else { | |
228 assert node.isDeleted(); | |
229 } | |
4305
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
230 } |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
231 |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
232 public void replaceSplit(ControlSplitNode node, Node replacement, int survivingSuccessor) { |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
233 if (replacement instanceof FixedWithNextNode) { |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
234 replaceSplitWithFixed(node, (FixedWithNextNode) replacement, survivingSuccessor); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
235 } else { |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
236 assert replacement != null : "cannot replace " + node + " with null"; |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
237 assert replacement instanceof FloatingNode : "cannot replace " + node + " with " + replacement; |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
238 replaceSplitWithFloating(node, (FloatingNode) replacement, survivingSuccessor); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
239 } |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
240 } |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
241 |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
242 public void replaceSplitWithFixed(ControlSplitNode node, FixedWithNextNode replacement, int survivingSuccessor) { |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
243 assert node != null && replacement != null && node.isAlive() && replacement.isAlive() : "cannot replace " + node + " with " + replacement; |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
244 assert survivingSuccessor >= 0 && survivingSuccessor < node.blockSuccessorCount() : "invalid surviving successor " + survivingSuccessor + " for " + node; |
4338 | 245 BeginNode begin = node.blockSuccessor(survivingSuccessor); |
4599
97d11635f2bf
evacuate guards when deleting control splits
Lukas Stadler <lukas.stadler@jku.at>
parents:
4419
diff
changeset
|
246 begin.evacuateGuards(); |
4338 | 247 FixedNode next = begin.next(); |
248 begin.setNext(null); | |
4305
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
249 for (int i = 0; i < node.blockSuccessorCount(); i++) { |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
250 node.setBlockSuccessor(i, null); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
251 } |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
252 replacement.setNext(next); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
253 node.replaceAndDelete(replacement); |
4338 | 254 begin.safeDelete(); |
4305
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
255 } |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
256 |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
257 public void replaceSplitWithFloating(ControlSplitNode node, FloatingNode replacement, int survivingSuccessor) { |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
258 assert node != null && replacement != null && node.isAlive() && replacement.isAlive() : "cannot replace " + node + " with " + replacement; |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
259 assert survivingSuccessor >= 0 && survivingSuccessor < node.blockSuccessorCount() : "invalid surviving successor " + survivingSuccessor + " for " + node; |
4338 | 260 BeginNode begin = node.blockSuccessor(survivingSuccessor); |
4599
97d11635f2bf
evacuate guards when deleting control splits
Lukas Stadler <lukas.stadler@jku.at>
parents:
4419
diff
changeset
|
261 begin.evacuateGuards(); |
4338 | 262 FixedNode next = begin.next(); |
263 begin.setNext(null); | |
4305
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
264 for (int i = 0; i < node.blockSuccessorCount(); i++) { |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
265 node.setBlockSuccessor(i, null); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
266 } |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
267 node.replaceAtPredecessors(next); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
268 node.replaceAtUsages(replacement); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
269 node.safeDelete(); |
4338 | 270 begin.safeDelete(); |
4305
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
271 } |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
272 |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
273 public void addAfterFixed(FixedWithNextNode node, FixedWithNextNode newNode) { |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
274 assert node != null && newNode != null && node.isAlive() && newNode.isAlive() : "cannot add " + newNode + " after " + node; |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
275 assert newNode.next() == null; |
4419
2302b1514e7e
set probability of nodes added to the cfg graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
4338
diff
changeset
|
276 newNode.setProbability(node.probability()); |
4305
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
277 FixedNode next = node.next(); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
278 node.setNext(newNode); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
279 newNode.setNext(next); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
280 } |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
281 |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
282 public void addBeforeFixed(FixedNode node, FixedWithNextNode newNode) { |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
283 assert node != null && newNode != null && node.isAlive() && newNode.isAlive() : "cannot add " + newNode + " before " + node; |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
284 assert node.predecessor() != null && node.predecessor() instanceof FixedWithNextNode : "cannot add " + newNode + " before " + node; |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
285 assert newNode.next() == null; |
4419
2302b1514e7e
set probability of nodes added to the cfg graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
4338
diff
changeset
|
286 newNode.setProbability(node.probability()); |
4305
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
287 FixedWithNextNode pred = (FixedWithNextNode) node.predecessor(); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
288 pred.setNext(newNode); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
289 newNode.setNext(node); |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
290 } |
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4203
diff
changeset
|
291 |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
292 public void reduceDegenerateLoopBegin(LoopBeginNode begin) { |
4619
a09b44a28e7f
clenup unused floating nodes on killCFG
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
293 assert begin.loopEnds().isEmpty() : "Loop begin still has backedges"; |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
294 if (begin.forwardEndCount() == 1) { // bypass merge and remove |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
295 reduceTrivialMerge(begin); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
296 } else { // convert to merge |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
297 MergeNode merge = this.add(new MergeNode()); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
298 this.replaceFixedWithFixed(begin, merge); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
299 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
300 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
301 |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
302 public void reduceTrivialMerge(MergeNode merge) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
303 assert merge.forwardEndCount() == 1; |
4619
a09b44a28e7f
clenup unused floating nodes on killCFG
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
304 assert !(merge instanceof LoopBeginNode) || ((LoopBeginNode) merge).loopEnds().isEmpty(); |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
305 for (PhiNode phi : merge.phis().snapshot()) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
306 assert phi.valueCount() == 1; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
307 ValueNode singleValue = phi.valueAt(0); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
308 phi.replaceAtUsages(singleValue); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
309 phi.safeDelete(); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
310 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
311 EndNode singleEnd = merge.forwardEndAt(0); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
312 FixedNode sux = merge.next(); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
313 FrameState stateAfter = merge.stateAfter(); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4621
diff
changeset
|
314 // evacuateGuards |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4621
diff
changeset
|
315 Node prevBegin = singleEnd.predecessor(); |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4621
diff
changeset
|
316 assert prevBegin != null; |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4621
diff
changeset
|
317 while (!(prevBegin instanceof BeginNode)) { |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4621
diff
changeset
|
318 prevBegin = prevBegin.predecessor(); |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4621
diff
changeset
|
319 } |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4621
diff
changeset
|
320 merge.replaceAtUsages(prevBegin); |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4621
diff
changeset
|
321 |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
322 merge.safeDelete(); |
4619
a09b44a28e7f
clenup unused floating nodes on killCFG
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
323 if (stateAfter != null && stateAfter.usages().isEmpty()) { |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
324 stateAfter.safeDelete(); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
325 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
326 if (sux == null) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
327 singleEnd.replaceAtPredecessors(null); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
328 singleEnd.safeDelete(); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
329 } else { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
330 singleEnd.replaceAndDelete(sux); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
331 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4419
diff
changeset
|
332 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
333 } |