< prev index next >

src/share/vm/opto/compile.cpp

Print this page
rev 5783 : 8024069: replace_in_map() should operate on parent maps
Summary: type information gets lost because replace_in_map() doesn't update parent maps
Reviewed-by: kvn, twisti
rev 5784 : 8026796: Make replace_in_map() on parent maps generic
Summary: propagate node replacements along control flow edges to callers
Reviewed-by: kvn, vlivanov


 382 void Compile::remove_useless_late_inlines(GrowableArray<CallGenerator*>* inlines, Unique_Node_List &useful) {
 383   int shift = 0;
 384   for (int i = 0; i < inlines->length(); i++) {
 385     CallGenerator* cg = inlines->at(i);
 386     CallNode* call = cg->call_node();
 387     if (shift > 0) {
 388       inlines->at_put(i-shift, cg);
 389     }
 390     if (!useful.member(call)) {
 391       shift++;
 392     }
 393   }
 394   inlines->trunc_to(inlines->length()-shift);
 395 }
 396 
 397 // Disconnect all useless nodes by disconnecting those at the boundary.
 398 void Compile::remove_useless_nodes(Unique_Node_List &useful) {
 399   uint next = 0;
 400   while (next < useful.size()) {
 401     Node *n = useful.at(next++);





 402     // Use raw traversal of out edges since this code removes out edges
 403     int max = n->outcnt();
 404     for (int j = 0; j < max; ++j) {
 405       Node* child = n->raw_out(j);
 406       if (! useful.member(child)) {
 407         assert(!child->is_top() || child != top(),
 408                "If top is cached in Compile object it is in useful list");
 409         // Only need to remove this out-edge to the useless node
 410         n->raw_del_out(j);
 411         --j;
 412         --max;
 413       }
 414     }
 415     if (n->outcnt() == 1 && n->has_special_unique_user()) {
 416       record_for_igvn(n->unique_out());
 417     }
 418   }
 419   // Remove useless macro and predicate opaq nodes
 420   for (int i = C->macro_count()-1; i >= 0; i--) {
 421     Node* n = C->macro_node(i);


1878     ResourceMark rm;
1879     PhaseRemoveUseless pru(C->initial_gvn(), C->for_igvn());
1880   }
1881 
1882   igvn = PhaseIterGVN(gvn);
1883 }
1884 
1885 // Perform incremental inlining until bound on number of live nodes is reached
1886 void Compile::inline_incrementally(PhaseIterGVN& igvn) {
1887   PhaseGVN* gvn = initial_gvn();
1888 
1889   set_inlining_incrementally(true);
1890   set_inlining_progress(true);
1891   uint low_live_nodes = 0;
1892 
1893   while(inlining_progress() && _late_inlines.length() > 0) {
1894 
1895     if (live_nodes() > (uint)LiveNodeCountInliningCutoff) {
1896       if (low_live_nodes < (uint)LiveNodeCountInliningCutoff * 8 / 10) {
1897         // PhaseIdealLoop is expensive so we only try it once we are
1898         // out of loop and we only try it again if the previous helped
1899         // got the number of nodes down significantly
1900         PhaseIdealLoop ideal_loop( igvn, false, true );
1901         if (failing())  return;
1902         low_live_nodes = live_nodes();
1903         _major_progress = true;
1904       }
1905 
1906       if (live_nodes() > (uint)LiveNodeCountInliningCutoff) {
1907         break;
1908       }
1909     }
1910 
1911     inline_incrementally_one(igvn);
1912 
1913     if (failing())  return;
1914 
1915     igvn.optimize();
1916 
1917     if (failing())  return;
1918   }
1919 




 382 void Compile::remove_useless_late_inlines(GrowableArray<CallGenerator*>* inlines, Unique_Node_List &useful) {
 383   int shift = 0;
 384   for (int i = 0; i < inlines->length(); i++) {
 385     CallGenerator* cg = inlines->at(i);
 386     CallNode* call = cg->call_node();
 387     if (shift > 0) {
 388       inlines->at_put(i-shift, cg);
 389     }
 390     if (!useful.member(call)) {
 391       shift++;
 392     }
 393   }
 394   inlines->trunc_to(inlines->length()-shift);
 395 }
 396 
 397 // Disconnect all useless nodes by disconnecting those at the boundary.
 398 void Compile::remove_useless_nodes(Unique_Node_List &useful) {
 399   uint next = 0;
 400   while (next < useful.size()) {
 401     Node *n = useful.at(next++);
 402     if (n->is_SafePoint()) {
 403       // We're done with a parsing phase. Replaced nodes are not valid
 404       // beyond that point.
 405       n->as_SafePoint()->delete_replaced_nodes();
 406     }
 407     // Use raw traversal of out edges since this code removes out edges
 408     int max = n->outcnt();
 409     for (int j = 0; j < max; ++j) {
 410       Node* child = n->raw_out(j);
 411       if (! useful.member(child)) {
 412         assert(!child->is_top() || child != top(),
 413                "If top is cached in Compile object it is in useful list");
 414         // Only need to remove this out-edge to the useless node
 415         n->raw_del_out(j);
 416         --j;
 417         --max;
 418       }
 419     }
 420     if (n->outcnt() == 1 && n->has_special_unique_user()) {
 421       record_for_igvn(n->unique_out());
 422     }
 423   }
 424   // Remove useless macro and predicate opaq nodes
 425   for (int i = C->macro_count()-1; i >= 0; i--) {
 426     Node* n = C->macro_node(i);


1883     ResourceMark rm;
1884     PhaseRemoveUseless pru(C->initial_gvn(), C->for_igvn());
1885   }
1886 
1887   igvn = PhaseIterGVN(gvn);
1888 }
1889 
1890 // Perform incremental inlining until bound on number of live nodes is reached
1891 void Compile::inline_incrementally(PhaseIterGVN& igvn) {
1892   PhaseGVN* gvn = initial_gvn();
1893 
1894   set_inlining_incrementally(true);
1895   set_inlining_progress(true);
1896   uint low_live_nodes = 0;
1897 
1898   while(inlining_progress() && _late_inlines.length() > 0) {
1899 
1900     if (live_nodes() > (uint)LiveNodeCountInliningCutoff) {
1901       if (low_live_nodes < (uint)LiveNodeCountInliningCutoff * 8 / 10) {
1902         // PhaseIdealLoop is expensive so we only try it once we are
1903         // out of live nodes and we only try it again if the previous
1904         // helped got the number of nodes down significantly
1905         PhaseIdealLoop ideal_loop( igvn, false, true );
1906         if (failing())  return;
1907         low_live_nodes = live_nodes();
1908         _major_progress = true;
1909       }
1910 
1911       if (live_nodes() > (uint)LiveNodeCountInliningCutoff) {
1912         break;
1913       }
1914     }
1915 
1916     inline_incrementally_one(igvn);
1917 
1918     if (failing())  return;
1919 
1920     igvn.optimize();
1921 
1922     if (failing())  return;
1923   }
1924 


< prev index next >