< 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:

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

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



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