< prev index next >

src/hotspot/share/opto/compile.cpp

Print this page

 401   }
 402   if (dead->is_ParsePredicate()) {
 403     remove_parse_predicate(dead->as_ParsePredicate());
 404   }
 405   if (dead->for_post_loop_opts_igvn()) {
 406     remove_from_post_loop_opts_igvn(dead);
 407   }
 408   if (dead->for_merge_stores_igvn()) {
 409     remove_from_merge_stores_igvn(dead);
 410   }
 411   if (dead->is_Call()) {
 412     remove_useless_late_inlines(                &_late_inlines, dead);
 413     remove_useless_late_inlines(         &_string_late_inlines, dead);
 414     remove_useless_late_inlines(         &_boxing_late_inlines, dead);
 415     remove_useless_late_inlines(&_vector_reboxing_late_inlines, dead);
 416 
 417     if (dead->is_CallStaticJava()) {
 418       remove_unstable_if_trap(dead->as_CallStaticJava(), false);
 419     }
 420   }
 421   BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
 422   bs->unregister_potential_barrier_node(dead);
 423 }
 424 
 425 // Disconnect all useless nodes by disconnecting those at the boundary.
 426 void Compile::disconnect_useless_nodes(Unique_Node_List& useful, Unique_Node_List& worklist, const Unique_Node_List* root_and_safepoints) {
 427   uint next = 0;
 428   while (next < useful.size()) {
 429     Node *n = useful.at(next++);
 430     if (n->is_SafePoint()) {
 431       // We're done with a parsing phase. Replaced nodes are not valid
 432       // beyond that point.
 433       n->as_SafePoint()->delete_replaced_nodes();
 434     }
 435     // Use raw traversal of out edges since this code removes out edges
 436     int max = n->outcnt();
 437     for (int j = 0; j < max; ++j) {
 438       Node* child = n->raw_out(j);
 439       if (!useful.member(child)) {
 440         assert(!child->is_top() || child != top(),
 441                "If top is cached in Compile object it is in useful list");
 442         // Only need to remove this out-edge to the useless node

 452       assert(useful.member(n->unique_out()), "do not push a useless node");
 453       worklist.push(n->unique_out());
 454     }
 455   }
 456 
 457   remove_useless_nodes(_macro_nodes,        useful); // remove useless macro nodes
 458   remove_useless_nodes(_parse_predicates,   useful); // remove useless Parse Predicate nodes
 459   // Remove useless Template Assertion Predicate opaque nodes
 460   remove_useless_nodes(_template_assertion_predicate_opaques, useful);
 461   remove_useless_nodes(_expensive_nodes,    useful); // remove useless expensive nodes
 462   remove_useless_nodes(_for_post_loop_igvn, useful); // remove useless node recorded for post loop opts IGVN pass
 463   remove_useless_nodes(_for_merge_stores_igvn, useful); // remove useless node recorded for merge stores IGVN pass
 464   remove_useless_unstable_if_traps(useful);          // remove useless unstable_if traps
 465   remove_useless_coarsened_locks(useful);            // remove useless coarsened locks nodes
 466 #ifdef ASSERT
 467   if (_modified_nodes != nullptr) {
 468     _modified_nodes->remove_useless_nodes(useful.member_set());
 469   }
 470 #endif
 471 
 472   BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
 473   bs->eliminate_useless_gc_barriers(useful, this);
 474   // clean up the late inline lists
 475   remove_useless_late_inlines(                &_late_inlines, useful);
 476   remove_useless_late_inlines(         &_string_late_inlines, useful);
 477   remove_useless_late_inlines(         &_boxing_late_inlines, useful);
 478   remove_useless_late_inlines(&_vector_reboxing_late_inlines, useful);
 479   DEBUG_ONLY(verify_graph_edges(true /*check for no_dead_code*/, root_and_safepoints);)
 480 }
 481 
 482 // ============================================================================
 483 //------------------------------CompileWrapper---------------------------------
 484 class CompileWrapper : public StackObj {
 485   Compile *const _compile;
 486  public:
 487   CompileWrapper(Compile* compile);
 488 
 489   ~CompileWrapper();
 490 };
 491 
 492 CompileWrapper::CompileWrapper(Compile* compile) : _compile(compile) {
 493   // the Compile* pointer is stored in the current ciEnv:

3201       break;
3202     }
3203     default:
3204       break;
3205     }
3206   }
3207 
3208 #ifdef ASSERT
3209   if( n->is_Mem() ) {
3210     int alias_idx = get_alias_index(n->as_Mem()->adr_type());
3211     assert( n->in(0) != nullptr || alias_idx != Compile::AliasIdxRaw ||
3212             // oop will be recorded in oop map if load crosses safepoint
3213             (n->is_Load() && (n->as_Load()->bottom_type()->isa_oopptr() ||
3214                               LoadNode::is_immutable_value(n->in(MemNode::Address)))),
3215             "raw memory operations should have control edge");
3216   }
3217   if (n->is_MemBar()) {
3218     MemBarNode* mb = n->as_MemBar();
3219     if (mb->trailing_store() || mb->trailing_load_store()) {
3220       assert(mb->leading_membar()->trailing_membar() == mb, "bad membar pair");
3221       Node* mem = BarrierSet::barrier_set()->barrier_set_c2()->step_over_gc_barrier(mb->in(MemBarNode::Precedent));
3222       assert((mb->trailing_store() && mem->is_Store() && mem->as_Store()->is_release()) ||
3223              (mb->trailing_load_store() && mem->is_LoadStore()), "missing mem op");
3224     } else if (mb->leading()) {
3225       assert(mb->trailing_membar()->leading_membar() == mb, "bad membar pair");
3226     }
3227   }
3228 #endif
3229   // Count FPU ops and common calls, implements item (3)
3230   bool gc_handled = BarrierSet::barrier_set()->barrier_set_c2()->final_graph_reshaping(this, n, nop, dead_nodes);
3231   if (!gc_handled) {
3232     final_graph_reshaping_main_switch(n, frc, nop, dead_nodes);
3233   }
3234 
3235   // Collect CFG split points
3236   if (n->is_MultiBranch() && !n->is_RangeCheck()) {
3237     frc._tests.push(n);
3238   }
3239 }
3240 
3241 void Compile::handle_div_mod_op(Node* n, BasicType bt, bool is_unsigned) {
3242   if (!UseDivMod) {
3243     return;
3244   }
3245 
3246   // Check if "a % b" and "a / b" both exist
3247   Node* d = n->find_similar(Op_DivIL(bt, is_unsigned));
3248   if (d == nullptr) {
3249     return;
3250   }
3251 
3252   // Replace them with a fused divmod if supported
3253   if (Matcher::has_match_rule(Op_DivModIL(bt, is_unsigned))) {

 401   }
 402   if (dead->is_ParsePredicate()) {
 403     remove_parse_predicate(dead->as_ParsePredicate());
 404   }
 405   if (dead->for_post_loop_opts_igvn()) {
 406     remove_from_post_loop_opts_igvn(dead);
 407   }
 408   if (dead->for_merge_stores_igvn()) {
 409     remove_from_merge_stores_igvn(dead);
 410   }
 411   if (dead->is_Call()) {
 412     remove_useless_late_inlines(                &_late_inlines, dead);
 413     remove_useless_late_inlines(         &_string_late_inlines, dead);
 414     remove_useless_late_inlines(         &_boxing_late_inlines, dead);
 415     remove_useless_late_inlines(&_vector_reboxing_late_inlines, dead);
 416 
 417     if (dead->is_CallStaticJava()) {
 418       remove_unstable_if_trap(dead->as_CallStaticJava(), false);
 419     }
 420   }


 421 }
 422 
 423 // Disconnect all useless nodes by disconnecting those at the boundary.
 424 void Compile::disconnect_useless_nodes(Unique_Node_List& useful, Unique_Node_List& worklist, const Unique_Node_List* root_and_safepoints) {
 425   uint next = 0;
 426   while (next < useful.size()) {
 427     Node *n = useful.at(next++);
 428     if (n->is_SafePoint()) {
 429       // We're done with a parsing phase. Replaced nodes are not valid
 430       // beyond that point.
 431       n->as_SafePoint()->delete_replaced_nodes();
 432     }
 433     // Use raw traversal of out edges since this code removes out edges
 434     int max = n->outcnt();
 435     for (int j = 0; j < max; ++j) {
 436       Node* child = n->raw_out(j);
 437       if (!useful.member(child)) {
 438         assert(!child->is_top() || child != top(),
 439                "If top is cached in Compile object it is in useful list");
 440         // Only need to remove this out-edge to the useless node

 450       assert(useful.member(n->unique_out()), "do not push a useless node");
 451       worklist.push(n->unique_out());
 452     }
 453   }
 454 
 455   remove_useless_nodes(_macro_nodes,        useful); // remove useless macro nodes
 456   remove_useless_nodes(_parse_predicates,   useful); // remove useless Parse Predicate nodes
 457   // Remove useless Template Assertion Predicate opaque nodes
 458   remove_useless_nodes(_template_assertion_predicate_opaques, useful);
 459   remove_useless_nodes(_expensive_nodes,    useful); // remove useless expensive nodes
 460   remove_useless_nodes(_for_post_loop_igvn, useful); // remove useless node recorded for post loop opts IGVN pass
 461   remove_useless_nodes(_for_merge_stores_igvn, useful); // remove useless node recorded for merge stores IGVN pass
 462   remove_useless_unstable_if_traps(useful);          // remove useless unstable_if traps
 463   remove_useless_coarsened_locks(useful);            // remove useless coarsened locks nodes
 464 #ifdef ASSERT
 465   if (_modified_nodes != nullptr) {
 466     _modified_nodes->remove_useless_nodes(useful.member_set());
 467   }
 468 #endif
 469 


 470   // clean up the late inline lists
 471   remove_useless_late_inlines(                &_late_inlines, useful);
 472   remove_useless_late_inlines(         &_string_late_inlines, useful);
 473   remove_useless_late_inlines(         &_boxing_late_inlines, useful);
 474   remove_useless_late_inlines(&_vector_reboxing_late_inlines, useful);
 475   DEBUG_ONLY(verify_graph_edges(true /*check for no_dead_code*/, root_and_safepoints);)
 476 }
 477 
 478 // ============================================================================
 479 //------------------------------CompileWrapper---------------------------------
 480 class CompileWrapper : public StackObj {
 481   Compile *const _compile;
 482  public:
 483   CompileWrapper(Compile* compile);
 484 
 485   ~CompileWrapper();
 486 };
 487 
 488 CompileWrapper::CompileWrapper(Compile* compile) : _compile(compile) {
 489   // the Compile* pointer is stored in the current ciEnv:

3197       break;
3198     }
3199     default:
3200       break;
3201     }
3202   }
3203 
3204 #ifdef ASSERT
3205   if( n->is_Mem() ) {
3206     int alias_idx = get_alias_index(n->as_Mem()->adr_type());
3207     assert( n->in(0) != nullptr || alias_idx != Compile::AliasIdxRaw ||
3208             // oop will be recorded in oop map if load crosses safepoint
3209             (n->is_Load() && (n->as_Load()->bottom_type()->isa_oopptr() ||
3210                               LoadNode::is_immutable_value(n->in(MemNode::Address)))),
3211             "raw memory operations should have control edge");
3212   }
3213   if (n->is_MemBar()) {
3214     MemBarNode* mb = n->as_MemBar();
3215     if (mb->trailing_store() || mb->trailing_load_store()) {
3216       assert(mb->leading_membar()->trailing_membar() == mb, "bad membar pair");
3217       Node* mem = mb->in(MemBarNode::Precedent);
3218       assert((mb->trailing_store() && mem->is_Store() && mem->as_Store()->is_release()) ||
3219              (mb->trailing_load_store() && mem->is_LoadStore()), "missing mem op");
3220     } else if (mb->leading()) {
3221       assert(mb->trailing_membar()->leading_membar() == mb, "bad membar pair");
3222     }
3223   }
3224 #endif
3225   // Count FPU ops and common calls, implements item (3)
3226   final_graph_reshaping_main_switch(n, frc, nop, dead_nodes);



3227 
3228   // Collect CFG split points
3229   if (n->is_MultiBranch() && !n->is_RangeCheck()) {
3230     frc._tests.push(n);
3231   }
3232 }
3233 
3234 void Compile::handle_div_mod_op(Node* n, BasicType bt, bool is_unsigned) {
3235   if (!UseDivMod) {
3236     return;
3237   }
3238 
3239   // Check if "a % b" and "a / b" both exist
3240   Node* d = n->find_similar(Op_DivIL(bt, is_unsigned));
3241   if (d == nullptr) {
3242     return;
3243   }
3244 
3245   // Replace them with a fused divmod if supported
3246   if (Matcher::has_match_rule(Op_DivModIL(bt, is_unsigned))) {
< prev index next >