< prev index next >

src/hotspot/share/opto/lcm.cpp

Print this page

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




 317       Block *b = block;          // Start from nul check
 318       while( b != inb && b->_dom_depth > inb->_dom_depth )
 319         b = b->_idom;           // search upwards for input
 320       // See if input dominates null check
 321       if( b != inb )
 322         break;
 323     }
 324     if( j > 0 )
 325       continue;
 326     Block *mb = get_block_for_node(mach);
 327     // Hoisting stores requires more checks for the anti-dependence case.
 328     // Give up hoisting if we have to move the store past any load.
 329     if( was_store ) {
 330       Block *b = mb;            // Start searching here for a local load
 331       // mach use (faulting) trying to hoist
 332       // n might be blocker to hoisting
 333       while( b != block ) {
 334         uint k;
 335         for( k = 1; k < b->number_of_nodes(); k++ ) {
 336           Node *n = b->get_node(k);

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





















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

 841     // Children of projections are now all ready
 842     for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) {
 843       Node* m = n->fast_out(j); // Get user
 844       if(get_block_for_node(m) != block) {
 845         continue;
 846       }
 847       if( m->is_Phi() ) continue;
 848       int m_cnt = ready_cnt.at(m->_idx) - 1;
 849       ready_cnt.at_put(m->_idx, m_cnt);
 850       if( m_cnt == 0 )
 851         worklist.push(m);
 852     }
 853 
 854   }
 855 
 856   // Act as if the call defines the Frame Pointer.
 857   // Certainly the FP is alive and well after the call.
 858   regs.Insert(_matcher.c_frame_pointer());
 859 
 860   // Set all registers killed and not already defined by the call.
 861   uint r_cnt = mcall->tf()->range()->cnt();
 862   int op = mcall->ideal_Opcode();
 863   MachProjNode *proj = new MachProjNode( mcall, r_cnt+1, RegMask::Empty, MachProjNode::fat_proj );
 864   map_node_to_block(proj, block);
 865   block->insert_node(proj, node_cnt++);
 866 
 867   // Select the right register save policy.
 868   const char *save_policy = NULL;
 869   switch (op) {
 870     case Op_CallRuntime:
 871     case Op_CallLeaf:
 872     case Op_CallLeafNoFP:
 873     case Op_CallLeafVector:
 874       // Calling C code so use C calling convention
 875       save_policy = _matcher._c_reg_save_policy;
 876       break;
 877 
 878     case Op_CallStaticJava:
 879     case Op_CallDynamicJava:
 880       // Calling Java code so use Java calling convention
 881       save_policy = _matcher._register_save_policy;

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

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

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