344 } |
344 } |
345 |
345 |
346 // Disconnect all useless nodes by disconnecting those at the boundary. |
346 // Disconnect all useless nodes by disconnecting those at the boundary. |
347 void Compile::remove_useless_nodes(Unique_Node_List &useful) { |
347 void Compile::remove_useless_nodes(Unique_Node_List &useful) { |
348 uint next = 0; |
348 uint next = 0; |
349 while( next < useful.size() ) { |
349 while (next < useful.size()) { |
350 Node *n = useful.at(next++); |
350 Node *n = useful.at(next++); |
351 // Use raw traversal of out edges since this code removes out edges |
351 // Use raw traversal of out edges since this code removes out edges |
352 int max = n->outcnt(); |
352 int max = n->outcnt(); |
353 for (int j = 0; j < max; ++j ) { |
353 for (int j = 0; j < max; ++j) { |
354 Node* child = n->raw_out(j); |
354 Node* child = n->raw_out(j); |
355 if( ! useful.member(child) ) { |
355 if (! useful.member(child)) { |
356 assert( !child->is_top() || child != top(), |
356 assert(!child->is_top() || child != top(), |
357 "If top is cached in Compile object it is in useful list"); |
357 "If top is cached in Compile object it is in useful list"); |
358 // Only need to remove this out-edge to the useless node |
358 // Only need to remove this out-edge to the useless node |
359 n->raw_del_out(j); |
359 n->raw_del_out(j); |
360 --j; |
360 --j; |
361 --max; |
361 --max; |
362 } |
362 } |
363 } |
363 } |
364 if (n->outcnt() == 1 && n->has_special_unique_user()) { |
364 if (n->outcnt() == 1 && n->has_special_unique_user()) { |
365 record_for_igvn( n->unique_out() ); |
365 record_for_igvn(n->unique_out()); |
|
366 } |
|
367 } |
|
368 // Remove useless macro and predicate opaq nodes |
|
369 for (int i = C->macro_count()-1; i >= 0; i--) { |
|
370 Node* n = C->macro_node(i); |
|
371 if (!useful.member(n)) { |
|
372 remove_macro_node(n); |
366 } |
373 } |
367 } |
374 } |
368 debug_only(verify_graph_edges(true/*check for no_dead_code*/);) |
375 debug_only(verify_graph_edges(true/*check for no_dead_code*/);) |
369 } |
376 } |
370 |
377 |
717 |
724 |
718 // now inline anything that we skipped the first time around |
725 // now inline anything that we skipped the first time around |
719 while (_late_inlines.length() > 0) { |
726 while (_late_inlines.length() > 0) { |
720 CallGenerator* cg = _late_inlines.pop(); |
727 CallGenerator* cg = _late_inlines.pop(); |
721 cg->do_late_inline(); |
728 cg->do_late_inline(); |
|
729 if (failing()) return; |
722 } |
730 } |
723 } |
731 } |
724 assert(_late_inlines.length() == 0, "should have been processed"); |
732 assert(_late_inlines.length() == 0, "should have been processed"); |
725 |
733 |
726 print_method("Before RemoveUseless", 3); |
734 print_method("Before RemoveUseless", 3); |
1689 |
1697 |
1690 if (failing()) return; |
1698 if (failing()) return; |
1691 |
1699 |
1692 // Perform escape analysis |
1700 // Perform escape analysis |
1693 if (_do_escape_analysis && ConnectionGraph::has_candidates(this)) { |
1701 if (_do_escape_analysis && ConnectionGraph::has_candidates(this)) { |
|
1702 if (has_loops()) { |
|
1703 // Cleanup graph (remove dead nodes). |
|
1704 TracePhase t2("idealLoop", &_t_idealLoop, true); |
|
1705 PhaseIdealLoop ideal_loop( igvn, false, true ); |
|
1706 if (major_progress()) print_method("PhaseIdealLoop before EA", 2); |
|
1707 if (failing()) return; |
|
1708 } |
1694 TracePhase t2("escapeAnalysis", &_t_escapeAnalysis, true); |
1709 TracePhase t2("escapeAnalysis", &_t_escapeAnalysis, true); |
1695 ConnectionGraph::do_analysis(this, &igvn); |
1710 ConnectionGraph::do_analysis(this, &igvn); |
1696 |
1711 |
1697 if (failing()) return; |
1712 if (failing()) return; |
1698 |
1713 |
1699 igvn.optimize(); |
1714 igvn.optimize(); |
1700 print_method("Iter GVN 3", 2); |
1715 print_method("Iter GVN after EA", 2); |
1701 |
1716 |
1702 if (failing()) return; |
1717 if (failing()) return; |
1703 |
1718 |
1704 } |
1719 } |
1705 |
1720 |