src/share/vm/opto/output.cpp
Print this page
*** 447,456 ****
--- 447,467 ----
if (i< nblocks-1) {
Block *nb = _cfg->_blocks[i+1];
int max_loop_pad = nb->code_alignment()-relocInfo::addr_unit();
if (max_loop_pad > 0) {
assert(is_power_of_2(max_loop_pad+relocInfo::addr_unit()), "");
+ // Adjust last_call_adr and/or last_avoid_back_to_back_adr.
+ // If either is the last instruction in this block, bump by
+ // max_loop_pad in lock-step with blk_size, so sizing
+ // calculations in subsequent blocks still can conservatively
+ // detect that it may the last instruction in this block.
+ if (last_call_adr == blk_starts[i]+blk_size) {
+ last_call_adr += max_loop_pad;
+ }
+ if (last_avoid_back_to_back_adr == blk_starts[i]+blk_size) {
+ last_avoid_back_to_back_adr += max_loop_pad;
+ }
blk_size += max_loop_pad;
}
}
// Save block size; update total method size
*** 1191,1202 ****
int previous_offset = 0;
int current_offset = 0;
int last_call_offset = -1;
int last_avoid_back_to_back_offset = -1;
#ifdef ASSERT
- int block_alignment_padding = 0;
-
uint* jmp_target = NEW_RESOURCE_ARRAY(uint,nblocks);
uint* jmp_offset = NEW_RESOURCE_ARRAY(uint,nblocks);
uint* jmp_size = NEW_RESOURCE_ARRAY(uint,nblocks);
uint* jmp_rule = NEW_RESOURCE_ARRAY(uint,nblocks);
#endif
--- 1202,1211 ----
*** 1226,1237 ****
// ------------------
// Now fill in the code buffer
Node *delay_slot = NULL;
for (uint i=0; i < nblocks; i++) {
- guarantee(blk_starts[i] >= (uint)cb->insts_size(),"should not increase size");
-
Block *b = _cfg->_blocks[i];
Node *head = b->head();
// If this block needs to start aligned (i.e, can be reached other
--- 1235,1244 ----
*** 1248,1265 ****
}
jmp_target[i] = 0;
jmp_offset[i] = 0;
jmp_size[i] = 0;
jmp_rule[i] = 0;
-
- // Maximum alignment padding for loop block was used
- // during first round of branches shortening, as result
- // padding for nodes (sfpt after call) was not added.
- // Take this into account for block's size change check
- // and allow increase block's size by the difference
- // of maximum and actual alignment paddings.
- int orig_blk_size = blk_starts[i+1] - blk_starts[i] + block_alignment_padding;
#endif
int blk_offset = current_offset;
// Define the label at the beginning of the basic block
MacroAssembler(cb).bind(blk_labels[b->_pre_order]);
--- 1255,1264 ----
*** 1555,1566 ****
// Don't reuse it
delay_slot = NULL;
}
} // End for all instructions in block
- assert((uint)blk_offset <= blk_starts[i], "shouldn't increase distance");
- blk_starts[i] = blk_offset;
// If the next block is the top of a loop, pad this block out to align
// the loop top a little. Helps prevent pipe stalls at loop back branches.
if (i < nblocks-1) {
Block *nb = _cfg->_blocks[i+1];
--- 1554,1563 ----
*** 1570,1589 ****
b->_nodes.insert( b->_nodes.size(), nop );
_cfg->_bbs.map( nop->_idx, b );
nop->emit(*cb, _regalloc);
current_offset = cb->insts_size();
}
- #ifdef ASSERT
- int max_loop_pad = nb->code_alignment()-relocInfo::addr_unit();
- block_alignment_padding = (max_loop_pad - padding);
- assert(block_alignment_padding >= 0, "sanity");
- #endif
}
// Verify that the distance for generated before forward
// short branches is still valid.
! assert(orig_blk_size >= (current_offset - blk_offset), "shouldn't increase block size");
} // End of for all blocks
blk_starts[nblocks] = current_offset;
non_safepoints.flush_at_end();
--- 1567,1583 ----
b->_nodes.insert( b->_nodes.size(), nop );
_cfg->_bbs.map( nop->_idx, b );
nop->emit(*cb, _regalloc);
current_offset = cb->insts_size();
}
}
// Verify that the distance for generated before forward
// short branches is still valid.
! guarantee((int)(blk_starts[i+1] - blk_starts[i]) >= (current_offset - blk_offset), "shouldn't increase block size");
+ // Save new block start offset
+ blk_starts[i] = blk_offset;
} // End of for all blocks
blk_starts[nblocks] = current_offset;
non_safepoints.flush_at_end();