< prev index next >

src/hotspot/share/opto/lcm.cpp

Print this page

 259       const Node* base = mach->get_base_and_disp(offset, adr_type);
 260       if (base == nullptr || base == NodeSentinel) {
 261         // Narrow oop address doesn't have base, only index.
 262         // Give up if offset is beyond page size or if heap base is not protected.
 263         if (val->bottom_type()->isa_narrowoop() &&
 264             (MacroAssembler::needs_explicit_null_check(offset) ||
 265              !CompressedOops::use_implicit_null_checks()))
 266           continue;
 267         // cannot reason about it; is probably not implicit null exception
 268       } else {
 269         const TypePtr* tptr;
 270         if ((UseCompressedOops || UseCompressedClassPointers) &&
 271             (CompressedOops::shift() == 0 || CompressedKlassPointers::shift() == 0)) {
 272           // 32-bits narrow oop can be the base of address expressions
 273           tptr = base->get_ptr_type();
 274         } else {
 275           // only regular oops are expected here
 276           tptr = base->bottom_type()->is_ptr();
 277         }
 278         // Give up if offset is not a compile-time constant.
 279         if (offset == Type::OffsetBot || tptr->_offset == Type::OffsetBot)
 280           continue;
 281         offset += tptr->_offset; // correct if base is offsetted
 282         // Give up if reference is beyond page size.
 283         if (MacroAssembler::needs_explicit_null_check(offset))
 284           continue;
 285         // Give up if base is a decode node and the heap base is not protected.
 286         if (base->is_Mach() && base->as_Mach()->ideal_Opcode() == Op_DecodeN &&
 287             !CompressedOops::use_implicit_null_checks())
 288           continue;
 289       }
 290     }
 291 
 292     // Check ctrl input to see if the null-check dominates the memory op
 293     Block *cb = get_block_for_node(mach);
 294     cb = cb->_idom;             // Always hoist at least 1 block
 295     if( !was_store ) {          // Stores can be hoisted only one block
 296       while( cb->_dom_depth > (block->_dom_depth + 1))
 297         cb = cb->_idom;         // Hoist loads as far as we want
 298       // The non-null-block should dominate the memory op, too. Live
 299       // range spilling will insert a spill in the non-null-block if it is
 300       // needs to spill the memory op for an implicit null check.
 301       if (cb->_dom_depth == (block->_dom_depth + 1)) {
 302         if (cb != not_null_block) continue;
 303         cb = cb->_idom;
 304       }
 305     }
 306     if( cb != block ) continue;
 307 
 308     // Found a memory user; see if it can be hoisted to check-block
 309     uint vidx = 0;              // Capture index of value into memop
 310     uint j;
 311     for( j = mach->req()-1; j > 0; j-- ) {
 312       if( mach->in(j) == val ) {
 313         vidx = j;
 314         // Ignore DecodeN val which could be hoisted to where needed.
 315         if( is_decoden ) continue;
 316       }
 317       // Block of memory-op input
 318       Block *inb = get_block_for_node(mach->in(j));




 319       Block *b = block;          // Start from nul check
 320       while( b != inb && b->_dom_depth > inb->_dom_depth )
 321         b = b->_idom;           // search upwards for input
 322       // See if input dominates null check
 323       if( b != inb )
 324         break;
 325     }
 326     if( j > 0 )
 327       continue;
 328     Block *mb = get_block_for_node(mach);
 329     // Hoisting stores requires more checks for the anti-dependence case.
 330     // Give up hoisting if we have to move the store past any load.
 331     if (was_store) {
 332        // Make sure control does not do a merge (would have to check allpaths)
 333        if (mb->num_preds() != 2) {
 334          continue;
 335        }
 336        // mach is a store, hence block is the immediate dominator of mb.
 337        // Due to the null-check shape of block (where its successors cannot re-join),
 338        // block must be the direct predecessor of mb.

 391           tempb->find_remove(temp);
 392           block->add_inst(temp);
 393           map_node_to_block(temp, block);
 394         }
 395       }
 396       valb->find_remove(val);
 397       block->add_inst(val);
 398       map_node_to_block(val, block);
 399       // DecodeN on x86 may kill flags. Check for flag-killing projections
 400       // that also need to be hoisted.
 401       for (DUIterator_Fast jmax, j = val->fast_outs(jmax); j < jmax; j++) {
 402         Node* n = val->fast_out(j);
 403         if( n->is_MachProj() ) {
 404           get_block_for_node(n)->find_remove(n);
 405           block->add_inst(n);
 406           map_node_to_block(n, block);
 407         }
 408       }
 409     }
 410   }





















 411   // Hoist the memory candidate up to the end of the test block.
 412   Block *old_block = get_block_for_node(best);
 413   old_block->find_remove(best);
 414   block->add_inst(best);
 415   map_node_to_block(best, block);
 416 
 417   // Move the control dependence if it is pinned to not-null block.
 418   // Don't change it in other cases: null or dominating control.
 419   Node* ctrl = best->in(0);
 420   if (ctrl != nullptr && get_block_for_node(ctrl) == not_null_block) {
 421     // Set it to control edge of null check.
 422     best->set_req(0, proj->in(0)->in(0));
 423   }
 424 
 425   // Check for flag-killing projections that also need to be hoisted
 426   // Should be DU safe because no edge updates.
 427   for (DUIterator_Fast jmax, j = best->fast_outs(jmax); j < jmax; j++) {
 428     Node* n = best->fast_out(j);
 429     if( n->is_MachProj() ) {
 430       get_block_for_node(n)->find_remove(n);

 862     // Children of projections are now all ready
 863     for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) {
 864       Node* m = n->fast_out(j); // Get user
 865       if(get_block_for_node(m) != block) {
 866         continue;
 867       }
 868       if( m->is_Phi() ) continue;
 869       int m_cnt = ready_cnt.at(m->_idx) - 1;
 870       ready_cnt.at_put(m->_idx, m_cnt);
 871       if( m_cnt == 0 )
 872         worklist.push(m);
 873     }
 874 
 875   }
 876 
 877   // Act as if the call defines the Frame Pointer.
 878   // Certainly the FP is alive and well after the call.
 879   regs.Insert(_matcher.c_frame_pointer());
 880 
 881   // Set all registers killed and not already defined by the call.
 882   uint r_cnt = mcall->tf()->range()->cnt();
 883   int op = mcall->ideal_Opcode();
 884   MachProjNode *proj = new MachProjNode( mcall, r_cnt+1, RegMask::Empty, MachProjNode::fat_proj );
 885   map_node_to_block(proj, block);
 886   block->insert_node(proj, node_cnt++);
 887 
 888   // Select the right register save policy.
 889   const char *save_policy = nullptr;
 890   switch (op) {
 891     case Op_CallRuntime:
 892     case Op_CallLeaf:
 893     case Op_CallLeafNoFP:
 894     case Op_CallLeafVector:
 895       // Calling C code so use C calling convention
 896       save_policy = _matcher._c_reg_save_policy;
 897       break;
 898 
 899     case Op_CallStaticJava:
 900     case Op_CallDynamicJava:
 901       // Calling Java code so use Java calling convention
 902       save_policy = _matcher._register_save_policy;

 259       const Node* base = mach->get_base_and_disp(offset, adr_type);
 260       if (base == nullptr || base == NodeSentinel) {
 261         // Narrow oop address doesn't have base, only index.
 262         // Give up if offset is beyond page size or if heap base is not protected.
 263         if (val->bottom_type()->isa_narrowoop() &&
 264             (MacroAssembler::needs_explicit_null_check(offset) ||
 265              !CompressedOops::use_implicit_null_checks()))
 266           continue;
 267         // cannot reason about it; is probably not implicit null exception
 268       } else {
 269         const TypePtr* tptr;
 270         if ((UseCompressedOops || UseCompressedClassPointers) &&
 271             (CompressedOops::shift() == 0 || CompressedKlassPointers::shift() == 0)) {
 272           // 32-bits narrow oop can be the base of address expressions
 273           tptr = base->get_ptr_type();
 274         } else {
 275           // only regular oops are expected here
 276           tptr = base->bottom_type()->is_ptr();
 277         }
 278         // Give up if offset is not a compile-time constant.
 279         if (offset == Type::OffsetBot || tptr->offset() == Type::OffsetBot)
 280           continue;
 281         offset += tptr->offset(); // correct if base is offsetted
 282         // Give up if reference is beyond page size.
 283         if (MacroAssembler::needs_explicit_null_check(offset))
 284           continue;
 285         // Give up if base is a decode node and the heap base is not protected.
 286         if (base->is_Mach() && base->as_Mach()->ideal_Opcode() == Op_DecodeN &&
 287             !CompressedOops::use_implicit_null_checks())
 288           continue;
 289       }
 290     }
 291 
 292     // Check ctrl input to see if the null-check dominates the memory op
 293     Block *cb = get_block_for_node(mach);
 294     cb = cb->_idom;             // Always hoist at least 1 block
 295     if( !was_store ) {          // Stores can be hoisted only one block
 296       while( cb->_dom_depth > (block->_dom_depth + 1))
 297         cb = cb->_idom;         // Hoist loads as far as we want
 298       // The non-null-block should dominate the memory op, too. Live
 299       // range spilling will insert a spill in the non-null-block if it is
 300       // needs to spill the memory op for an implicit null check.
 301       if (cb->_dom_depth == (block->_dom_depth + 1)) {
 302         if (cb != not_null_block) continue;
 303         cb = cb->_idom;
 304       }
 305     }
 306     if( cb != block ) continue;
 307 
 308     // Found a memory user; see if it can be hoisted to check-block
 309     uint vidx = 0;              // Capture index of value into memop
 310     uint j;
 311     for( j = mach->req()-1; j > 0; j-- ) {
 312       if( mach->in(j) == val ) {
 313         vidx = j;
 314         // Ignore DecodeN val which could be hoisted to where needed.
 315         if( is_decoden ) continue;
 316       }
 317       // Block of memory-op input
 318       Block* inb = get_block_for_node(mach->in(j));
 319       if (mach->in(j)->is_Con() && mach->in(j)->req() == 1 && inb == get_block_for_node(mach)) {
 320         // Ignore constant loads scheduled in the same block (we can simply hoist them as well)
 321         continue;
 322       }
 323       Block *b = block;          // Start from nul check
 324       while( b != inb && b->_dom_depth > inb->_dom_depth )
 325         b = b->_idom;           // search upwards for input
 326       // See if input dominates null check
 327       if( b != inb )
 328         break;
 329     }
 330     if( j > 0 )
 331       continue;
 332     Block *mb = get_block_for_node(mach);
 333     // Hoisting stores requires more checks for the anti-dependence case.
 334     // Give up hoisting if we have to move the store past any load.
 335     if (was_store) {
 336        // Make sure control does not do a merge (would have to check allpaths)
 337        if (mb->num_preds() != 2) {
 338          continue;
 339        }
 340        // mach is a store, hence block is the immediate dominator of mb.
 341        // Due to the null-check shape of block (where its successors cannot re-join),
 342        // block must be the direct predecessor of mb.

 395           tempb->find_remove(temp);
 396           block->add_inst(temp);
 397           map_node_to_block(temp, block);
 398         }
 399       }
 400       valb->find_remove(val);
 401       block->add_inst(val);
 402       map_node_to_block(val, block);
 403       // DecodeN on x86 may kill flags. Check for flag-killing projections
 404       // that also need to be hoisted.
 405       for (DUIterator_Fast jmax, j = val->fast_outs(jmax); j < jmax; j++) {
 406         Node* n = val->fast_out(j);
 407         if( n->is_MachProj() ) {
 408           get_block_for_node(n)->find_remove(n);
 409           block->add_inst(n);
 410           map_node_to_block(n, block);
 411         }
 412       }
 413     }
 414   }
 415 
 416   // Hoist constant load inputs as well.
 417   for (uint i = 1; i < best->req(); ++i) {
 418     Node* n = best->in(i);
 419     if (n->is_Con() && get_block_for_node(n) == get_block_for_node(best)) {
 420       get_block_for_node(n)->find_remove(n);
 421       block->add_inst(n);
 422       map_node_to_block(n, block);
 423       // Constant loads may kill flags (for example, when XORing a register).
 424       // Check for flag-killing projections that also need to be hoisted.
 425       for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) {
 426         Node* proj = n->fast_out(j);
 427         if (proj->is_MachProj()) {
 428           get_block_for_node(proj)->find_remove(proj);
 429           block->add_inst(proj);
 430           map_node_to_block(proj, block);
 431         }
 432       }
 433     }
 434   }
 435 
 436   // Hoist the memory candidate up to the end of the test block.
 437   Block *old_block = get_block_for_node(best);
 438   old_block->find_remove(best);
 439   block->add_inst(best);
 440   map_node_to_block(best, block);
 441 
 442   // Move the control dependence if it is pinned to not-null block.
 443   // Don't change it in other cases: null or dominating control.
 444   Node* ctrl = best->in(0);
 445   if (ctrl != nullptr && get_block_for_node(ctrl) == not_null_block) {
 446     // Set it to control edge of null check.
 447     best->set_req(0, proj->in(0)->in(0));
 448   }
 449 
 450   // Check for flag-killing projections that also need to be hoisted
 451   // Should be DU safe because no edge updates.
 452   for (DUIterator_Fast jmax, j = best->fast_outs(jmax); j < jmax; j++) {
 453     Node* n = best->fast_out(j);
 454     if( n->is_MachProj() ) {
 455       get_block_for_node(n)->find_remove(n);

 887     // Children of projections are now all ready
 888     for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) {
 889       Node* m = n->fast_out(j); // Get user
 890       if(get_block_for_node(m) != block) {
 891         continue;
 892       }
 893       if( m->is_Phi() ) continue;
 894       int m_cnt = ready_cnt.at(m->_idx) - 1;
 895       ready_cnt.at_put(m->_idx, m_cnt);
 896       if( m_cnt == 0 )
 897         worklist.push(m);
 898     }
 899 
 900   }
 901 
 902   // Act as if the call defines the Frame Pointer.
 903   // Certainly the FP is alive and well after the call.
 904   regs.Insert(_matcher.c_frame_pointer());
 905 
 906   // Set all registers killed and not already defined by the call.
 907   uint r_cnt = mcall->tf()->range_cc()->cnt();
 908   int op = mcall->ideal_Opcode();
 909   MachProjNode *proj = new MachProjNode( mcall, r_cnt+1, RegMask::Empty, MachProjNode::fat_proj );
 910   map_node_to_block(proj, block);
 911   block->insert_node(proj, node_cnt++);
 912 
 913   // Select the right register save policy.
 914   const char *save_policy = nullptr;
 915   switch (op) {
 916     case Op_CallRuntime:
 917     case Op_CallLeaf:
 918     case Op_CallLeafNoFP:
 919     case Op_CallLeafVector:
 920       // Calling C code so use C calling convention
 921       save_policy = _matcher._c_reg_save_policy;
 922       break;
 923 
 924     case Op_CallStaticJava:
 925     case Op_CallDynamicJava:
 926       // Calling Java code so use Java calling convention
 927       save_policy = _matcher._register_save_policy;
< prev index next >