Mercurial > hg > truffle
annotate src/share/vm/opto/escape.cpp @ 253:b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
Summary: Escape Analysis fixes.
Reviewed-by: never, rasbold
author | kvn |
---|---|
date | Mon, 28 Jul 2008 17:12:52 -0700 |
parents | 02a35ad4adf8 |
children | c3e045194476 |
rev | line source |
---|---|
0 | 1 /* |
196 | 2 * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 #include "incls/_precompiled.incl" | |
26 #include "incls/_escape.cpp.incl" | |
27 | |
28 void PointsToNode::add_edge(uint targIdx, PointsToNode::EdgeType et) { | |
29 uint v = (targIdx << EdgeShift) + ((uint) et); | |
30 if (_edges == NULL) { | |
31 Arena *a = Compile::current()->comp_arena(); | |
32 _edges = new(a) GrowableArray<uint>(a, INITIAL_EDGE_COUNT, 0, 0); | |
33 } | |
34 _edges->append_if_missing(v); | |
35 } | |
36 | |
37 void PointsToNode::remove_edge(uint targIdx, PointsToNode::EdgeType et) { | |
38 uint v = (targIdx << EdgeShift) + ((uint) et); | |
39 | |
40 _edges->remove(v); | |
41 } | |
42 | |
43 #ifndef PRODUCT | |
77 | 44 static const char *node_type_names[] = { |
0 | 45 "UnknownType", |
46 "JavaObject", | |
47 "LocalVar", | |
48 "Field" | |
49 }; | |
50 | |
77 | 51 static const char *esc_names[] = { |
0 | 52 "UnknownEscape", |
65 | 53 "NoEscape", |
54 "ArgEscape", | |
55 "GlobalEscape" | |
0 | 56 }; |
57 | |
77 | 58 static const char *edge_type_suffix[] = { |
0 | 59 "?", // UnknownEdge |
60 "P", // PointsToEdge | |
61 "D", // DeferredEdge | |
62 "F" // FieldEdge | |
63 }; | |
64 | |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
65 void PointsToNode::dump(bool print_state) const { |
0 | 66 NodeType nt = node_type(); |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
67 tty->print("%s ", node_type_names[(int) nt]); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
68 if (print_state) { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
69 EscapeState es = escape_state(); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
70 tty->print("%s %s ", esc_names[(int) es], _scalar_replaceable ? "":"NSR"); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
71 } |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
72 tty->print("[["); |
0 | 73 for (uint i = 0; i < edge_count(); i++) { |
74 tty->print(" %d%s", edge_target(i), edge_type_suffix[(int) edge_type(i)]); | |
75 } | |
76 tty->print("]] "); | |
77 if (_node == NULL) | |
78 tty->print_cr("<null>"); | |
79 else | |
80 _node->dump(); | |
81 } | |
82 #endif | |
83 | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
84 ConnectionGraph::ConnectionGraph(Compile * C) : |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
85 _nodes(C->comp_arena(), C->unique(), C->unique(), PointsToNode()), |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
86 _processed(C->comp_arena()), |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
87 _collecting(true), |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
88 _compile(C), |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
89 _node_map(C->comp_arena()) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
90 |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
91 _phantom_object = C->top()->_idx, |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
92 add_node(C->top(), PointsToNode::JavaObject, PointsToNode::GlobalEscape,true); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
93 |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
94 // Add ConP(#NULL) and ConN(#NULL) nodes. |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
95 PhaseGVN* igvn = C->initial_gvn(); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
96 Node* oop_null = igvn->zerocon(T_OBJECT); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
97 _oop_null = oop_null->_idx; |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
98 assert(_oop_null < C->unique(), "should be created already"); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
99 add_node(oop_null, PointsToNode::JavaObject, PointsToNode::NoEscape, true); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
100 |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
101 if (UseCompressedOops) { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
102 Node* noop_null = igvn->zerocon(T_NARROWOOP); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
103 _noop_null = noop_null->_idx; |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
104 assert(_noop_null < C->unique(), "should be created already"); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
105 add_node(noop_null, PointsToNode::JavaObject, PointsToNode::NoEscape, true); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
106 } |
0 | 107 } |
108 | |
109 void ConnectionGraph::add_pointsto_edge(uint from_i, uint to_i) { | |
110 PointsToNode *f = ptnode_adr(from_i); | |
111 PointsToNode *t = ptnode_adr(to_i); | |
112 | |
113 assert(f->node_type() != PointsToNode::UnknownType && t->node_type() != PointsToNode::UnknownType, "node types must be set"); | |
114 assert(f->node_type() == PointsToNode::LocalVar || f->node_type() == PointsToNode::Field, "invalid source of PointsTo edge"); | |
115 assert(t->node_type() == PointsToNode::JavaObject, "invalid destination of PointsTo edge"); | |
116 f->add_edge(to_i, PointsToNode::PointsToEdge); | |
117 } | |
118 | |
119 void ConnectionGraph::add_deferred_edge(uint from_i, uint to_i) { | |
120 PointsToNode *f = ptnode_adr(from_i); | |
121 PointsToNode *t = ptnode_adr(to_i); | |
122 | |
123 assert(f->node_type() != PointsToNode::UnknownType && t->node_type() != PointsToNode::UnknownType, "node types must be set"); | |
124 assert(f->node_type() == PointsToNode::LocalVar || f->node_type() == PointsToNode::Field, "invalid source of Deferred edge"); | |
125 assert(t->node_type() == PointsToNode::LocalVar || t->node_type() == PointsToNode::Field, "invalid destination of Deferred edge"); | |
126 // don't add a self-referential edge, this can occur during removal of | |
127 // deferred edges | |
128 if (from_i != to_i) | |
129 f->add_edge(to_i, PointsToNode::DeferredEdge); | |
130 } | |
131 | |
65 | 132 int ConnectionGraph::address_offset(Node* adr, PhaseTransform *phase) { |
133 const Type *adr_type = phase->type(adr); | |
134 if (adr->is_AddP() && adr_type->isa_oopptr() == NULL && | |
135 adr->in(AddPNode::Address)->is_Proj() && | |
136 adr->in(AddPNode::Address)->in(0)->is_Allocate()) { | |
137 // We are computing a raw address for a store captured by an Initialize | |
138 // compute an appropriate address type. AddP cases #3 and #5 (see below). | |
139 int offs = (int)phase->find_intptr_t_con(adr->in(AddPNode::Offset), Type::OffsetBot); | |
140 assert(offs != Type::OffsetBot || | |
141 adr->in(AddPNode::Address)->in(0)->is_AllocateArray(), | |
142 "offset must be a constant or it is initialization of array"); | |
143 return offs; | |
144 } | |
145 const TypePtr *t_ptr = adr_type->isa_ptr(); | |
0 | 146 assert(t_ptr != NULL, "must be a pointer type"); |
147 return t_ptr->offset(); | |
148 } | |
149 | |
150 void ConnectionGraph::add_field_edge(uint from_i, uint to_i, int offset) { | |
151 PointsToNode *f = ptnode_adr(from_i); | |
152 PointsToNode *t = ptnode_adr(to_i); | |
153 | |
154 assert(f->node_type() != PointsToNode::UnknownType && t->node_type() != PointsToNode::UnknownType, "node types must be set"); | |
155 assert(f->node_type() == PointsToNode::JavaObject, "invalid destination of Field edge"); | |
156 assert(t->node_type() == PointsToNode::Field, "invalid destination of Field edge"); | |
157 assert (t->offset() == -1 || t->offset() == offset, "conflicting field offsets"); | |
158 t->set_offset(offset); | |
159 | |
160 f->add_edge(to_i, PointsToNode::FieldEdge); | |
161 } | |
162 | |
163 void ConnectionGraph::set_escape_state(uint ni, PointsToNode::EscapeState es) { | |
164 PointsToNode *npt = ptnode_adr(ni); | |
165 PointsToNode::EscapeState old_es = npt->escape_state(); | |
166 if (es > old_es) | |
167 npt->set_escape_state(es); | |
168 } | |
169 | |
65 | 170 void ConnectionGraph::add_node(Node *n, PointsToNode::NodeType nt, |
171 PointsToNode::EscapeState es, bool done) { | |
172 PointsToNode* ptadr = ptnode_adr(n->_idx); | |
173 ptadr->_node = n; | |
174 ptadr->set_node_type(nt); | |
175 | |
176 // inline set_escape_state(idx, es); | |
177 PointsToNode::EscapeState old_es = ptadr->escape_state(); | |
178 if (es > old_es) | |
179 ptadr->set_escape_state(es); | |
180 | |
181 if (done) | |
182 _processed.set(n->_idx); | |
183 } | |
184 | |
0 | 185 PointsToNode::EscapeState ConnectionGraph::escape_state(Node *n, PhaseTransform *phase) { |
186 uint idx = n->_idx; | |
187 PointsToNode::EscapeState es; | |
188 | |
65 | 189 // If we are still collecting or there were no non-escaping allocations |
190 // we don't know the answer yet | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
191 if (_collecting) |
0 | 192 return PointsToNode::UnknownEscape; |
193 | |
194 // if the node was created after the escape computation, return | |
195 // UnknownEscape | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
196 if (idx >= nodes_size()) |
0 | 197 return PointsToNode::UnknownEscape; |
198 | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
199 es = ptnode_adr(idx)->escape_state(); |
0 | 200 |
201 // if we have already computed a value, return it | |
202 if (es != PointsToNode::UnknownEscape) | |
203 return es; | |
204 | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
205 // PointsTo() calls n->uncast() which can return a new ideal node. |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
206 if (n->uncast()->_idx >= nodes_size()) |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
207 return PointsToNode::UnknownEscape; |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
208 |
0 | 209 // compute max escape state of anything this node could point to |
210 VectorSet ptset(Thread::current()->resource_area()); | |
211 PointsTo(ptset, n, phase); | |
65 | 212 for(VectorSetI i(&ptset); i.test() && es != PointsToNode::GlobalEscape; ++i) { |
0 | 213 uint pt = i.elem; |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
214 PointsToNode::EscapeState pes = ptnode_adr(pt)->escape_state(); |
0 | 215 if (pes > es) |
216 es = pes; | |
217 } | |
218 // cache the computed escape state | |
219 assert(es != PointsToNode::UnknownEscape, "should have computed an escape state"); | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
220 ptnode_adr(idx)->set_escape_state(es); |
0 | 221 return es; |
222 } | |
223 | |
224 void ConnectionGraph::PointsTo(VectorSet &ptset, Node * n, PhaseTransform *phase) { | |
225 VectorSet visited(Thread::current()->resource_area()); | |
226 GrowableArray<uint> worklist; | |
227 | |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
228 #ifdef ASSERT |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
229 Node *orig_n = n; |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
230 #endif |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
231 |
65 | 232 n = n->uncast(); |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
233 PointsToNode* npt = ptnode_adr(n->_idx); |
0 | 234 |
235 // If we have a JavaObject, return just that object | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
236 if (npt->node_type() == PointsToNode::JavaObject) { |
0 | 237 ptset.set(n->_idx); |
238 return; | |
239 } | |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
240 #ifdef ASSERT |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
241 if (npt->_node == NULL) { |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
242 if (orig_n != n) |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
243 orig_n->dump(); |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
244 n->dump(); |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
245 assert(npt->_node != NULL, "unregistered node"); |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
246 } |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
247 #endif |
0 | 248 worklist.push(n->_idx); |
249 while(worklist.length() > 0) { | |
250 int ni = worklist.pop(); | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
251 if (visited.test_set(ni)) |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
252 continue; |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
253 |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
254 PointsToNode* pn = ptnode_adr(ni); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
255 // ensure that all inputs of a Phi have been processed |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
256 assert(!_collecting || !pn->_node->is_Phi() || _processed.test(ni),""); |
0 | 257 |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
258 int edges_processed = 0; |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
259 uint e_cnt = pn->edge_count(); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
260 for (uint e = 0; e < e_cnt; e++) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
261 uint etgt = pn->edge_target(e); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
262 PointsToNode::EdgeType et = pn->edge_type(e); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
263 if (et == PointsToNode::PointsToEdge) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
264 ptset.set(etgt); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
265 edges_processed++; |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
266 } else if (et == PointsToNode::DeferredEdge) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
267 worklist.push(etgt); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
268 edges_processed++; |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
269 } else { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
270 assert(false,"neither PointsToEdge or DeferredEdge"); |
0 | 271 } |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
272 } |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
273 if (edges_processed == 0) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
274 // no deferred or pointsto edges found. Assume the value was set |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
275 // outside this method. Add the phantom object to the pointsto set. |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
276 ptset.set(_phantom_object); |
0 | 277 } |
278 } | |
279 } | |
280 | |
101
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
281 void ConnectionGraph::remove_deferred(uint ni, GrowableArray<uint>* deferred_edges, VectorSet* visited) { |
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
282 // This method is most expensive during ConnectionGraph construction. |
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
283 // Reuse vectorSet and an additional growable array for deferred edges. |
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
284 deferred_edges->clear(); |
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
285 visited->Clear(); |
0 | 286 |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
287 visited->set(ni); |
0 | 288 PointsToNode *ptn = ptnode_adr(ni); |
289 | |
101
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
290 // Mark current edges as visited and move deferred edges to separate array. |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
291 for (uint i = 0; i < ptn->edge_count(); ) { |
65 | 292 uint t = ptn->edge_target(i); |
101
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
293 #ifdef ASSERT |
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
294 assert(!visited->test_set(t), "expecting no duplications"); |
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
295 #else |
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
296 visited->set(t); |
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
297 #endif |
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
298 if (ptn->edge_type(i) == PointsToNode::DeferredEdge) { |
0 | 299 ptn->remove_edge(t, PointsToNode::DeferredEdge); |
101
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
300 deferred_edges->append(t); |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
301 } else { |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
302 i++; |
101
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
303 } |
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
304 } |
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
305 for (int next = 0; next < deferred_edges->length(); ++next) { |
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
306 uint t = deferred_edges->at(next); |
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
307 PointsToNode *ptt = ptnode_adr(t); |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
308 uint e_cnt = ptt->edge_count(); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
309 for (uint e = 0; e < e_cnt; e++) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
310 uint etgt = ptt->edge_target(e); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
311 if (visited->test_set(etgt)) |
101
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
312 continue; |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
313 |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
314 PointsToNode::EdgeType et = ptt->edge_type(e); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
315 if (et == PointsToNode::PointsToEdge) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
316 add_pointsto_edge(ni, etgt); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
317 if(etgt == _phantom_object) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
318 // Special case - field set outside (globally escaping). |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
319 ptn->set_escape_state(PointsToNode::GlobalEscape); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
320 } |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
321 } else if (et == PointsToNode::DeferredEdge) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
322 deferred_edges->append(etgt); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
323 } else { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
324 assert(false,"invalid connection graph"); |
0 | 325 } |
326 } | |
327 } | |
328 } | |
329 | |
330 | |
331 // Add an edge to node given by "to_i" from any field of adr_i whose offset | |
332 // matches "offset" A deferred edge is added if to_i is a LocalVar, and | |
333 // a pointsto edge is added if it is a JavaObject | |
334 | |
335 void ConnectionGraph::add_edge_from_fields(uint adr_i, uint to_i, int offs) { | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
336 PointsToNode* an = ptnode_adr(adr_i); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
337 PointsToNode* to = ptnode_adr(to_i); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
338 bool deferred = (to->node_type() == PointsToNode::LocalVar); |
0 | 339 |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
340 for (uint fe = 0; fe < an->edge_count(); fe++) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
341 assert(an->edge_type(fe) == PointsToNode::FieldEdge, "expecting a field edge"); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
342 int fi = an->edge_target(fe); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
343 PointsToNode* pf = ptnode_adr(fi); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
344 int po = pf->offset(); |
0 | 345 if (po == offs || po == Type::OffsetBot || offs == Type::OffsetBot) { |
346 if (deferred) | |
347 add_deferred_edge(fi, to_i); | |
348 else | |
349 add_pointsto_edge(fi, to_i); | |
350 } | |
351 } | |
352 } | |
353 | |
65 | 354 // Add a deferred edge from node given by "from_i" to any field of adr_i |
355 // whose offset matches "offset". | |
0 | 356 void ConnectionGraph::add_deferred_edge_to_fields(uint from_i, uint adr_i, int offs) { |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
357 PointsToNode* an = ptnode_adr(adr_i); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
358 for (uint fe = 0; fe < an->edge_count(); fe++) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
359 assert(an->edge_type(fe) == PointsToNode::FieldEdge, "expecting a field edge"); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
360 int fi = an->edge_target(fe); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
361 PointsToNode* pf = ptnode_adr(fi); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
362 int po = pf->offset(); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
363 if (pf->edge_count() == 0) { |
0 | 364 // we have not seen any stores to this field, assume it was set outside this method |
365 add_pointsto_edge(fi, _phantom_object); | |
366 } | |
367 if (po == offs || po == Type::OffsetBot || offs == Type::OffsetBot) { | |
368 add_deferred_edge(from_i, fi); | |
369 } | |
370 } | |
371 } | |
372 | |
65 | 373 // Helper functions |
374 | |
375 static Node* get_addp_base(Node *addp) { | |
376 assert(addp->is_AddP(), "must be AddP"); | |
377 // | |
378 // AddP cases for Base and Address inputs: | |
379 // case #1. Direct object's field reference: | |
380 // Allocate | |
381 // | | |
382 // Proj #5 ( oop result ) | |
383 // | | |
384 // CheckCastPP (cast to instance type) | |
385 // | | | |
386 // AddP ( base == address ) | |
387 // | |
388 // case #2. Indirect object's field reference: | |
389 // Phi | |
390 // | | |
391 // CastPP (cast to instance type) | |
392 // | | | |
393 // AddP ( base == address ) | |
394 // | |
395 // case #3. Raw object's field reference for Initialize node: | |
396 // Allocate | |
397 // | | |
398 // Proj #5 ( oop result ) | |
399 // top | | |
400 // \ | | |
401 // AddP ( base == top ) | |
402 // | |
403 // case #4. Array's element reference: | |
404 // {CheckCastPP | CastPP} | |
405 // | | | | |
406 // | AddP ( array's element offset ) | |
407 // | | | |
408 // AddP ( array's offset ) | |
409 // | |
410 // case #5. Raw object's field reference for arraycopy stub call: | |
411 // The inline_native_clone() case when the arraycopy stub is called | |
412 // after the allocation before Initialize and CheckCastPP nodes. | |
413 // Allocate | |
414 // | | |
415 // Proj #5 ( oop result ) | |
416 // | | | |
417 // AddP ( base == address ) | |
418 // | |
77 | 419 // case #6. Constant Pool, ThreadLocal, CastX2P or |
420 // Raw object's field reference: | |
421 // {ConP, ThreadLocal, CastX2P, raw Load} | |
65 | 422 // top | |
423 // \ | | |
424 // AddP ( base == top ) | |
425 // | |
77 | 426 // case #7. Klass's field reference. |
427 // LoadKlass | |
428 // | | | |
429 // AddP ( base == address ) | |
430 // | |
164
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
431 // case #8. narrow Klass's field reference. |
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
432 // LoadNKlass |
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
433 // | |
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
434 // DecodeN |
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
435 // | | |
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
436 // AddP ( base == address ) |
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
437 // |
65 | 438 Node *base = addp->in(AddPNode::Base)->uncast(); |
439 if (base->is_top()) { // The AddP case #3 and #6. | |
440 base = addp->in(AddPNode::Address)->uncast(); | |
441 assert(base->Opcode() == Op_ConP || base->Opcode() == Op_ThreadLocal || | |
168
7793bd37a336
6705887: Compressed Oops: generate x64 addressing and implicit null checks with narrow oops
kvn
parents:
164
diff
changeset
|
442 base->Opcode() == Op_CastX2P || base->is_DecodeN() || |
77 | 443 (base->is_Mem() && base->bottom_type() == TypeRawPtr::NOTNULL) || |
444 (base->is_Proj() && base->in(0)->is_Allocate()), "sanity"); | |
0 | 445 } |
65 | 446 return base; |
447 } | |
448 | |
449 static Node* find_second_addp(Node* addp, Node* n) { | |
450 assert(addp->is_AddP() && addp->outcnt() > 0, "Don't process dead nodes"); | |
451 | |
452 Node* addp2 = addp->raw_out(0); | |
453 if (addp->outcnt() == 1 && addp2->is_AddP() && | |
454 addp2->in(AddPNode::Base) == n && | |
455 addp2->in(AddPNode::Address) == addp) { | |
456 | |
457 assert(addp->in(AddPNode::Base) == n, "expecting the same base"); | |
458 // | |
459 // Find array's offset to push it on worklist first and | |
460 // as result process an array's element offset first (pushed second) | |
461 // to avoid CastPP for the array's offset. | |
462 // Otherwise the inserted CastPP (LocalVar) will point to what | |
463 // the AddP (Field) points to. Which would be wrong since | |
464 // the algorithm expects the CastPP has the same point as | |
465 // as AddP's base CheckCastPP (LocalVar). | |
466 // | |
467 // ArrayAllocation | |
468 // | | |
469 // CheckCastPP | |
470 // | | |
471 // memProj (from ArrayAllocation CheckCastPP) | |
472 // | || | |
473 // | || Int (element index) | |
474 // | || | ConI (log(element size)) | |
475 // | || | / | |
476 // | || LShift | |
477 // | || / | |
478 // | AddP (array's element offset) | |
479 // | | | |
480 // | | ConI (array's offset: #12(32-bits) or #24(64-bits)) | |
481 // | / / | |
482 // AddP (array's offset) | |
483 // | | |
484 // Load/Store (memory operation on array's element) | |
485 // | |
486 return addp2; | |
487 } | |
488 return NULL; | |
0 | 489 } |
490 | |
491 // | |
492 // Adjust the type and inputs of an AddP which computes the | |
493 // address of a field of an instance | |
494 // | |
495 void ConnectionGraph::split_AddP(Node *addp, Node *base, PhaseGVN *igvn) { | |
65 | 496 const TypeOopPtr *base_t = igvn->type(base)->isa_oopptr(); |
223 | 497 assert(base_t != NULL && base_t->is_known_instance(), "expecting instance oopptr"); |
0 | 498 const TypeOopPtr *t = igvn->type(addp)->isa_oopptr(); |
65 | 499 if (t == NULL) { |
500 // We are computing a raw address for a store captured by an Initialize | |
501 // compute an appropriate address type. | |
502 assert(igvn->type(addp) == TypeRawPtr::NOTNULL, "must be raw pointer"); | |
503 assert(addp->in(AddPNode::Address)->is_Proj(), "base of raw address must be result projection from allocation"); | |
504 int offs = (int)igvn->find_intptr_t_con(addp->in(AddPNode::Offset), Type::OffsetBot); | |
505 assert(offs != Type::OffsetBot, "offset must be a constant"); | |
506 t = base_t->add_offset(offs)->is_oopptr(); | |
507 } | |
223 | 508 int inst_id = base_t->instance_id(); |
509 assert(!t->is_known_instance() || t->instance_id() == inst_id, | |
0 | 510 "old type must be non-instance or match new type"); |
511 const TypeOopPtr *tinst = base_t->add_offset(t->offset())->is_oopptr(); | |
65 | 512 // Do NOT remove the next call: ensure an new alias index is allocated |
513 // for the instance type | |
0 | 514 int alias_idx = _compile->get_alias_index(tinst); |
515 igvn->set_type(addp, tinst); | |
516 // record the allocation in the node map | |
517 set_map(addp->_idx, get_map(base->_idx)); | |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
518 |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
519 // Set addp's Base and Address to 'base'. |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
520 Node *abase = addp->in(AddPNode::Base); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
521 Node *adr = addp->in(AddPNode::Address); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
522 if (adr->is_Proj() && adr->in(0)->is_Allocate() && |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
523 adr->in(0)->_idx == (uint)inst_id) { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
524 // Skip AddP cases #3 and #5. |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
525 } else { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
526 assert(!abase->is_top(), "sanity"); // AddP case #3 |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
527 if (abase != base) { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
528 igvn->hash_delete(addp); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
529 addp->set_req(AddPNode::Base, base); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
530 if (abase == adr) { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
531 addp->set_req(AddPNode::Address, base); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
532 } else { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
533 // AddP case #4 (adr is array's element offset AddP node) |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
534 #ifdef ASSERT |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
535 const TypeOopPtr *atype = igvn->type(adr)->isa_oopptr(); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
536 assert(adr->is_AddP() && atype != NULL && |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
537 atype->instance_id() == inst_id, "array's element offset should be processed first"); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
538 #endif |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
539 } |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
540 igvn->hash_insert(addp); |
0 | 541 } |
542 } | |
65 | 543 // Put on IGVN worklist since at least addp's type was changed above. |
544 record_for_optimizer(addp); | |
0 | 545 } |
546 | |
547 // | |
548 // Create a new version of orig_phi if necessary. Returns either the newly | |
549 // created phi or an existing phi. Sets create_new to indicate wheter a new | |
550 // phi was created. Cache the last newly created phi in the node map. | |
551 // | |
552 PhiNode *ConnectionGraph::create_split_phi(PhiNode *orig_phi, int alias_idx, GrowableArray<PhiNode *> &orig_phi_worklist, PhaseGVN *igvn, bool &new_created) { | |
553 Compile *C = _compile; | |
554 new_created = false; | |
555 int phi_alias_idx = C->get_alias_index(orig_phi->adr_type()); | |
556 // nothing to do if orig_phi is bottom memory or matches alias_idx | |
65 | 557 if (phi_alias_idx == alias_idx) { |
0 | 558 return orig_phi; |
559 } | |
560 // have we already created a Phi for this alias index? | |
561 PhiNode *result = get_map_phi(orig_phi->_idx); | |
562 if (result != NULL && C->get_alias_index(result->adr_type()) == alias_idx) { | |
563 return result; | |
564 } | |
38
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
565 if ((int)C->unique() + 2*NodeLimitFudgeFactor > MaxNodeLimit) { |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
566 if (C->do_escape_analysis() == true && !C->failing()) { |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
567 // Retry compilation without escape analysis. |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
568 // If this is the first failure, the sentinel string will "stick" |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
569 // to the Compile object, and the C2Compiler will see it and retry. |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
570 C->record_failure(C2Compiler::retry_no_escape_analysis()); |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
571 } |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
572 return NULL; |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
573 } |
0 | 574 orig_phi_worklist.append_if_missing(orig_phi); |
65 | 575 const TypePtr *atype = C->get_adr_type(alias_idx); |
0 | 576 result = PhiNode::make(orig_phi->in(0), NULL, Type::MEMORY, atype); |
577 set_map_phi(orig_phi->_idx, result); | |
578 igvn->set_type(result, result->bottom_type()); | |
579 record_for_optimizer(result); | |
580 new_created = true; | |
581 return result; | |
582 } | |
583 | |
584 // | |
585 // Return a new version of Memory Phi "orig_phi" with the inputs having the | |
586 // specified alias index. | |
587 // | |
588 PhiNode *ConnectionGraph::split_memory_phi(PhiNode *orig_phi, int alias_idx, GrowableArray<PhiNode *> &orig_phi_worklist, PhaseGVN *igvn) { | |
589 | |
590 assert(alias_idx != Compile::AliasIdxBot, "can't split out bottom memory"); | |
591 Compile *C = _compile; | |
592 bool new_phi_created; | |
65 | 593 PhiNode *result = create_split_phi(orig_phi, alias_idx, orig_phi_worklist, igvn, new_phi_created); |
0 | 594 if (!new_phi_created) { |
595 return result; | |
596 } | |
597 | |
598 GrowableArray<PhiNode *> phi_list; | |
599 GrowableArray<uint> cur_input; | |
600 | |
601 PhiNode *phi = orig_phi; | |
602 uint idx = 1; | |
603 bool finished = false; | |
604 while(!finished) { | |
605 while (idx < phi->req()) { | |
65 | 606 Node *mem = find_inst_mem(phi->in(idx), alias_idx, orig_phi_worklist, igvn); |
0 | 607 if (mem != NULL && mem->is_Phi()) { |
65 | 608 PhiNode *newphi = create_split_phi(mem->as_Phi(), alias_idx, orig_phi_worklist, igvn, new_phi_created); |
0 | 609 if (new_phi_created) { |
610 // found an phi for which we created a new split, push current one on worklist and begin | |
611 // processing new one | |
612 phi_list.push(phi); | |
613 cur_input.push(idx); | |
614 phi = mem->as_Phi(); | |
65 | 615 result = newphi; |
0 | 616 idx = 1; |
617 continue; | |
618 } else { | |
65 | 619 mem = newphi; |
0 | 620 } |
621 } | |
38
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
622 if (C->failing()) { |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
623 return NULL; |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
624 } |
0 | 625 result->set_req(idx++, mem); |
626 } | |
627 #ifdef ASSERT | |
628 // verify that the new Phi has an input for each input of the original | |
629 assert( phi->req() == result->req(), "must have same number of inputs."); | |
630 assert( result->in(0) != NULL && result->in(0) == phi->in(0), "regions must match"); | |
65 | 631 #endif |
632 // Check if all new phi's inputs have specified alias index. | |
633 // Otherwise use old phi. | |
0 | 634 for (uint i = 1; i < phi->req(); i++) { |
65 | 635 Node* in = result->in(i); |
636 assert((phi->in(i) == NULL) == (in == NULL), "inputs must correspond."); | |
0 | 637 } |
638 // we have finished processing a Phi, see if there are any more to do | |
639 finished = (phi_list.length() == 0 ); | |
640 if (!finished) { | |
641 phi = phi_list.pop(); | |
642 idx = cur_input.pop(); | |
65 | 643 PhiNode *prev_result = get_map_phi(phi->_idx); |
644 prev_result->set_req(idx++, result); | |
645 result = prev_result; | |
0 | 646 } |
647 } | |
648 return result; | |
649 } | |
650 | |
65 | 651 |
652 // | |
653 // The next methods are derived from methods in MemNode. | |
654 // | |
655 static Node *step_through_mergemem(MergeMemNode *mmem, int alias_idx, const TypeOopPtr *tinst) { | |
656 Node *mem = mmem; | |
657 // TypeInstPtr::NOTNULL+any is an OOP with unknown offset - generally | |
658 // means an array I have not precisely typed yet. Do not do any | |
659 // alias stuff with it any time soon. | |
660 if( tinst->base() != Type::AnyPtr && | |
661 !(tinst->klass()->is_java_lang_Object() && | |
662 tinst->offset() == Type::OffsetBot) ) { | |
663 mem = mmem->memory_at(alias_idx); | |
664 // Update input if it is progress over what we have now | |
665 } | |
666 return mem; | |
667 } | |
668 | |
669 // | |
670 // Search memory chain of "mem" to find a MemNode whose address | |
671 // is the specified alias index. | |
672 // | |
673 Node* ConnectionGraph::find_inst_mem(Node *orig_mem, int alias_idx, GrowableArray<PhiNode *> &orig_phis, PhaseGVN *phase) { | |
674 if (orig_mem == NULL) | |
675 return orig_mem; | |
676 Compile* C = phase->C; | |
677 const TypeOopPtr *tinst = C->get_adr_type(alias_idx)->isa_oopptr(); | |
223 | 678 bool is_instance = (tinst != NULL) && tinst->is_known_instance(); |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
679 Node *start_mem = C->start()->proj_out(TypeFunc::Memory); |
65 | 680 Node *prev = NULL; |
681 Node *result = orig_mem; | |
682 while (prev != result) { | |
683 prev = result; | |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
684 if (result == start_mem) |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
685 break; // hit one of our sentinals |
65 | 686 if (result->is_Mem()) { |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
687 const Type *at = phase->type(result->in(MemNode::Address)); |
65 | 688 if (at != Type::TOP) { |
689 assert (at->isa_ptr() != NULL, "pointer type required."); | |
690 int idx = C->get_alias_index(at->is_ptr()); | |
691 if (idx == alias_idx) | |
692 break; | |
693 } | |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
694 result = result->in(MemNode::Memory); |
65 | 695 } |
696 if (!is_instance) | |
697 continue; // don't search further for non-instance types | |
698 // skip over a call which does not affect this memory slice | |
699 if (result->is_Proj() && result->as_Proj()->_con == TypeFunc::Memory) { | |
700 Node *proj_in = result->in(0); | |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
701 if (proj_in->is_Allocate() && proj_in->_idx == (uint)tinst->instance_id()) { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
702 break; // hit one of our sentinals |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
703 } else if (proj_in->is_Call()) { |
65 | 704 CallNode *call = proj_in->as_Call(); |
705 if (!call->may_modify(tinst, phase)) { | |
706 result = call->in(TypeFunc::Memory); | |
707 } | |
708 } else if (proj_in->is_Initialize()) { | |
709 AllocateNode* alloc = proj_in->as_Initialize()->allocation(); | |
710 // Stop if this is the initialization for the object instance which | |
711 // which contains this memory slice, otherwise skip over it. | |
223 | 712 if (alloc == NULL || alloc->_idx != (uint)tinst->instance_id()) { |
65 | 713 result = proj_in->in(TypeFunc::Memory); |
714 } | |
715 } else if (proj_in->is_MemBar()) { | |
716 result = proj_in->in(TypeFunc::Memory); | |
717 } | |
718 } else if (result->is_MergeMem()) { | |
719 MergeMemNode *mmem = result->as_MergeMem(); | |
720 result = step_through_mergemem(mmem, alias_idx, tinst); | |
721 if (result == mmem->base_memory()) { | |
722 // Didn't find instance memory, search through general slice recursively. | |
723 result = mmem->memory_at(C->get_general_index(alias_idx)); | |
724 result = find_inst_mem(result, alias_idx, orig_phis, phase); | |
725 if (C->failing()) { | |
726 return NULL; | |
727 } | |
728 mmem->set_memory_at(alias_idx, result); | |
729 } | |
730 } else if (result->is_Phi() && | |
731 C->get_alias_index(result->as_Phi()->adr_type()) != alias_idx) { | |
732 Node *un = result->as_Phi()->unique_input(phase); | |
733 if (un != NULL) { | |
734 result = un; | |
735 } else { | |
736 break; | |
737 } | |
738 } | |
739 } | |
247 | 740 if (result->is_Phi()) { |
65 | 741 PhiNode *mphi = result->as_Phi(); |
742 assert(mphi->bottom_type() == Type::MEMORY, "memory phi required"); | |
743 const TypePtr *t = mphi->adr_type(); | |
744 if (C->get_alias_index(t) != alias_idx) { | |
247 | 745 // Create a new Phi with the specified alias index type. |
65 | 746 result = split_memory_phi(mphi, alias_idx, orig_phis, phase); |
247 | 747 } else if (!is_instance) { |
748 // Push all non-instance Phis on the orig_phis worklist to update inputs | |
749 // during Phase 4 if needed. | |
750 orig_phis.append_if_missing(mphi); | |
65 | 751 } |
752 } | |
753 // the result is either MemNode, PhiNode, InitializeNode. | |
754 return result; | |
755 } | |
756 | |
757 | |
0 | 758 // |
759 // Convert the types of unescaped object to instance types where possible, | |
760 // propagate the new type information through the graph, and update memory | |
761 // edges and MergeMem inputs to reflect the new type. | |
762 // | |
763 // We start with allocations (and calls which may be allocations) on alloc_worklist. | |
764 // The processing is done in 4 phases: | |
765 // | |
766 // Phase 1: Process possible allocations from alloc_worklist. Create instance | |
767 // types for the CheckCastPP for allocations where possible. | |
768 // Propagate the the new types through users as follows: | |
769 // casts and Phi: push users on alloc_worklist | |
770 // AddP: cast Base and Address inputs to the instance type | |
771 // push any AddP users on alloc_worklist and push any memnode | |
772 // users onto memnode_worklist. | |
773 // Phase 2: Process MemNode's from memnode_worklist. compute new address type and | |
774 // search the Memory chain for a store with the appropriate type | |
775 // address type. If a Phi is found, create a new version with | |
776 // the approriate memory slices from each of the Phi inputs. | |
777 // For stores, process the users as follows: | |
778 // MemNode: push on memnode_worklist | |
779 // MergeMem: push on mergemem_worklist | |
780 // Phase 3: Process MergeMem nodes from mergemem_worklist. Walk each memory slice | |
781 // moving the first node encountered of each instance type to the | |
782 // the input corresponding to its alias index. | |
783 // appropriate memory slice. | |
784 // Phase 4: Update the inputs of non-instance memory Phis and the Memory input of memnodes. | |
785 // | |
786 // In the following example, the CheckCastPP nodes are the cast of allocation | |
787 // results and the allocation of node 29 is unescaped and eligible to be an | |
788 // instance type. | |
789 // | |
790 // We start with: | |
791 // | |
792 // 7 Parm #memory | |
793 // 10 ConI "12" | |
794 // 19 CheckCastPP "Foo" | |
795 // 20 AddP _ 19 19 10 Foo+12 alias_index=4 | |
796 // 29 CheckCastPP "Foo" | |
797 // 30 AddP _ 29 29 10 Foo+12 alias_index=4 | |
798 // | |
799 // 40 StoreP 25 7 20 ... alias_index=4 | |
800 // 50 StoreP 35 40 30 ... alias_index=4 | |
801 // 60 StoreP 45 50 20 ... alias_index=4 | |
802 // 70 LoadP _ 60 30 ... alias_index=4 | |
803 // 80 Phi 75 50 60 Memory alias_index=4 | |
804 // 90 LoadP _ 80 30 ... alias_index=4 | |
805 // 100 LoadP _ 80 20 ... alias_index=4 | |
806 // | |
807 // | |
808 // Phase 1 creates an instance type for node 29 assigning it an instance id of 24 | |
809 // and creating a new alias index for node 30. This gives: | |
810 // | |
811 // 7 Parm #memory | |
812 // 10 ConI "12" | |
813 // 19 CheckCastPP "Foo" | |
814 // 20 AddP _ 19 19 10 Foo+12 alias_index=4 | |
815 // 29 CheckCastPP "Foo" iid=24 | |
816 // 30 AddP _ 29 29 10 Foo+12 alias_index=6 iid=24 | |
817 // | |
818 // 40 StoreP 25 7 20 ... alias_index=4 | |
819 // 50 StoreP 35 40 30 ... alias_index=6 | |
820 // 60 StoreP 45 50 20 ... alias_index=4 | |
821 // 70 LoadP _ 60 30 ... alias_index=6 | |
822 // 80 Phi 75 50 60 Memory alias_index=4 | |
823 // 90 LoadP _ 80 30 ... alias_index=6 | |
824 // 100 LoadP _ 80 20 ... alias_index=4 | |
825 // | |
826 // In phase 2, new memory inputs are computed for the loads and stores, | |
827 // And a new version of the phi is created. In phase 4, the inputs to | |
828 // node 80 are updated and then the memory nodes are updated with the | |
829 // values computed in phase 2. This results in: | |
830 // | |
831 // 7 Parm #memory | |
832 // 10 ConI "12" | |
833 // 19 CheckCastPP "Foo" | |
834 // 20 AddP _ 19 19 10 Foo+12 alias_index=4 | |
835 // 29 CheckCastPP "Foo" iid=24 | |
836 // 30 AddP _ 29 29 10 Foo+12 alias_index=6 iid=24 | |
837 // | |
838 // 40 StoreP 25 7 20 ... alias_index=4 | |
839 // 50 StoreP 35 7 30 ... alias_index=6 | |
840 // 60 StoreP 45 40 20 ... alias_index=4 | |
841 // 70 LoadP _ 50 30 ... alias_index=6 | |
842 // 80 Phi 75 40 60 Memory alias_index=4 | |
843 // 120 Phi 75 50 50 Memory alias_index=6 | |
844 // 90 LoadP _ 120 30 ... alias_index=6 | |
845 // 100 LoadP _ 80 20 ... alias_index=4 | |
846 // | |
847 void ConnectionGraph::split_unique_types(GrowableArray<Node *> &alloc_worklist) { | |
848 GrowableArray<Node *> memnode_worklist; | |
849 GrowableArray<Node *> mergemem_worklist; | |
850 GrowableArray<PhiNode *> orig_phis; | |
851 PhaseGVN *igvn = _compile->initial_gvn(); | |
852 uint new_index_start = (uint) _compile->num_alias_types(); | |
853 VectorSet visited(Thread::current()->resource_area()); | |
854 VectorSet ptset(Thread::current()->resource_area()); | |
855 | |
65 | 856 |
857 // Phase 1: Process possible allocations from alloc_worklist. | |
858 // Create instance types for the CheckCastPP for allocations where possible. | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
859 // |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
860 // (Note: don't forget to change the order of the second AddP node on |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
861 // the alloc_worklist if the order of the worklist processing is changed, |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
862 // see the comment in find_second_addp().) |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
863 // |
0 | 864 while (alloc_worklist.length() != 0) { |
865 Node *n = alloc_worklist.pop(); | |
866 uint ni = n->_idx; | |
65 | 867 const TypeOopPtr* tinst = NULL; |
0 | 868 if (n->is_Call()) { |
869 CallNode *alloc = n->as_Call(); | |
870 // copy escape information to call node | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
871 PointsToNode* ptn = ptnode_adr(alloc->_idx); |
0 | 872 PointsToNode::EscapeState es = escape_state(alloc, igvn); |
65 | 873 // We have an allocation or call which returns a Java object, |
874 // see if it is unescaped. | |
875 if (es != PointsToNode::NoEscape || !ptn->_scalar_replaceable) | |
0 | 876 continue; |
39
76256d272075
6667612: (Escape Analysis) disable loop cloning if it has a scalar replaceable allocation
kvn
parents:
38
diff
changeset
|
877 if (alloc->is_Allocate()) { |
76256d272075
6667612: (Escape Analysis) disable loop cloning if it has a scalar replaceable allocation
kvn
parents:
38
diff
changeset
|
878 // Set the scalar_replaceable flag before the next check. |
76256d272075
6667612: (Escape Analysis) disable loop cloning if it has a scalar replaceable allocation
kvn
parents:
38
diff
changeset
|
879 alloc->as_Allocate()->_is_scalar_replaceable = true; |
76256d272075
6667612: (Escape Analysis) disable loop cloning if it has a scalar replaceable allocation
kvn
parents:
38
diff
changeset
|
880 } |
65 | 881 // find CheckCastPP of call return value |
882 n = alloc->result_cast(); | |
883 if (n == NULL || // No uses accept Initialize or | |
884 !n->is_CheckCastPP()) // not unique CheckCastPP. | |
885 continue; | |
886 // The inline code for Object.clone() casts the allocation result to | |
247 | 887 // java.lang.Object and then to the actual type of the allocated |
65 | 888 // object. Detect this case and use the second cast. |
247 | 889 // Also detect j.l.reflect.Array.newInstance(jobject, jint) case when |
890 // the allocation result is cast to java.lang.Object and then | |
891 // to the actual Array type. | |
65 | 892 if (alloc->is_Allocate() && n->as_Type()->type() == TypeInstPtr::NOTNULL |
247 | 893 && (alloc->is_AllocateArray() || |
894 igvn->type(alloc->in(AllocateNode::KlassNode)) != TypeKlassPtr::OBJECT)) { | |
65 | 895 Node *cast2 = NULL; |
896 for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { | |
897 Node *use = n->fast_out(i); | |
898 if (use->is_CheckCastPP()) { | |
899 cast2 = use; | |
900 break; | |
901 } | |
902 } | |
903 if (cast2 != NULL) { | |
904 n = cast2; | |
905 } else { | |
906 continue; | |
907 } | |
908 } | |
909 set_escape_state(n->_idx, es); | |
247 | 910 // in order for an object to be scalar-replaceable, it must be: |
65 | 911 // - a direct allocation (not a call returning an object) |
912 // - non-escaping | |
913 // - eligible to be a unique type | |
914 // - not determined to be ineligible by escape analysis | |
0 | 915 set_map(alloc->_idx, n); |
916 set_map(n->_idx, alloc); | |
65 | 917 const TypeOopPtr *t = igvn->type(n)->isa_oopptr(); |
918 if (t == NULL) | |
0 | 919 continue; // not a TypeInstPtr |
247 | 920 tinst = t->cast_to_exactness(true)->is_oopptr()->cast_to_instance_id(ni); |
0 | 921 igvn->hash_delete(n); |
922 igvn->set_type(n, tinst); | |
923 n->raise_bottom_type(tinst); | |
924 igvn->hash_insert(n); | |
65 | 925 record_for_optimizer(n); |
926 if (alloc->is_Allocate() && ptn->_scalar_replaceable && | |
927 (t->isa_instptr() || t->isa_aryptr())) { | |
163 | 928 |
929 // First, put on the worklist all Field edges from Connection Graph | |
930 // which is more accurate then putting immediate users from Ideal Graph. | |
931 for (uint e = 0; e < ptn->edge_count(); e++) { | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
932 Node *use = ptnode_adr(ptn->edge_target(e))->_node; |
163 | 933 assert(ptn->edge_type(e) == PointsToNode::FieldEdge && use->is_AddP(), |
934 "only AddP nodes are Field edges in CG"); | |
935 if (use->outcnt() > 0) { // Don't process dead nodes | |
936 Node* addp2 = find_second_addp(use, use->in(AddPNode::Base)); | |
937 if (addp2 != NULL) { | |
938 assert(alloc->is_AllocateArray(),"array allocation was expected"); | |
939 alloc_worklist.append_if_missing(addp2); | |
940 } | |
941 alloc_worklist.append_if_missing(use); | |
942 } | |
943 } | |
944 | |
65 | 945 // An allocation may have an Initialize which has raw stores. Scan |
946 // the users of the raw allocation result and push AddP users | |
947 // on alloc_worklist. | |
948 Node *raw_result = alloc->proj_out(TypeFunc::Parms); | |
949 assert (raw_result != NULL, "must have an allocation result"); | |
950 for (DUIterator_Fast imax, i = raw_result->fast_outs(imax); i < imax; i++) { | |
951 Node *use = raw_result->fast_out(i); | |
952 if (use->is_AddP() && use->outcnt() > 0) { // Don't process dead nodes | |
953 Node* addp2 = find_second_addp(use, raw_result); | |
954 if (addp2 != NULL) { | |
955 assert(alloc->is_AllocateArray(),"array allocation was expected"); | |
956 alloc_worklist.append_if_missing(addp2); | |
957 } | |
958 alloc_worklist.append_if_missing(use); | |
959 } else if (use->is_Initialize()) { | |
960 memnode_worklist.append_if_missing(use); | |
961 } | |
962 } | |
963 } | |
0 | 964 } else if (n->is_AddP()) { |
965 ptset.Clear(); | |
65 | 966 PointsTo(ptset, get_addp_base(n), igvn); |
0 | 967 assert(ptset.Size() == 1, "AddP address is unique"); |
65 | 968 uint elem = ptset.getelem(); // Allocation node's index |
969 if (elem == _phantom_object) | |
970 continue; // Assume the value was set outside this method. | |
971 Node *base = get_map(elem); // CheckCastPP node | |
0 | 972 split_AddP(n, base, igvn); |
65 | 973 tinst = igvn->type(base)->isa_oopptr(); |
974 } else if (n->is_Phi() || | |
975 n->is_CheckCastPP() || | |
168
7793bd37a336
6705887: Compressed Oops: generate x64 addressing and implicit null checks with narrow oops
kvn
parents:
164
diff
changeset
|
976 n->is_EncodeP() || |
7793bd37a336
6705887: Compressed Oops: generate x64 addressing and implicit null checks with narrow oops
kvn
parents:
164
diff
changeset
|
977 n->is_DecodeN() || |
65 | 978 (n->is_ConstraintCast() && n->Opcode() == Op_CastPP)) { |
0 | 979 if (visited.test_set(n->_idx)) { |
980 assert(n->is_Phi(), "loops only through Phi's"); | |
981 continue; // already processed | |
982 } | |
983 ptset.Clear(); | |
984 PointsTo(ptset, n, igvn); | |
985 if (ptset.Size() == 1) { | |
65 | 986 uint elem = ptset.getelem(); // Allocation node's index |
987 if (elem == _phantom_object) | |
988 continue; // Assume the value was set outside this method. | |
989 Node *val = get_map(elem); // CheckCastPP node | |
0 | 990 TypeNode *tn = n->as_Type(); |
65 | 991 tinst = igvn->type(val)->isa_oopptr(); |
223 | 992 assert(tinst != NULL && tinst->is_known_instance() && |
993 (uint)tinst->instance_id() == elem , "instance type expected."); | |
163 | 994 |
995 const Type *tn_type = igvn->type(tn); | |
223 | 996 const TypeOopPtr *tn_t; |
997 if (tn_type->isa_narrowoop()) { | |
998 tn_t = tn_type->make_ptr()->isa_oopptr(); | |
999 } else { | |
1000 tn_t = tn_type->isa_oopptr(); | |
1001 } | |
0 | 1002 |
65 | 1003 if (tn_t != NULL && |
223 | 1004 tinst->cast_to_instance_id(TypeOopPtr::InstanceBot)->higher_equal(tn_t)) { |
163 | 1005 if (tn_type->isa_narrowoop()) { |
1006 tn_type = tinst->make_narrowoop(); | |
1007 } else { | |
1008 tn_type = tinst; | |
1009 } | |
0 | 1010 igvn->hash_delete(tn); |
163 | 1011 igvn->set_type(tn, tn_type); |
1012 tn->set_type(tn_type); | |
0 | 1013 igvn->hash_insert(tn); |
65 | 1014 record_for_optimizer(n); |
0 | 1015 } |
1016 } | |
1017 } else { | |
1018 continue; | |
1019 } | |
1020 // push users on appropriate worklist | |
1021 for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { | |
1022 Node *use = n->fast_out(i); | |
1023 if(use->is_Mem() && use->in(MemNode::Address) == n) { | |
65 | 1024 memnode_worklist.append_if_missing(use); |
1025 } else if (use->is_Initialize()) { | |
1026 memnode_worklist.append_if_missing(use); | |
1027 } else if (use->is_MergeMem()) { | |
1028 mergemem_worklist.append_if_missing(use); | |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1029 } else if (use->is_SafePoint() && tinst != NULL) { |
65 | 1030 // Look for MergeMem nodes for calls which reference unique allocation |
1031 // (through CheckCastPP nodes) even for debug info. | |
1032 Node* m = use->in(TypeFunc::Memory); | |
1033 uint iid = tinst->instance_id(); | |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1034 while (m->is_Proj() && m->in(0)->is_SafePoint() && |
65 | 1035 m->in(0) != use && !m->in(0)->_idx != iid) { |
1036 m = m->in(0)->in(TypeFunc::Memory); | |
1037 } | |
1038 if (m->is_MergeMem()) { | |
1039 mergemem_worklist.append_if_missing(m); | |
1040 } | |
1041 } else if (use->is_AddP() && use->outcnt() > 0) { // No dead nodes | |
1042 Node* addp2 = find_second_addp(use, n); | |
1043 if (addp2 != NULL) { | |
1044 alloc_worklist.append_if_missing(addp2); | |
1045 } | |
1046 alloc_worklist.append_if_missing(use); | |
1047 } else if (use->is_Phi() || | |
1048 use->is_CheckCastPP() || | |
168
7793bd37a336
6705887: Compressed Oops: generate x64 addressing and implicit null checks with narrow oops
kvn
parents:
164
diff
changeset
|
1049 use->is_EncodeP() || |
7793bd37a336
6705887: Compressed Oops: generate x64 addressing and implicit null checks with narrow oops
kvn
parents:
164
diff
changeset
|
1050 use->is_DecodeN() || |
65 | 1051 (use->is_ConstraintCast() && use->Opcode() == Op_CastPP)) { |
1052 alloc_worklist.append_if_missing(use); | |
0 | 1053 } |
1054 } | |
1055 | |
1056 } | |
65 | 1057 // New alias types were created in split_AddP(). |
0 | 1058 uint new_index_end = (uint) _compile->num_alias_types(); |
1059 | |
1060 // Phase 2: Process MemNode's from memnode_worklist. compute new address type and | |
1061 // compute new values for Memory inputs (the Memory inputs are not | |
1062 // actually updated until phase 4.) | |
1063 if (memnode_worklist.length() == 0) | |
1064 return; // nothing to do | |
1065 | |
1066 while (memnode_worklist.length() != 0) { | |
1067 Node *n = memnode_worklist.pop(); | |
65 | 1068 if (visited.test_set(n->_idx)) |
1069 continue; | |
0 | 1070 if (n->is_Phi()) { |
1071 assert(n->as_Phi()->adr_type() != TypePtr::BOTTOM, "narrow memory slice required"); | |
1072 // we don't need to do anything, but the users must be pushed if we haven't processed | |
1073 // this Phi before | |
65 | 1074 } else if (n->is_Initialize()) { |
1075 // we don't need to do anything, but the users of the memory projection must be pushed | |
1076 n = n->as_Initialize()->proj_out(TypeFunc::Memory); | |
1077 if (n == NULL) | |
0 | 1078 continue; |
1079 } else { | |
1080 assert(n->is_Mem(), "memory node required."); | |
1081 Node *addr = n->in(MemNode::Address); | |
65 | 1082 assert(addr->is_AddP(), "AddP required"); |
0 | 1083 const Type *addr_t = igvn->type(addr); |
1084 if (addr_t == Type::TOP) | |
1085 continue; | |
1086 assert (addr_t->isa_ptr() != NULL, "pointer type required."); | |
1087 int alias_idx = _compile->get_alias_index(addr_t->is_ptr()); | |
65 | 1088 assert ((uint)alias_idx < new_index_end, "wrong alias index"); |
1089 Node *mem = find_inst_mem(n->in(MemNode::Memory), alias_idx, orig_phis, igvn); | |
38
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
1090 if (_compile->failing()) { |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
1091 return; |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
1092 } |
65 | 1093 if (mem != n->in(MemNode::Memory)) { |
0 | 1094 set_map(n->_idx, mem); |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1095 ptnode_adr(n->_idx)->_node = n; |
65 | 1096 } |
0 | 1097 if (n->is_Load()) { |
1098 continue; // don't push users | |
1099 } else if (n->is_LoadStore()) { | |
1100 // get the memory projection | |
1101 for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { | |
1102 Node *use = n->fast_out(i); | |
1103 if (use->Opcode() == Op_SCMemProj) { | |
1104 n = use; | |
1105 break; | |
1106 } | |
1107 } | |
1108 assert(n->Opcode() == Op_SCMemProj, "memory projection required"); | |
1109 } | |
1110 } | |
1111 // push user on appropriate worklist | |
1112 for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { | |
1113 Node *use = n->fast_out(i); | |
1114 if (use->is_Phi()) { | |
65 | 1115 memnode_worklist.append_if_missing(use); |
0 | 1116 } else if(use->is_Mem() && use->in(MemNode::Memory) == n) { |
65 | 1117 memnode_worklist.append_if_missing(use); |
1118 } else if (use->is_Initialize()) { | |
1119 memnode_worklist.append_if_missing(use); | |
0 | 1120 } else if (use->is_MergeMem()) { |
65 | 1121 mergemem_worklist.append_if_missing(use); |
0 | 1122 } |
1123 } | |
1124 } | |
1125 | |
65 | 1126 // Phase 3: Process MergeMem nodes from mergemem_worklist. |
1127 // Walk each memory moving the first node encountered of each | |
1128 // instance type to the the input corresponding to its alias index. | |
0 | 1129 while (mergemem_worklist.length() != 0) { |
1130 Node *n = mergemem_worklist.pop(); | |
1131 assert(n->is_MergeMem(), "MergeMem node required."); | |
65 | 1132 if (visited.test_set(n->_idx)) |
1133 continue; | |
0 | 1134 MergeMemNode *nmm = n->as_MergeMem(); |
1135 // Note: we don't want to use MergeMemStream here because we only want to | |
65 | 1136 // scan inputs which exist at the start, not ones we add during processing. |
0 | 1137 uint nslices = nmm->req(); |
1138 igvn->hash_delete(nmm); | |
1139 for (uint i = Compile::AliasIdxRaw+1; i < nslices; i++) { | |
65 | 1140 Node* mem = nmm->in(i); |
1141 Node* cur = NULL; | |
0 | 1142 if (mem == NULL || mem->is_top()) |
1143 continue; | |
1144 while (mem->is_Mem()) { | |
1145 const Type *at = igvn->type(mem->in(MemNode::Address)); | |
1146 if (at != Type::TOP) { | |
1147 assert (at->isa_ptr() != NULL, "pointer type required."); | |
1148 uint idx = (uint)_compile->get_alias_index(at->is_ptr()); | |
1149 if (idx == i) { | |
1150 if (cur == NULL) | |
1151 cur = mem; | |
1152 } else { | |
1153 if (idx >= nmm->req() || nmm->is_empty_memory(nmm->in(idx))) { | |
1154 nmm->set_memory_at(idx, mem); | |
1155 } | |
1156 } | |
1157 } | |
1158 mem = mem->in(MemNode::Memory); | |
1159 } | |
1160 nmm->set_memory_at(i, (cur != NULL) ? cur : mem); | |
65 | 1161 // Find any instance of the current type if we haven't encountered |
1162 // a value of the instance along the chain. | |
1163 for (uint ni = new_index_start; ni < new_index_end; ni++) { | |
1164 if((uint)_compile->get_general_index(ni) == i) { | |
1165 Node *m = (ni >= nmm->req()) ? nmm->empty_memory() : nmm->in(ni); | |
1166 if (nmm->is_empty_memory(m)) { | |
1167 Node* result = find_inst_mem(mem, ni, orig_phis, igvn); | |
1168 if (_compile->failing()) { | |
1169 return; | |
1170 } | |
1171 nmm->set_memory_at(ni, result); | |
1172 } | |
1173 } | |
1174 } | |
1175 } | |
1176 // Find the rest of instances values | |
1177 for (uint ni = new_index_start; ni < new_index_end; ni++) { | |
1178 const TypeOopPtr *tinst = igvn->C->get_adr_type(ni)->isa_oopptr(); | |
1179 Node* result = step_through_mergemem(nmm, ni, tinst); | |
1180 if (result == nmm->base_memory()) { | |
1181 // Didn't find instance memory, search through general slice recursively. | |
1182 result = nmm->memory_at(igvn->C->get_general_index(ni)); | |
1183 result = find_inst_mem(result, ni, orig_phis, igvn); | |
1184 if (_compile->failing()) { | |
1185 return; | |
1186 } | |
1187 nmm->set_memory_at(ni, result); | |
1188 } | |
1189 } | |
1190 igvn->hash_insert(nmm); | |
1191 record_for_optimizer(nmm); | |
1192 | |
1193 // Propagate new memory slices to following MergeMem nodes. | |
1194 for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { | |
1195 Node *use = n->fast_out(i); | |
1196 if (use->is_Call()) { | |
1197 CallNode* in = use->as_Call(); | |
1198 if (in->proj_out(TypeFunc::Memory) != NULL) { | |
1199 Node* m = in->proj_out(TypeFunc::Memory); | |
1200 for (DUIterator_Fast jmax, j = m->fast_outs(jmax); j < jmax; j++) { | |
1201 Node* mm = m->fast_out(j); | |
1202 if (mm->is_MergeMem()) { | |
1203 mergemem_worklist.append_if_missing(mm); | |
1204 } | |
1205 } | |
1206 } | |
1207 if (use->is_Allocate()) { | |
1208 use = use->as_Allocate()->initialization(); | |
1209 if (use == NULL) { | |
1210 continue; | |
1211 } | |
1212 } | |
1213 } | |
1214 if (use->is_Initialize()) { | |
1215 InitializeNode* in = use->as_Initialize(); | |
1216 if (in->proj_out(TypeFunc::Memory) != NULL) { | |
1217 Node* m = in->proj_out(TypeFunc::Memory); | |
1218 for (DUIterator_Fast jmax, j = m->fast_outs(jmax); j < jmax; j++) { | |
1219 Node* mm = m->fast_out(j); | |
1220 if (mm->is_MergeMem()) { | |
1221 mergemem_worklist.append_if_missing(mm); | |
0 | 1222 } |
1223 } | |
1224 } | |
1225 } | |
1226 } | |
1227 } | |
1228 | |
65 | 1229 // Phase 4: Update the inputs of non-instance memory Phis and |
1230 // the Memory input of memnodes | |
0 | 1231 // First update the inputs of any non-instance Phi's from |
1232 // which we split out an instance Phi. Note we don't have | |
1233 // to recursively process Phi's encounted on the input memory | |
1234 // chains as is done in split_memory_phi() since they will | |
1235 // also be processed here. | |
247 | 1236 for (int j = 0; j < orig_phis.length(); j++) { |
1237 PhiNode *phi = orig_phis.at(j); | |
0 | 1238 int alias_idx = _compile->get_alias_index(phi->adr_type()); |
1239 igvn->hash_delete(phi); | |
1240 for (uint i = 1; i < phi->req(); i++) { | |
1241 Node *mem = phi->in(i); | |
65 | 1242 Node *new_mem = find_inst_mem(mem, alias_idx, orig_phis, igvn); |
1243 if (_compile->failing()) { | |
1244 return; | |
1245 } | |
0 | 1246 if (mem != new_mem) { |
1247 phi->set_req(i, new_mem); | |
1248 } | |
1249 } | |
1250 igvn->hash_insert(phi); | |
1251 record_for_optimizer(phi); | |
1252 } | |
1253 | |
1254 // Update the memory inputs of MemNodes with the value we computed | |
1255 // in Phase 2. | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1256 for (uint i = 0; i < nodes_size(); i++) { |
0 | 1257 Node *nmem = get_map(i); |
1258 if (nmem != NULL) { | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1259 Node *n = ptnode_adr(i)->_node; |
0 | 1260 if (n != NULL && n->is_Mem()) { |
1261 igvn->hash_delete(n); | |
1262 n->set_req(MemNode::Memory, nmem); | |
1263 igvn->hash_insert(n); | |
1264 record_for_optimizer(n); | |
1265 } | |
1266 } | |
1267 } | |
1268 } | |
1269 | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1270 bool ConnectionGraph::has_candidates(Compile *C) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1271 // EA brings benefits only when the code has allocations and/or locks which |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1272 // are represented by ideal Macro nodes. |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1273 int cnt = C->macro_count(); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1274 for( int i=0; i < cnt; i++ ) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1275 Node *n = C->macro_node(i); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1276 if ( n->is_Allocate() ) |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1277 return true; |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1278 if( n->is_Lock() ) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1279 Node* obj = n->as_Lock()->obj_node()->uncast(); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1280 if( !(obj->is_Parm() || obj->is_Con()) ) |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1281 return true; |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1282 } |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1283 } |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1284 return false; |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1285 } |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1286 |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1287 bool ConnectionGraph::compute_escape() { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1288 Compile* C = _compile; |
65 | 1289 |
163 | 1290 // 1. Populate Connection Graph (CG) with Ideal nodes. |
65 | 1291 |
1292 Unique_Node_List worklist_init; | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1293 worklist_init.map(C->unique(), NULL); // preallocate space |
65 | 1294 |
1295 // Initialize worklist | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1296 if (C->root() != NULL) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1297 worklist_init.push(C->root()); |
65 | 1298 } |
1299 | |
1300 GrowableArray<int> cg_worklist; | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1301 PhaseGVN* igvn = C->initial_gvn(); |
65 | 1302 bool has_allocations = false; |
1303 | |
1304 // Push all useful nodes onto CG list and set their type. | |
1305 for( uint next = 0; next < worklist_init.size(); ++next ) { | |
1306 Node* n = worklist_init.at(next); | |
1307 record_for_escape_analysis(n, igvn); | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1308 // Only allocations and java static calls results are checked |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1309 // for an escape status. See process_call_result() below. |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1310 if (n->is_Allocate() || n->is_CallStaticJava() && |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1311 ptnode_adr(n->_idx)->node_type() == PointsToNode::JavaObject) { |
65 | 1312 has_allocations = true; |
1313 } | |
1314 if(n->is_AddP()) | |
1315 cg_worklist.append(n->_idx); | |
1316 for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { | |
1317 Node* m = n->fast_out(i); // Get user | |
1318 worklist_init.push(m); | |
1319 } | |
1320 } | |
0 | 1321 |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1322 if (!has_allocations) { |
65 | 1323 _collecting = false; |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1324 return false; // Nothing to do. |
65 | 1325 } |
1326 | |
1327 // 2. First pass to create simple CG edges (doesn't require to walk CG). | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1328 uint delayed_size = _delayed_worklist.size(); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1329 for( uint next = 0; next < delayed_size; ++next ) { |
65 | 1330 Node* n = _delayed_worklist.at(next); |
1331 build_connection_graph(n, igvn); | |
1332 } | |
0 | 1333 |
65 | 1334 // 3. Pass to create fields edges (Allocate -F-> AddP). |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1335 uint cg_length = cg_worklist.length(); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1336 for( uint next = 0; next < cg_length; ++next ) { |
65 | 1337 int ni = cg_worklist.at(next); |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1338 build_connection_graph(ptnode_adr(ni)->_node, igvn); |
65 | 1339 } |
1340 | |
1341 cg_worklist.clear(); | |
1342 cg_worklist.append(_phantom_object); | |
1343 | |
1344 // 4. Build Connection Graph which need | |
1345 // to walk the connection graph. | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1346 for (uint ni = 0; ni < nodes_size(); ni++) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1347 PointsToNode* ptn = ptnode_adr(ni); |
65 | 1348 Node *n = ptn->_node; |
1349 if (n != NULL) { // Call, AddP, LoadP, StoreP | |
1350 build_connection_graph(n, igvn); | |
1351 if (ptn->node_type() != PointsToNode::UnknownType) | |
1352 cg_worklist.append(n->_idx); // Collect CG nodes | |
1353 } | |
0 | 1354 } |
1355 | |
1356 VectorSet ptset(Thread::current()->resource_area()); | |
101
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
1357 GrowableArray<uint> deferred_edges; |
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
1358 VectorSet visited(Thread::current()->resource_area()); |
0 | 1359 |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1360 // 5. Remove deferred edges from the graph and collect |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1361 // information needed for type splitting. |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1362 cg_length = cg_worklist.length(); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1363 for( uint next = 0; next < cg_length; ++next ) { |
65 | 1364 int ni = cg_worklist.at(next); |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1365 PointsToNode* ptn = ptnode_adr(ni); |
0 | 1366 PointsToNode::NodeType nt = ptn->node_type(); |
1367 if (nt == PointsToNode::LocalVar || nt == PointsToNode::Field) { | |
101
a6cb86dd209b
6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01
kvn
parents:
65
diff
changeset
|
1368 remove_deferred(ni, &deferred_edges, &visited); |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1369 Node *n = ptn->_node; |
0 | 1370 if (n->is_AddP()) { |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1371 // Search for objects which are not scalar replaceable. |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1372 // Mark their escape state as ArgEscape to propagate the state |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1373 // to referenced objects. |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1374 // Note: currently there are no difference in compiler optimizations |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1375 // for ArgEscape objects and NoEscape objects which are not |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1376 // scalar replaceable. |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1377 |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1378 int offset = ptn->offset(); |
65 | 1379 Node *base = get_addp_base(n); |
0 | 1380 ptset.Clear(); |
1381 PointsTo(ptset, base, igvn); | |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1382 int ptset_size = ptset.Size(); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1383 |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1384 // Check if a field's initializing value is recorded and add |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1385 // a corresponding NULL field's value if it is not recorded. |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1386 // Connection Graph does not record a default initialization by NULL |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1387 // captured by Initialize node. |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1388 // |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1389 // Note: it will disable scalar replacement in some cases: |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1390 // |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1391 // Point p[] = new Point[1]; |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1392 // p[0] = new Point(); // Will be not scalar replaced |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1393 // |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1394 // but it will save us from incorrect optimizations in next cases: |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1395 // |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1396 // Point p[] = new Point[1]; |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1397 // if ( x ) p[0] = new Point(); // Will be not scalar replaced |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1398 // |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1399 // Without a control flow analysis we can't distinguish above cases. |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1400 // |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1401 if (offset != Type::OffsetBot && ptset_size == 1) { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1402 uint elem = ptset.getelem(); // Allocation node's index |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1403 // It does not matter if it is not Allocation node since |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1404 // only non-escaping allocations are scalar replaced. |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1405 if (ptnode_adr(elem)->_node->is_Allocate() && |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1406 ptnode_adr(elem)->escape_state() == PointsToNode::NoEscape) { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1407 AllocateNode* alloc = ptnode_adr(elem)->_node->as_Allocate(); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1408 InitializeNode* ini = alloc->initialization(); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1409 Node* value = NULL; |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1410 if (ini != NULL) { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1411 BasicType ft = UseCompressedOops ? T_NARROWOOP : T_OBJECT; |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1412 Node* store = ini->find_captured_store(offset, type2aelembytes(ft), igvn); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1413 if (store != NULL && store->is_Store()) |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1414 value = store->in(MemNode::ValueIn); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1415 } |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1416 if (value == NULL || value != ptnode_adr(value->_idx)->_node) { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1417 // A field's initializing value was not recorded. Add NULL. |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1418 uint null_idx = UseCompressedOops ? _noop_null : _oop_null; |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1419 add_pointsto_edge(ni, null_idx); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1420 } |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1421 } |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1422 } |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1423 |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1424 // An object is not scalar replaceable if the field which may point |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1425 // to it has unknown offset (unknown element of an array of objects). |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1426 // |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1427 if (offset == Type::OffsetBot) { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1428 uint e_cnt = ptn->edge_count(); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1429 for (uint ei = 0; ei < e_cnt; ei++) { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1430 uint npi = ptn->edge_target(ei); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1431 set_escape_state(npi, PointsToNode::ArgEscape); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1432 ptnode_adr(npi)->_scalar_replaceable = false; |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1433 } |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1434 } |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1435 |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1436 // Currently an object is not scalar replaceable if a LoadStore node |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1437 // access its field since the field value is unknown after it. |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1438 // |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1439 bool has_LoadStore = false; |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1440 for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1441 Node *use = n->fast_out(i); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1442 if (use->is_LoadStore()) { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1443 has_LoadStore = true; |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1444 break; |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1445 } |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1446 } |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1447 // An object is not scalar replaceable if the address points |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1448 // to unknown field (unknown element for arrays, offset is OffsetBot). |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1449 // |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1450 // Or the address may point to more then one object. This may produce |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1451 // the false positive result (set scalar_replaceable to false) |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1452 // since the flow-insensitive escape analysis can't separate |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1453 // the case when stores overwrite the field's value from the case |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1454 // when stores happened on different control branches. |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1455 // |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1456 if (ptset_size > 1 || ptset_size != 0 && |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1457 (has_LoadStore || offset == Type::OffsetBot)) { |
0 | 1458 for( VectorSetI j(&ptset); j.test(); ++j ) { |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1459 set_escape_state(j.elem, PointsToNode::ArgEscape); |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1460 ptnode_adr(j.elem)->_scalar_replaceable = false; |
0 | 1461 } |
1462 } | |
1463 } | |
1464 } | |
1465 } | |
65 | 1466 |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1467 // 6. Propagate escape states. |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1468 GrowableArray<int> worklist; |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1469 bool has_non_escaping_obj = false; |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1470 |
0 | 1471 // push all GlobalEscape nodes on the worklist |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1472 for( uint next = 0; next < cg_length; ++next ) { |
65 | 1473 int nk = cg_worklist.at(next); |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1474 if (ptnode_adr(nk)->escape_state() == PointsToNode::GlobalEscape) |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1475 worklist.push(nk); |
0 | 1476 } |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1477 // mark all nodes reachable from GlobalEscape nodes |
0 | 1478 while(worklist.length() > 0) { |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1479 PointsToNode* ptn = ptnode_adr(worklist.pop()); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1480 uint e_cnt = ptn->edge_count(); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1481 for (uint ei = 0; ei < e_cnt; ei++) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1482 uint npi = ptn->edge_target(ei); |
0 | 1483 PointsToNode *np = ptnode_adr(npi); |
65 | 1484 if (np->escape_state() < PointsToNode::GlobalEscape) { |
0 | 1485 np->set_escape_state(PointsToNode::GlobalEscape); |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1486 worklist.push(npi); |
0 | 1487 } |
1488 } | |
1489 } | |
1490 | |
1491 // push all ArgEscape nodes on the worklist | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1492 for( uint next = 0; next < cg_length; ++next ) { |
65 | 1493 int nk = cg_worklist.at(next); |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1494 if (ptnode_adr(nk)->escape_state() == PointsToNode::ArgEscape) |
0 | 1495 worklist.push(nk); |
1496 } | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1497 // mark all nodes reachable from ArgEscape nodes |
0 | 1498 while(worklist.length() > 0) { |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1499 PointsToNode* ptn = ptnode_adr(worklist.pop()); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1500 if (ptn->node_type() == PointsToNode::JavaObject) |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1501 has_non_escaping_obj = true; // Non GlobalEscape |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1502 uint e_cnt = ptn->edge_count(); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1503 for (uint ei = 0; ei < e_cnt; ei++) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1504 uint npi = ptn->edge_target(ei); |
0 | 1505 PointsToNode *np = ptnode_adr(npi); |
65 | 1506 if (np->escape_state() < PointsToNode::ArgEscape) { |
0 | 1507 np->set_escape_state(PointsToNode::ArgEscape); |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1508 worklist.push(npi); |
0 | 1509 } |
1510 } | |
1511 } | |
65 | 1512 |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1513 GrowableArray<Node*> alloc_worklist; |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1514 |
65 | 1515 // push all NoEscape nodes on the worklist |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1516 for( uint next = 0; next < cg_length; ++next ) { |
65 | 1517 int nk = cg_worklist.at(next); |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1518 if (ptnode_adr(nk)->escape_state() == PointsToNode::NoEscape) |
65 | 1519 worklist.push(nk); |
1520 } | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1521 // mark all nodes reachable from NoEscape nodes |
65 | 1522 while(worklist.length() > 0) { |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1523 PointsToNode* ptn = ptnode_adr(worklist.pop()); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1524 if (ptn->node_type() == PointsToNode::JavaObject) |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1525 has_non_escaping_obj = true; // Non GlobalEscape |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1526 Node* n = ptn->_node; |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1527 if (n->is_Allocate() && ptn->_scalar_replaceable ) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1528 // Push scalar replaceable alocations on alloc_worklist |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1529 // for processing in split_unique_types(). |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1530 alloc_worklist.append(n); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1531 } |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1532 uint e_cnt = ptn->edge_count(); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1533 for (uint ei = 0; ei < e_cnt; ei++) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1534 uint npi = ptn->edge_target(ei); |
65 | 1535 PointsToNode *np = ptnode_adr(npi); |
1536 if (np->escape_state() < PointsToNode::NoEscape) { | |
1537 np->set_escape_state(PointsToNode::NoEscape); | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1538 worklist.push(npi); |
65 | 1539 } |
1540 } | |
1541 } | |
1542 | |
0 | 1543 _collecting = false; |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1544 assert(C->unique() == nodes_size(), "there should be no new ideal nodes during ConnectionGraph build"); |
0 | 1545 |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1546 bool has_scalar_replaceable_candidates = alloc_worklist.length() > 0; |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1547 if ( has_scalar_replaceable_candidates && |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1548 C->AliasLevel() >= 3 && EliminateAllocations ) { |
0 | 1549 |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1550 // Now use the escape information to create unique types for |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1551 // scalar replaceable objects. |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1552 split_unique_types(alloc_worklist); |
0 | 1553 |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1554 if (C->failing()) return false; |
0 | 1555 |
65 | 1556 // Clean up after split unique types. |
1557 ResourceMark rm; | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1558 PhaseRemoveUseless pru(C->initial_gvn(), C->for_igvn()); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1559 |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1560 C->print_method("After Escape Analysis", 2); |
0 | 1561 |
65 | 1562 #ifdef ASSERT |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1563 } else if (Verbose && (PrintEscapeAnalysis || PrintEliminateAllocations)) { |
65 | 1564 tty->print("=== No allocations eliminated for "); |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1565 C->method()->print_short_name(); |
65 | 1566 if(!EliminateAllocations) { |
1567 tty->print(" since EliminateAllocations is off ==="); | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1568 } else if(!has_scalar_replaceable_candidates) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1569 tty->print(" since there are no scalar replaceable candidates ==="); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1570 } else if(C->AliasLevel() < 3) { |
65 | 1571 tty->print(" since AliasLevel < 3 ==="); |
0 | 1572 } |
65 | 1573 tty->cr(); |
1574 #endif | |
0 | 1575 } |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1576 return has_non_escaping_obj; |
0 | 1577 } |
1578 | |
1579 void ConnectionGraph::process_call_arguments(CallNode *call, PhaseTransform *phase) { | |
1580 | |
1581 switch (call->Opcode()) { | |
65 | 1582 #ifdef ASSERT |
0 | 1583 case Op_Allocate: |
1584 case Op_AllocateArray: | |
1585 case Op_Lock: | |
1586 case Op_Unlock: | |
65 | 1587 assert(false, "should be done already"); |
0 | 1588 break; |
65 | 1589 #endif |
1590 case Op_CallLeafNoFP: | |
1591 { | |
1592 // Stub calls, objects do not escape but they are not scale replaceable. | |
1593 // Adjust escape state for outgoing arguments. | |
1594 const TypeTuple * d = call->tf()->domain(); | |
1595 VectorSet ptset(Thread::current()->resource_area()); | |
1596 for (uint i = TypeFunc::Parms; i < d->cnt(); i++) { | |
1597 const Type* at = d->field_at(i); | |
1598 Node *arg = call->in(i)->uncast(); | |
1599 const Type *aat = phase->type(arg); | |
1600 if (!arg->is_top() && at->isa_ptr() && aat->isa_ptr()) { | |
1601 assert(aat == Type::TOP || aat == TypePtr::NULL_PTR || | |
1602 aat->isa_ptr() != NULL, "expecting an Ptr"); | |
1603 set_escape_state(arg->_idx, PointsToNode::ArgEscape); | |
1604 if (arg->is_AddP()) { | |
1605 // | |
1606 // The inline_native_clone() case when the arraycopy stub is called | |
1607 // after the allocation before Initialize and CheckCastPP nodes. | |
1608 // | |
1609 // Set AddP's base (Allocate) as not scalar replaceable since | |
1610 // pointer to the base (with offset) is passed as argument. | |
1611 // | |
1612 arg = get_addp_base(arg); | |
1613 } | |
1614 ptset.Clear(); | |
1615 PointsTo(ptset, arg, phase); | |
1616 for( VectorSetI j(&ptset); j.test(); ++j ) { | |
1617 uint pt = j.elem; | |
1618 set_escape_state(pt, PointsToNode::ArgEscape); | |
1619 } | |
1620 } | |
1621 } | |
1622 break; | |
1623 } | |
0 | 1624 |
1625 case Op_CallStaticJava: | |
1626 // For a static call, we know exactly what method is being called. | |
1627 // Use bytecode estimator to record the call's escape affects | |
1628 { | |
1629 ciMethod *meth = call->as_CallJava()->method(); | |
65 | 1630 BCEscapeAnalyzer *call_analyzer = (meth !=NULL) ? meth->get_bcea() : NULL; |
1631 // fall-through if not a Java method or no analyzer information | |
1632 if (call_analyzer != NULL) { | |
0 | 1633 const TypeTuple * d = call->tf()->domain(); |
1634 VectorSet ptset(Thread::current()->resource_area()); | |
65 | 1635 bool copy_dependencies = false; |
0 | 1636 for (uint i = TypeFunc::Parms; i < d->cnt(); i++) { |
1637 const Type* at = d->field_at(i); | |
1638 int k = i - TypeFunc::Parms; | |
1639 | |
1640 if (at->isa_oopptr() != NULL) { | |
65 | 1641 Node *arg = call->in(i)->uncast(); |
0 | 1642 |
65 | 1643 bool global_escapes = false; |
1644 bool fields_escapes = false; | |
1645 if (!call_analyzer->is_arg_stack(k)) { | |
1646 // The argument global escapes, mark everything it could point to | |
1647 set_escape_state(arg->_idx, PointsToNode::GlobalEscape); | |
1648 global_escapes = true; | |
1649 } else { | |
1650 if (!call_analyzer->is_arg_local(k)) { | |
1651 // The argument itself doesn't escape, but any fields might | |
1652 fields_escapes = true; | |
0 | 1653 } |
65 | 1654 set_escape_state(arg->_idx, PointsToNode::ArgEscape); |
1655 copy_dependencies = true; | |
1656 } | |
1657 | |
1658 ptset.Clear(); | |
1659 PointsTo(ptset, arg, phase); | |
1660 for( VectorSetI j(&ptset); j.test(); ++j ) { | |
1661 uint pt = j.elem; | |
1662 if (global_escapes) { | |
1663 //The argument global escapes, mark everything it could point to | |
1664 set_escape_state(pt, PointsToNode::GlobalEscape); | |
1665 } else { | |
1666 if (fields_escapes) { | |
1667 // The argument itself doesn't escape, but any fields might | |
1668 add_edge_from_fields(pt, _phantom_object, Type::OffsetBot); | |
1669 } | |
1670 set_escape_state(pt, PointsToNode::ArgEscape); | |
0 | 1671 } |
1672 } | |
1673 } | |
1674 } | |
65 | 1675 if (copy_dependencies) |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1676 call_analyzer->copy_dependencies(_compile->dependencies()); |
0 | 1677 break; |
1678 } | |
1679 } | |
1680 | |
1681 default: | |
65 | 1682 // Fall-through here if not a Java method or no analyzer information |
1683 // or some other type of call, assume the worst case: all arguments | |
0 | 1684 // globally escape. |
1685 { | |
1686 // adjust escape state for outgoing arguments | |
1687 const TypeTuple * d = call->tf()->domain(); | |
1688 VectorSet ptset(Thread::current()->resource_area()); | |
1689 for (uint i = TypeFunc::Parms; i < d->cnt(); i++) { | |
1690 const Type* at = d->field_at(i); | |
1691 if (at->isa_oopptr() != NULL) { | |
65 | 1692 Node *arg = call->in(i)->uncast(); |
1693 set_escape_state(arg->_idx, PointsToNode::GlobalEscape); | |
0 | 1694 ptset.Clear(); |
1695 PointsTo(ptset, arg, phase); | |
1696 for( VectorSetI j(&ptset); j.test(); ++j ) { | |
1697 uint pt = j.elem; | |
1698 set_escape_state(pt, PointsToNode::GlobalEscape); | |
1699 } | |
1700 } | |
1701 } | |
1702 } | |
1703 } | |
1704 } | |
1705 void ConnectionGraph::process_call_result(ProjNode *resproj, PhaseTransform *phase) { | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1706 CallNode *call = resproj->in(0)->as_Call(); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1707 uint call_idx = call->_idx; |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1708 uint resproj_idx = resproj->_idx; |
0 | 1709 |
1710 switch (call->Opcode()) { | |
1711 case Op_Allocate: | |
1712 { | |
1713 Node *k = call->in(AllocateNode::KlassNode); | |
1714 const TypeKlassPtr *kt; | |
1715 if (k->Opcode() == Op_LoadKlass) { | |
1716 kt = k->as_Load()->type()->isa_klassptr(); | |
1717 } else { | |
164
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
1718 // Also works for DecodeN(LoadNKlass). |
0 | 1719 kt = k->as_Type()->type()->isa_klassptr(); |
1720 } | |
1721 assert(kt != NULL, "TypeKlassPtr required."); | |
1722 ciKlass* cik = kt->klass(); | |
1723 ciInstanceKlass* ciik = cik->as_instance_klass(); | |
1724 | |
65 | 1725 PointsToNode::EscapeState es; |
1726 uint edge_to; | |
0 | 1727 if (cik->is_subclass_of(_compile->env()->Thread_klass()) || ciik->has_finalizer()) { |
65 | 1728 es = PointsToNode::GlobalEscape; |
1729 edge_to = _phantom_object; // Could not be worse | |
0 | 1730 } else { |
65 | 1731 es = PointsToNode::NoEscape; |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1732 edge_to = call_idx; |
0 | 1733 } |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1734 set_escape_state(call_idx, es); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1735 add_pointsto_edge(resproj_idx, edge_to); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1736 _processed.set(resproj_idx); |
0 | 1737 break; |
1738 } | |
1739 | |
1740 case Op_AllocateArray: | |
1741 { | |
65 | 1742 int length = call->in(AllocateNode::ALength)->find_int_con(-1); |
1743 if (length < 0 || length > EliminateAllocationArraySizeLimit) { | |
1744 // Not scalar replaceable if the length is not constant or too big. | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1745 ptnode_adr(call_idx)->_scalar_replaceable = false; |
65 | 1746 } |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1747 set_escape_state(call_idx, PointsToNode::NoEscape); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1748 add_pointsto_edge(resproj_idx, call_idx); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1749 _processed.set(resproj_idx); |
0 | 1750 break; |
1751 } | |
1752 | |
1753 case Op_CallStaticJava: | |
1754 // For a static call, we know exactly what method is being called. | |
1755 // Use bytecode estimator to record whether the call's return value escapes | |
1756 { | |
65 | 1757 bool done = true; |
0 | 1758 const TypeTuple *r = call->tf()->range(); |
1759 const Type* ret_type = NULL; | |
1760 | |
1761 if (r->cnt() > TypeFunc::Parms) | |
1762 ret_type = r->field_at(TypeFunc::Parms); | |
1763 | |
1764 // Note: we use isa_ptr() instead of isa_oopptr() here because the | |
1765 // _multianewarray functions return a TypeRawPtr. | |
65 | 1766 if (ret_type == NULL || ret_type->isa_ptr() == NULL) { |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1767 _processed.set(resproj_idx); |
0 | 1768 break; // doesn't return a pointer type |
65 | 1769 } |
0 | 1770 ciMethod *meth = call->as_CallJava()->method(); |
65 | 1771 const TypeTuple * d = call->tf()->domain(); |
0 | 1772 if (meth == NULL) { |
1773 // not a Java method, assume global escape | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1774 set_escape_state(call_idx, PointsToNode::GlobalEscape); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1775 add_pointsto_edge(resproj_idx, _phantom_object); |
0 | 1776 } else { |
65 | 1777 BCEscapeAnalyzer *call_analyzer = meth->get_bcea(); |
1778 bool copy_dependencies = false; | |
0 | 1779 |
65 | 1780 if (call_analyzer->is_return_allocated()) { |
1781 // Returns a newly allocated unescaped object, simply | |
1782 // update dependency information. | |
1783 // Mark it as NoEscape so that objects referenced by | |
1784 // it's fields will be marked as NoEscape at least. | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1785 set_escape_state(call_idx, PointsToNode::NoEscape); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1786 add_pointsto_edge(resproj_idx, call_idx); |
65 | 1787 copy_dependencies = true; |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1788 } else if (call_analyzer->is_return_local()) { |
0 | 1789 // determine whether any arguments are returned |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1790 set_escape_state(call_idx, PointsToNode::NoEscape); |
0 | 1791 for (uint i = TypeFunc::Parms; i < d->cnt(); i++) { |
1792 const Type* at = d->field_at(i); | |
1793 | |
1794 if (at->isa_oopptr() != NULL) { | |
65 | 1795 Node *arg = call->in(i)->uncast(); |
0 | 1796 |
65 | 1797 if (call_analyzer->is_arg_returned(i - TypeFunc::Parms)) { |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1798 PointsToNode *arg_esp = ptnode_adr(arg->_idx); |
65 | 1799 if (arg_esp->node_type() == PointsToNode::UnknownType) |
1800 done = false; | |
1801 else if (arg_esp->node_type() == PointsToNode::JavaObject) | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1802 add_pointsto_edge(resproj_idx, arg->_idx); |
0 | 1803 else |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1804 add_deferred_edge(resproj_idx, arg->_idx); |
0 | 1805 arg_esp->_hidden_alias = true; |
1806 } | |
1807 } | |
1808 } | |
65 | 1809 copy_dependencies = true; |
0 | 1810 } else { |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1811 set_escape_state(call_idx, PointsToNode::GlobalEscape); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1812 add_pointsto_edge(resproj_idx, _phantom_object); |
65 | 1813 for (uint i = TypeFunc::Parms; i < d->cnt(); i++) { |
1814 const Type* at = d->field_at(i); | |
1815 if (at->isa_oopptr() != NULL) { | |
1816 Node *arg = call->in(i)->uncast(); | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1817 PointsToNode *arg_esp = ptnode_adr(arg->_idx); |
65 | 1818 arg_esp->_hidden_alias = true; |
1819 } | |
1820 } | |
0 | 1821 } |
65 | 1822 if (copy_dependencies) |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1823 call_analyzer->copy_dependencies(_compile->dependencies()); |
0 | 1824 } |
65 | 1825 if (done) |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1826 _processed.set(resproj_idx); |
0 | 1827 break; |
1828 } | |
1829 | |
1830 default: | |
1831 // Some other type of call, assume the worst case that the | |
1832 // returned value, if any, globally escapes. | |
1833 { | |
1834 const TypeTuple *r = call->tf()->range(); | |
1835 if (r->cnt() > TypeFunc::Parms) { | |
1836 const Type* ret_type = r->field_at(TypeFunc::Parms); | |
1837 | |
1838 // Note: we use isa_ptr() instead of isa_oopptr() here because the | |
1839 // _multianewarray functions return a TypeRawPtr. | |
1840 if (ret_type->isa_ptr() != NULL) { | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1841 set_escape_state(call_idx, PointsToNode::GlobalEscape); |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1842 add_pointsto_edge(resproj_idx, _phantom_object); |
0 | 1843 } |
1844 } | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1845 _processed.set(resproj_idx); |
0 | 1846 } |
1847 } | |
1848 } | |
1849 | |
65 | 1850 // Populate Connection Graph with Ideal nodes and create simple |
1851 // connection graph edges (do not need to check the node_type of inputs | |
1852 // or to call PointsTo() to walk the connection graph). | |
1853 void ConnectionGraph::record_for_escape_analysis(Node *n, PhaseTransform *phase) { | |
1854 if (_processed.test(n->_idx)) | |
1855 return; // No need to redefine node's state. | |
1856 | |
1857 if (n->is_Call()) { | |
1858 // Arguments to allocation and locking don't escape. | |
1859 if (n->is_Allocate()) { | |
1860 add_node(n, PointsToNode::JavaObject, PointsToNode::UnknownEscape, true); | |
1861 record_for_optimizer(n); | |
1862 } else if (n->is_Lock() || n->is_Unlock()) { | |
1863 // Put Lock and Unlock nodes on IGVN worklist to process them during | |
1864 // the first IGVN optimization when escape information is still available. | |
1865 record_for_optimizer(n); | |
1866 _processed.set(n->_idx); | |
1867 } else { | |
1868 // Have to process call's arguments first. | |
1869 PointsToNode::NodeType nt = PointsToNode::UnknownType; | |
1870 | |
1871 // Check if a call returns an object. | |
1872 const TypeTuple *r = n->as_Call()->tf()->range(); | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1873 if (n->is_CallStaticJava() && r->cnt() > TypeFunc::Parms && |
65 | 1874 n->as_Call()->proj_out(TypeFunc::Parms) != NULL) { |
1875 // Note: use isa_ptr() instead of isa_oopptr() here because | |
1876 // the _multianewarray functions return a TypeRawPtr. | |
1877 if (r->field_at(TypeFunc::Parms)->isa_ptr() != NULL) { | |
1878 nt = PointsToNode::JavaObject; | |
1879 } | |
1880 } | |
1881 add_node(n, nt, PointsToNode::UnknownEscape, false); | |
1882 } | |
1883 return; | |
1884 } | |
1885 | |
1886 // Using isa_ptr() instead of isa_oopptr() for LoadP and Phi because | |
1887 // ThreadLocal has RawPrt type. | |
1888 switch (n->Opcode()) { | |
1889 case Op_AddP: | |
1890 { | |
1891 add_node(n, PointsToNode::Field, PointsToNode::UnknownEscape, false); | |
1892 break; | |
1893 } | |
1894 case Op_CastX2P: | |
1895 { // "Unsafe" memory access. | |
1896 add_node(n, PointsToNode::JavaObject, PointsToNode::GlobalEscape, true); | |
1897 break; | |
1898 } | |
1899 case Op_CastPP: | |
1900 case Op_CheckCastPP: | |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
1901 case Op_EncodeP: |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
1902 case Op_DecodeN: |
65 | 1903 { |
1904 add_node(n, PointsToNode::LocalVar, PointsToNode::UnknownEscape, false); | |
1905 int ti = n->in(1)->_idx; | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1906 PointsToNode::NodeType nt = ptnode_adr(ti)->node_type(); |
65 | 1907 if (nt == PointsToNode::UnknownType) { |
1908 _delayed_worklist.push(n); // Process it later. | |
1909 break; | |
1910 } else if (nt == PointsToNode::JavaObject) { | |
1911 add_pointsto_edge(n->_idx, ti); | |
1912 } else { | |
1913 add_deferred_edge(n->_idx, ti); | |
1914 } | |
1915 _processed.set(n->_idx); | |
1916 break; | |
1917 } | |
1918 case Op_ConP: | |
1919 { | |
1920 // assume all pointer constants globally escape except for null | |
1921 PointsToNode::EscapeState es; | |
1922 if (phase->type(n) == TypePtr::NULL_PTR) | |
1923 es = PointsToNode::NoEscape; | |
1924 else | |
1925 es = PointsToNode::GlobalEscape; | |
0 | 1926 |
65 | 1927 add_node(n, PointsToNode::JavaObject, es, true); |
1928 break; | |
1929 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
102
diff
changeset
|
1930 case Op_ConN: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
102
diff
changeset
|
1931 { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
102
diff
changeset
|
1932 // assume all narrow oop constants globally escape except for null |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
102
diff
changeset
|
1933 PointsToNode::EscapeState es; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
102
diff
changeset
|
1934 if (phase->type(n) == TypeNarrowOop::NULL_PTR) |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
102
diff
changeset
|
1935 es = PointsToNode::NoEscape; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
102
diff
changeset
|
1936 else |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
102
diff
changeset
|
1937 es = PointsToNode::GlobalEscape; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
102
diff
changeset
|
1938 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
102
diff
changeset
|
1939 add_node(n, PointsToNode::JavaObject, es, true); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
102
diff
changeset
|
1940 break; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
102
diff
changeset
|
1941 } |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
1942 case Op_CreateEx: |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
1943 { |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
1944 // assume that all exception objects globally escape |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
1945 add_node(n, PointsToNode::JavaObject, PointsToNode::GlobalEscape, true); |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
1946 break; |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
1947 } |
65 | 1948 case Op_LoadKlass: |
164
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
1949 case Op_LoadNKlass: |
65 | 1950 { |
1951 add_node(n, PointsToNode::JavaObject, PointsToNode::GlobalEscape, true); | |
1952 break; | |
1953 } | |
1954 case Op_LoadP: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
102
diff
changeset
|
1955 case Op_LoadN: |
65 | 1956 { |
1957 const Type *t = phase->type(n); | |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1958 if (t->make_ptr() == NULL) { |
65 | 1959 _processed.set(n->_idx); |
1960 return; | |
1961 } | |
1962 add_node(n, PointsToNode::LocalVar, PointsToNode::UnknownEscape, false); | |
1963 break; | |
1964 } | |
1965 case Op_Parm: | |
1966 { | |
1967 _processed.set(n->_idx); // No need to redefine it state. | |
1968 uint con = n->as_Proj()->_con; | |
1969 if (con < TypeFunc::Parms) | |
1970 return; | |
1971 const Type *t = n->in(0)->as_Start()->_domain->field_at(con); | |
1972 if (t->isa_ptr() == NULL) | |
1973 return; | |
1974 // We have to assume all input parameters globally escape | |
1975 // (Note: passing 'false' since _processed is already set). | |
1976 add_node(n, PointsToNode::JavaObject, PointsToNode::GlobalEscape, false); | |
1977 break; | |
1978 } | |
1979 case Op_Phi: | |
1980 { | |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1981 const Type *t = n->as_Phi()->type(); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1982 if (t->make_ptr() == NULL) { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
1983 // nothing to do if not an oop or narrow oop |
65 | 1984 _processed.set(n->_idx); |
1985 return; | |
1986 } | |
1987 add_node(n, PointsToNode::LocalVar, PointsToNode::UnknownEscape, false); | |
1988 uint i; | |
1989 for (i = 1; i < n->req() ; i++) { | |
1990 Node* in = n->in(i); | |
1991 if (in == NULL) | |
1992 continue; // ignore NULL | |
1993 in = in->uncast(); | |
1994 if (in->is_top() || in == n) | |
1995 continue; // ignore top or inputs which go back this node | |
1996 int ti = in->_idx; | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
1997 PointsToNode::NodeType nt = ptnode_adr(ti)->node_type(); |
65 | 1998 if (nt == PointsToNode::UnknownType) { |
1999 break; | |
2000 } else if (nt == PointsToNode::JavaObject) { | |
2001 add_pointsto_edge(n->_idx, ti); | |
2002 } else { | |
2003 add_deferred_edge(n->_idx, ti); | |
2004 } | |
2005 } | |
2006 if (i >= n->req()) | |
2007 _processed.set(n->_idx); | |
2008 else | |
2009 _delayed_worklist.push(n); | |
2010 break; | |
2011 } | |
2012 case Op_Proj: | |
2013 { | |
2014 // we are only interested in the result projection from a call | |
2015 if (n->as_Proj()->_con == TypeFunc::Parms && n->in(0)->is_Call() ) { | |
2016 add_node(n, PointsToNode::LocalVar, PointsToNode::UnknownEscape, false); | |
2017 process_call_result(n->as_Proj(), phase); | |
2018 if (!_processed.test(n->_idx)) { | |
2019 // The call's result may need to be processed later if the call | |
2020 // returns it's argument and the argument is not processed yet. | |
2021 _delayed_worklist.push(n); | |
2022 } | |
2023 } else { | |
2024 _processed.set(n->_idx); | |
2025 } | |
2026 break; | |
2027 } | |
2028 case Op_Return: | |
2029 { | |
2030 if( n->req() > TypeFunc::Parms && | |
2031 phase->type(n->in(TypeFunc::Parms))->isa_oopptr() ) { | |
2032 // Treat Return value as LocalVar with GlobalEscape escape state. | |
2033 add_node(n, PointsToNode::LocalVar, PointsToNode::GlobalEscape, false); | |
2034 int ti = n->in(TypeFunc::Parms)->_idx; | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2035 PointsToNode::NodeType nt = ptnode_adr(ti)->node_type(); |
65 | 2036 if (nt == PointsToNode::UnknownType) { |
2037 _delayed_worklist.push(n); // Process it later. | |
2038 break; | |
2039 } else if (nt == PointsToNode::JavaObject) { | |
2040 add_pointsto_edge(n->_idx, ti); | |
2041 } else { | |
2042 add_deferred_edge(n->_idx, ti); | |
2043 } | |
2044 } | |
2045 _processed.set(n->_idx); | |
2046 break; | |
2047 } | |
2048 case Op_StoreP: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
102
diff
changeset
|
2049 case Op_StoreN: |
65 | 2050 { |
2051 const Type *adr_type = phase->type(n->in(MemNode::Address)); | |
221
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
168
diff
changeset
|
2052 adr_type = adr_type->make_ptr(); |
65 | 2053 if (adr_type->isa_oopptr()) { |
2054 add_node(n, PointsToNode::UnknownType, PointsToNode::UnknownEscape, false); | |
2055 } else { | |
2056 Node* adr = n->in(MemNode::Address); | |
2057 if (adr->is_AddP() && phase->type(adr) == TypeRawPtr::NOTNULL && | |
2058 adr->in(AddPNode::Address)->is_Proj() && | |
2059 adr->in(AddPNode::Address)->in(0)->is_Allocate()) { | |
2060 add_node(n, PointsToNode::UnknownType, PointsToNode::UnknownEscape, false); | |
2061 // We are computing a raw address for a store captured | |
2062 // by an Initialize compute an appropriate address type. | |
2063 int offs = (int)phase->find_intptr_t_con(adr->in(AddPNode::Offset), Type::OffsetBot); | |
2064 assert(offs != Type::OffsetBot, "offset must be a constant"); | |
2065 } else { | |
2066 _processed.set(n->_idx); | |
2067 return; | |
2068 } | |
2069 } | |
2070 break; | |
2071 } | |
2072 case Op_StorePConditional: | |
2073 case Op_CompareAndSwapP: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
102
diff
changeset
|
2074 case Op_CompareAndSwapN: |
65 | 2075 { |
2076 const Type *adr_type = phase->type(n->in(MemNode::Address)); | |
221
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
168
diff
changeset
|
2077 adr_type = adr_type->make_ptr(); |
65 | 2078 if (adr_type->isa_oopptr()) { |
2079 add_node(n, PointsToNode::UnknownType, PointsToNode::UnknownEscape, false); | |
2080 } else { | |
2081 _processed.set(n->_idx); | |
2082 return; | |
2083 } | |
2084 break; | |
2085 } | |
2086 case Op_ThreadLocal: | |
2087 { | |
2088 add_node(n, PointsToNode::JavaObject, PointsToNode::ArgEscape, true); | |
2089 break; | |
2090 } | |
2091 default: | |
2092 ; | |
2093 // nothing to do | |
2094 } | |
2095 return; | |
2096 } | |
2097 | |
2098 void ConnectionGraph::build_connection_graph(Node *n, PhaseTransform *phase) { | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2099 uint n_idx = n->_idx; |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2100 |
65 | 2101 // Don't set processed bit for AddP, LoadP, StoreP since |
2102 // they may need more then one pass to process. | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2103 if (_processed.test(n_idx)) |
65 | 2104 return; // No need to redefine node's state. |
2105 | |
0 | 2106 if (n->is_Call()) { |
2107 CallNode *call = n->as_Call(); | |
2108 process_call_arguments(call, phase); | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2109 _processed.set(n_idx); |
0 | 2110 return; |
2111 } | |
2112 | |
65 | 2113 switch (n->Opcode()) { |
0 | 2114 case Op_AddP: |
2115 { | |
65 | 2116 Node *base = get_addp_base(n); |
2117 // Create a field edge to this node from everything base could point to. | |
0 | 2118 VectorSet ptset(Thread::current()->resource_area()); |
2119 PointsTo(ptset, base, phase); | |
2120 for( VectorSetI i(&ptset); i.test(); ++i ) { | |
2121 uint pt = i.elem; | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2122 add_field_edge(pt, n_idx, address_offset(n, phase)); |
65 | 2123 } |
2124 break; | |
2125 } | |
2126 case Op_CastX2P: | |
2127 { | |
2128 assert(false, "Op_CastX2P"); | |
2129 break; | |
2130 } | |
2131 case Op_CastPP: | |
2132 case Op_CheckCastPP: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
102
diff
changeset
|
2133 case Op_EncodeP: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
102
diff
changeset
|
2134 case Op_DecodeN: |
65 | 2135 { |
2136 int ti = n->in(1)->_idx; | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2137 if (ptnode_adr(ti)->node_type() == PointsToNode::JavaObject) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2138 add_pointsto_edge(n_idx, ti); |
65 | 2139 } else { |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2140 add_deferred_edge(n_idx, ti); |
65 | 2141 } |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2142 _processed.set(n_idx); |
65 | 2143 break; |
2144 } | |
2145 case Op_ConP: | |
2146 { | |
2147 assert(false, "Op_ConP"); | |
2148 break; | |
2149 } | |
163 | 2150 case Op_ConN: |
2151 { | |
2152 assert(false, "Op_ConN"); | |
2153 break; | |
2154 } | |
65 | 2155 case Op_CreateEx: |
2156 { | |
2157 assert(false, "Op_CreateEx"); | |
2158 break; | |
2159 } | |
2160 case Op_LoadKlass: | |
164
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
2161 case Op_LoadNKlass: |
65 | 2162 { |
2163 assert(false, "Op_LoadKlass"); | |
2164 break; | |
2165 } | |
2166 case Op_LoadP: | |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
2167 case Op_LoadN: |
65 | 2168 { |
2169 const Type *t = phase->type(n); | |
2170 #ifdef ASSERT | |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
2171 if (t->make_ptr() == NULL) |
65 | 2172 assert(false, "Op_LoadP"); |
2173 #endif | |
2174 | |
2175 Node* adr = n->in(MemNode::Address)->uncast(); | |
2176 const Type *adr_type = phase->type(adr); | |
2177 Node* adr_base; | |
2178 if (adr->is_AddP()) { | |
2179 adr_base = get_addp_base(adr); | |
2180 } else { | |
2181 adr_base = adr; | |
2182 } | |
2183 | |
2184 // For everything "adr_base" could point to, create a deferred edge from | |
2185 // this node to each field with the same offset. | |
2186 VectorSet ptset(Thread::current()->resource_area()); | |
2187 PointsTo(ptset, adr_base, phase); | |
2188 int offset = address_offset(adr, phase); | |
2189 for( VectorSetI i(&ptset); i.test(); ++i ) { | |
2190 uint pt = i.elem; | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2191 add_deferred_edge_to_fields(n_idx, pt, offset); |
0 | 2192 } |
2193 break; | |
2194 } | |
2195 case Op_Parm: | |
2196 { | |
65 | 2197 assert(false, "Op_Parm"); |
0 | 2198 break; |
2199 } | |
2200 case Op_Phi: | |
2201 { | |
65 | 2202 #ifdef ASSERT |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
2203 const Type *t = n->as_Phi()->type(); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
2204 if (t->make_ptr() == NULL) |
65 | 2205 assert(false, "Op_Phi"); |
2206 #endif | |
2207 for (uint i = 1; i < n->req() ; i++) { | |
2208 Node* in = n->in(i); | |
2209 if (in == NULL) | |
2210 continue; // ignore NULL | |
2211 in = in->uncast(); | |
2212 if (in->is_top() || in == n) | |
2213 continue; // ignore top or inputs which go back this node | |
2214 int ti = in->_idx; | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2215 if (ptnode_adr(in->_idx)->node_type() == PointsToNode::JavaObject) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2216 add_pointsto_edge(n_idx, ti); |
65 | 2217 } else { |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2218 add_deferred_edge(n_idx, ti); |
65 | 2219 } |
2220 } | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2221 _processed.set(n_idx); |
0 | 2222 break; |
2223 } | |
65 | 2224 case Op_Proj: |
0 | 2225 { |
65 | 2226 // we are only interested in the result projection from a call |
2227 if (n->as_Proj()->_con == TypeFunc::Parms && n->in(0)->is_Call() ) { | |
2228 process_call_result(n->as_Proj(), phase); | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2229 assert(_processed.test(n_idx), "all call results should be processed"); |
65 | 2230 } else { |
2231 assert(false, "Op_Proj"); | |
2232 } | |
0 | 2233 break; |
2234 } | |
65 | 2235 case Op_Return: |
0 | 2236 { |
65 | 2237 #ifdef ASSERT |
2238 if( n->req() <= TypeFunc::Parms || | |
2239 !phase->type(n->in(TypeFunc::Parms))->isa_oopptr() ) { | |
2240 assert(false, "Op_Return"); | |
0 | 2241 } |
65 | 2242 #endif |
2243 int ti = n->in(TypeFunc::Parms)->_idx; | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2244 if (ptnode_adr(ti)->node_type() == PointsToNode::JavaObject) { |
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2245 add_pointsto_edge(n_idx, ti); |
65 | 2246 } else { |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2247 add_deferred_edge(n_idx, ti); |
65 | 2248 } |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2249 _processed.set(n_idx); |
0 | 2250 break; |
2251 } | |
2252 case Op_StoreP: | |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
2253 case Op_StoreN: |
0 | 2254 case Op_StorePConditional: |
2255 case Op_CompareAndSwapP: | |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
2256 case Op_CompareAndSwapN: |
0 | 2257 { |
2258 Node *adr = n->in(MemNode::Address); | |
221
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
168
diff
changeset
|
2259 const Type *adr_type = phase->type(adr)->make_ptr(); |
65 | 2260 #ifdef ASSERT |
0 | 2261 if (!adr_type->isa_oopptr()) |
65 | 2262 assert(phase->type(adr) == TypeRawPtr::NOTNULL, "Op_StoreP"); |
2263 #endif | |
0 | 2264 |
65 | 2265 assert(adr->is_AddP(), "expecting an AddP"); |
2266 Node *adr_base = get_addp_base(adr); | |
2267 Node *val = n->in(MemNode::ValueIn)->uncast(); | |
2268 // For everything "adr_base" could point to, create a deferred edge | |
2269 // to "val" from each field with the same offset. | |
0 | 2270 VectorSet ptset(Thread::current()->resource_area()); |
2271 PointsTo(ptset, adr_base, phase); | |
2272 for( VectorSetI i(&ptset); i.test(); ++i ) { | |
2273 uint pt = i.elem; | |
65 | 2274 add_edge_from_fields(pt, val->_idx, address_offset(adr, phase)); |
0 | 2275 } |
2276 break; | |
2277 } | |
65 | 2278 case Op_ThreadLocal: |
0 | 2279 { |
65 | 2280 assert(false, "Op_ThreadLocal"); |
0 | 2281 break; |
2282 } | |
2283 default: | |
2284 ; | |
2285 // nothing to do | |
2286 } | |
2287 } | |
2288 | |
2289 #ifndef PRODUCT | |
2290 void ConnectionGraph::dump() { | |
2291 PhaseGVN *igvn = _compile->initial_gvn(); | |
2292 bool first = true; | |
2293 | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2294 uint size = nodes_size(); |
65 | 2295 for (uint ni = 0; ni < size; ni++) { |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2296 PointsToNode *ptn = ptnode_adr(ni); |
65 | 2297 PointsToNode::NodeType ptn_type = ptn->node_type(); |
2298 | |
2299 if (ptn_type != PointsToNode::JavaObject || ptn->_node == NULL) | |
0 | 2300 continue; |
65 | 2301 PointsToNode::EscapeState es = escape_state(ptn->_node, igvn); |
2302 if (ptn->_node->is_Allocate() && (es == PointsToNode::NoEscape || Verbose)) { | |
2303 if (first) { | |
2304 tty->cr(); | |
2305 tty->print("======== Connection graph for "); | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2306 _compile->method()->print_short_name(); |
65 | 2307 tty->cr(); |
2308 first = false; | |
2309 } | |
2310 tty->print("%6d ", ni); | |
2311 ptn->dump(); | |
2312 // Print all locals which reference this allocation | |
2313 for (uint li = ni; li < size; li++) { | |
244
524eca34ea76
6684714: Optimize EA Connection Graph build performance
kvn
parents:
223
diff
changeset
|
2314 PointsToNode *ptn_loc = ptnode_adr(li); |
65 | 2315 PointsToNode::NodeType ptn_loc_type = ptn_loc->node_type(); |
2316 if ( ptn_loc_type == PointsToNode::LocalVar && ptn_loc->_node != NULL && | |
2317 ptn_loc->edge_count() == 1 && ptn_loc->edge_target(0) == ni ) { | |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
2318 ptnode_adr(li)->dump(false); |
0 | 2319 } |
2320 } | |
65 | 2321 if (Verbose) { |
2322 // Print all fields which reference this allocation | |
2323 for (uint i = 0; i < ptn->edge_count(); i++) { | |
2324 uint ei = ptn->edge_target(i); | |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
247
diff
changeset
|
2325 ptnode_adr(ei)->dump(false); |
65 | 2326 } |
2327 } | |
2328 tty->cr(); | |
0 | 2329 } |
2330 } | |
2331 } | |
2332 #endif |