src/share/vm/opto/escape.cpp

changeset 537
f96100ac3d12
parent 512
36cd3cc4d27b
parent 536
a6cb86dd209b
child 548
ba764ed4b6f2
equal deleted inserted replaced
518:d3cd40645d0d 537:f96100ac3d12
254 } 254 }
255 } 255 }
256 } 256 }
257 } 257 }
258 258
259 void ConnectionGraph::remove_deferred(uint ni) { 259 void ConnectionGraph::remove_deferred(uint ni, GrowableArray<uint>* deferred_edges, VectorSet* visited) {
260 VectorSet visited(Thread::current()->resource_area()); 260 // This method is most expensive during ConnectionGraph construction.
261 // Reuse vectorSet and an additional growable array for deferred edges.
262 deferred_edges->clear();
263 visited->Clear();
261 264
262 uint i = 0; 265 uint i = 0;
263 PointsToNode *ptn = ptnode_adr(ni); 266 PointsToNode *ptn = ptnode_adr(ni);
264 267
265 while(i < ptn->edge_count()) { 268 // Mark current edges as visited and move deferred edges to separate array.
269 for (; i < ptn->edge_count(); i++) {
266 uint t = ptn->edge_target(i); 270 uint t = ptn->edge_target(i);
271 #ifdef ASSERT
272 assert(!visited->test_set(t), "expecting no duplications");
273 #else
274 visited->set(t);
275 #endif
276 if (ptn->edge_type(i) == PointsToNode::DeferredEdge) {
277 ptn->remove_edge(t, PointsToNode::DeferredEdge);
278 deferred_edges->append(t);
279 }
280 }
281 for (int next = 0; next < deferred_edges->length(); ++next) {
282 uint t = deferred_edges->at(next);
267 PointsToNode *ptt = ptnode_adr(t); 283 PointsToNode *ptt = ptnode_adr(t);
268 if (ptn->edge_type(i) != PointsToNode::DeferredEdge) { 284 for (uint j = 0; j < ptt->edge_count(); j++) {
269 i++; 285 uint n1 = ptt->edge_target(j);
270 } else { 286 if (visited->test_set(n1))
271 ptn->remove_edge(t, PointsToNode::DeferredEdge); 287 continue;
272 if(!visited.test_set(t)) { 288 switch(ptt->edge_type(j)) {
273 for (uint j = 0; j < ptt->edge_count(); j++) { 289 case PointsToNode::PointsToEdge:
274 uint n1 = ptt->edge_target(j); 290 add_pointsto_edge(ni, n1);
275 PointsToNode *pt1 = ptnode_adr(n1); 291 if(n1 == _phantom_object) {
276 switch(ptt->edge_type(j)) { 292 // Special case - field set outside (globally escaping).
277 case PointsToNode::PointsToEdge: 293 ptn->set_escape_state(PointsToNode::GlobalEscape);
278 add_pointsto_edge(ni, n1);
279 if(n1 == _phantom_object) {
280 // Special case - field set outside (globally escaping).
281 ptn->set_escape_state(PointsToNode::GlobalEscape);
282 }
283 break;
284 case PointsToNode::DeferredEdge:
285 add_deferred_edge(ni, n1);
286 break;
287 case PointsToNode::FieldEdge:
288 assert(false, "invalid connection graph");
289 break;
290 } 294 }
291 } 295 break;
296 case PointsToNode::DeferredEdge:
297 deferred_edges->append(n1);
298 break;
299 case PointsToNode::FieldEdge:
300 assert(false, "invalid connection graph");
301 break;
292 } 302 }
293 } 303 }
294 } 304 }
295 } 305 }
296 306
1241 cg_worklist.append(n->_idx); // Collect CG nodes 1251 cg_worklist.append(n->_idx); // Collect CG nodes
1242 } 1252 }
1243 } 1253 }
1244 1254
1245 VectorSet ptset(Thread::current()->resource_area()); 1255 VectorSet ptset(Thread::current()->resource_area());
1246 GrowableArray<Node*> alloc_worklist; 1256 GrowableArray<Node*> alloc_worklist;
1247 GrowableArray<int> worklist; 1257 GrowableArray<int> worklist;
1258 GrowableArray<uint> deferred_edges;
1259 VectorSet visited(Thread::current()->resource_area());
1248 1260
1249 // remove deferred edges from the graph and collect 1261 // remove deferred edges from the graph and collect
1250 // information we will need for type splitting 1262 // information we will need for type splitting
1251 for( int next = 0; next < cg_worklist.length(); ++next ) { 1263 for( int next = 0; next < cg_worklist.length(); ++next ) {
1252 int ni = cg_worklist.at(next); 1264 int ni = cg_worklist.at(next);
1253 PointsToNode* ptn = _nodes->adr_at(ni); 1265 PointsToNode* ptn = _nodes->adr_at(ni);
1254 PointsToNode::NodeType nt = ptn->node_type(); 1266 PointsToNode::NodeType nt = ptn->node_type();
1255 Node *n = ptn->_node; 1267 Node *n = ptn->_node;
1256 if (nt == PointsToNode::LocalVar || nt == PointsToNode::Field) { 1268 if (nt == PointsToNode::LocalVar || nt == PointsToNode::Field) {
1257 remove_deferred(ni); 1269 remove_deferred(ni, &deferred_edges, &visited);
1258 if (n->is_AddP()) { 1270 if (n->is_AddP()) {
1259 // If this AddP computes an address which may point to more that one 1271 // If this AddP computes an address which may point to more that one
1260 // object, nothing the address points to can be scalar replaceable. 1272 // object, nothing the address points to can be scalar replaceable.
1261 Node *base = get_addp_base(n); 1273 Node *base = get_addp_base(n);
1262 ptset.Clear(); 1274 ptset.Clear();

mercurial