src/share/vm/opto/output.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hs-comp-shorten-branches Sdiff src/share/vm/opto

src/share/vm/opto/output.cpp

Print this page




 482 #ifdef ASSERT
 483         assert(jmp_size[i] > 0 && mach->is_MachBranch(), "sanity");
 484         int j;
 485         // Find the branch; ignore trailing NOPs.
 486         for (j = block->number_of_nodes()-1; j>=0; j--) {
 487           Node* n = block->get_node(j);
 488           if (!n->is_Mach() || n->as_Mach()->ideal_Opcode() != Op_Con)
 489             break;
 490         }
 491         assert(j >= 0 && j == idx && block->get_node(j) == (Node*)mach, "sanity");
 492 #endif
 493         int br_size = jmp_size[i];
 494         int br_offs = blk_starts[i] + jmp_offset[i];
 495 
 496         // This requires the TRUE branch target be in succs[0]
 497         uint bnum = block->non_connector_successor(0)->_pre_order;
 498         int offset = blk_starts[bnum] - br_offs;
 499         if (bnum > i) { // adjust following block's offset
 500           offset -= adjust_block_start;
 501         }










 502         // In the following code a nop could be inserted before
 503         // the branch which will increase the backward distance.
 504         bool needs_padding = ((uint)br_offs == last_may_be_short_branch_adr);
 505         if (needs_padding && offset <= 0)
 506           offset -= nop_size;
 507 
 508         if (_matcher->is_short_branch_offset(mach->rule(), br_size, offset)) {
 509           // We've got a winner.  Replace this branch.
 510           MachNode* replacement = mach->as_MachBranch()->short_branch_version(this);
 511 
 512           // Update the jmp_size.
 513           int new_size = replacement->size(_regalloc);
 514           int diff     = br_size - new_size;
 515           assert(diff >= (int)nop_size, "short_branch size should be smaller");
 516           // Conservatively take into accound padding between
 517           // avoid_back_to_back branches. Previous branch could be
 518           // converted into avoid_back_to_back branch during next
 519           // rounds.
 520           if (needs_padding && replacement->avoid_back_to_back()) {
 521             jmp_offset[i] += nop_size;
 522             diff -= nop_size;
 523           }
 524           adjust_block_start += diff;




 482 #ifdef ASSERT
 483         assert(jmp_size[i] > 0 && mach->is_MachBranch(), "sanity");
 484         int j;
 485         // Find the branch; ignore trailing NOPs.
 486         for (j = block->number_of_nodes()-1; j>=0; j--) {
 487           Node* n = block->get_node(j);
 488           if (!n->is_Mach() || n->as_Mach()->ideal_Opcode() != Op_Con)
 489             break;
 490         }
 491         assert(j >= 0 && j == idx && block->get_node(j) == (Node*)mach, "sanity");
 492 #endif
 493         int br_size = jmp_size[i];
 494         int br_offs = blk_starts[i] + jmp_offset[i];
 495 
 496         // This requires the TRUE branch target be in succs[0]
 497         uint bnum = block->non_connector_successor(0)->_pre_order;
 498         int offset = blk_starts[bnum] - br_offs;
 499         if (bnum > i) { // adjust following block's offset
 500           offset -= adjust_block_start;
 501         }
 502 
 503         // This block can be a loop header, account for the padding
 504         // in the previous block.
 505         int prev_block_loop_pad = block->code_alignment() - relocInfo::addr_unit();
 506         if (i > 0 && prev_block_loop_pad > 0) {
 507           assert(br_offs >= prev_block_loop_pad, "Should have at least a padding on top");
 508         } else {
 509           // First block or not a loop
 510           prev_block_loop_pad = 0;
 511         }
 512         // In the following code a nop could be inserted before
 513         // the branch which will increase the backward distance.
 514         bool needs_padding = ((uint)(br_offs - prev_block_loop_pad) == last_may_be_short_branch_adr);
 515         if (needs_padding && offset <= 0)
 516           offset -= nop_size;
 517 
 518         if (_matcher->is_short_branch_offset(mach->rule(), br_size, offset)) {
 519           // We've got a winner.  Replace this branch.
 520           MachNode* replacement = mach->as_MachBranch()->short_branch_version(this);
 521 
 522           // Update the jmp_size.
 523           int new_size = replacement->size(_regalloc);
 524           int diff     = br_size - new_size;
 525           assert(diff >= (int)nop_size, "short_branch size should be smaller");
 526           // Conservatively take into accound padding between
 527           // avoid_back_to_back branches. Previous branch could be
 528           // converted into avoid_back_to_back branch during next
 529           // rounds.
 530           if (needs_padding && replacement->avoid_back_to_back()) {
 531             jmp_offset[i] += nop_size;
 532             diff -= nop_size;
 533           }
 534           adjust_block_start += diff;


src/share/vm/opto/output.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File