Mercurial > hg > truffle
comparison src/share/vm/opto/output.cpp @ 8883:b9a918201d47
Merge with hsx25
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Sat, 06 Apr 2013 20:04:06 +0200 |
parents | f78ac2ce44ef 0a8c2ea3902d |
children | 836a62f43af9 |
comparison
equal
deleted
inserted
replaced
8660:d47b52b0ff68 | 8883:b9a918201d47 |
---|---|
447 if (i< nblocks-1) { | 447 if (i< nblocks-1) { |
448 Block *nb = _cfg->_blocks[i+1]; | 448 Block *nb = _cfg->_blocks[i+1]; |
449 int max_loop_pad = nb->code_alignment()-relocInfo::addr_unit(); | 449 int max_loop_pad = nb->code_alignment()-relocInfo::addr_unit(); |
450 if (max_loop_pad > 0) { | 450 if (max_loop_pad > 0) { |
451 assert(is_power_of_2(max_loop_pad+relocInfo::addr_unit()), ""); | 451 assert(is_power_of_2(max_loop_pad+relocInfo::addr_unit()), ""); |
452 // Adjust last_call_adr and/or last_avoid_back_to_back_adr. | |
453 // If either is the last instruction in this block, bump by | |
454 // max_loop_pad in lock-step with blk_size, so sizing | |
455 // calculations in subsequent blocks still can conservatively | |
456 // detect that it may the last instruction in this block. | |
457 if (last_call_adr == blk_starts[i]+blk_size) { | |
458 last_call_adr += max_loop_pad; | |
459 } | |
460 if (last_avoid_back_to_back_adr == blk_starts[i]+blk_size) { | |
461 last_avoid_back_to_back_adr += max_loop_pad; | |
462 } | |
452 blk_size += max_loop_pad; | 463 blk_size += max_loop_pad; |
453 } | 464 } |
454 } | 465 } |
455 | 466 |
456 // Save block size; update total method size | 467 // Save block size; update total method size |
1194 int previous_offset = 0; | 1205 int previous_offset = 0; |
1195 int current_offset = 0; | 1206 int current_offset = 0; |
1196 int last_call_offset = -1; | 1207 int last_call_offset = -1; |
1197 int last_avoid_back_to_back_offset = -1; | 1208 int last_avoid_back_to_back_offset = -1; |
1198 #ifdef ASSERT | 1209 #ifdef ASSERT |
1199 int block_alignment_padding = 0; | |
1200 | |
1201 uint* jmp_target = NEW_RESOURCE_ARRAY(uint,nblocks); | 1210 uint* jmp_target = NEW_RESOURCE_ARRAY(uint,nblocks); |
1202 uint* jmp_offset = NEW_RESOURCE_ARRAY(uint,nblocks); | 1211 uint* jmp_offset = NEW_RESOURCE_ARRAY(uint,nblocks); |
1203 uint* jmp_size = NEW_RESOURCE_ARRAY(uint,nblocks); | 1212 uint* jmp_size = NEW_RESOURCE_ARRAY(uint,nblocks); |
1204 uint* jmp_rule = NEW_RESOURCE_ARRAY(uint,nblocks); | 1213 uint* jmp_rule = NEW_RESOURCE_ARRAY(uint,nblocks); |
1205 #endif | 1214 #endif |
1229 // ------------------ | 1238 // ------------------ |
1230 // Now fill in the code buffer | 1239 // Now fill in the code buffer |
1231 Node *delay_slot = NULL; | 1240 Node *delay_slot = NULL; |
1232 | 1241 |
1233 for (uint i=0; i < nblocks; i++) { | 1242 for (uint i=0; i < nblocks; i++) { |
1234 guarantee(blk_starts[i] >= (uint)cb->insts_size(),"should not increase size"); | |
1235 | |
1236 Block *b = _cfg->_blocks[i]; | 1243 Block *b = _cfg->_blocks[i]; |
1237 | 1244 |
1238 Node *head = b->head(); | 1245 Node *head = b->head(); |
1239 | 1246 |
1240 // If this block needs to start aligned (i.e, can be reached other | 1247 // If this block needs to start aligned (i.e, can be reached other |
1251 } | 1258 } |
1252 jmp_target[i] = 0; | 1259 jmp_target[i] = 0; |
1253 jmp_offset[i] = 0; | 1260 jmp_offset[i] = 0; |
1254 jmp_size[i] = 0; | 1261 jmp_size[i] = 0; |
1255 jmp_rule[i] = 0; | 1262 jmp_rule[i] = 0; |
1256 | |
1257 // Maximum alignment padding for loop block was used | |
1258 // during first round of branches shortening, as result | |
1259 // padding for nodes (sfpt after call) was not added. | |
1260 // Take this into account for block's size change check | |
1261 // and allow increase block's size by the difference | |
1262 // of maximum and actual alignment paddings. | |
1263 int orig_blk_size = blk_starts[i+1] - blk_starts[i] + block_alignment_padding; | |
1264 #endif | 1263 #endif |
1265 int blk_offset = current_offset; | 1264 int blk_offset = current_offset; |
1266 | 1265 |
1267 // Define the label at the beginning of the basic block | 1266 // Define the label at the beginning of the basic block |
1268 MacroAssembler(cb).bind(blk_labels[b->_pre_order]); | 1267 MacroAssembler(cb).bind(blk_labels[b->_pre_order]); |
1558 // Don't reuse it | 1557 // Don't reuse it |
1559 delay_slot = NULL; | 1558 delay_slot = NULL; |
1560 } | 1559 } |
1561 | 1560 |
1562 } // End for all instructions in block | 1561 } // End for all instructions in block |
1563 assert((uint)blk_offset <= blk_starts[i], "shouldn't increase distance"); | |
1564 blk_starts[i] = blk_offset; | |
1565 | 1562 |
1566 // If the next block is the top of a loop, pad this block out to align | 1563 // If the next block is the top of a loop, pad this block out to align |
1567 // the loop top a little. Helps prevent pipe stalls at loop back branches. | 1564 // the loop top a little. Helps prevent pipe stalls at loop back branches. |
1568 if (i < nblocks-1) { | 1565 if (i < nblocks-1) { |
1569 Block *nb = _cfg->_blocks[i+1]; | 1566 Block *nb = _cfg->_blocks[i+1]; |
1573 b->_nodes.insert( b->_nodes.size(), nop ); | 1570 b->_nodes.insert( b->_nodes.size(), nop ); |
1574 _cfg->_bbs.map( nop->_idx, b ); | 1571 _cfg->_bbs.map( nop->_idx, b ); |
1575 nop->emit(*cb, _regalloc); | 1572 nop->emit(*cb, _regalloc); |
1576 current_offset = cb->insts_size(); | 1573 current_offset = cb->insts_size(); |
1577 } | 1574 } |
1578 #ifdef ASSERT | |
1579 int max_loop_pad = nb->code_alignment()-relocInfo::addr_unit(); | |
1580 block_alignment_padding = (max_loop_pad - padding); | |
1581 assert(block_alignment_padding >= 0, "sanity"); | |
1582 #endif | |
1583 } | 1575 } |
1584 // Verify that the distance for generated before forward | 1576 // Verify that the distance for generated before forward |
1585 // short branches is still valid. | 1577 // short branches is still valid. |
1586 assert(orig_blk_size >= (current_offset - blk_offset), "shouldn't increase block size"); | 1578 guarantee((int)(blk_starts[i+1] - blk_starts[i]) >= (current_offset - blk_offset), "shouldn't increase block size"); |
1587 | 1579 |
1580 // Save new block start offset | |
1581 blk_starts[i] = blk_offset; | |
1588 } // End of for all blocks | 1582 } // End of for all blocks |
1589 blk_starts[nblocks] = current_offset; | 1583 blk_starts[nblocks] = current_offset; |
1590 | 1584 |
1591 non_safepoints.flush_at_end(); | 1585 non_safepoints.flush_at_end(); |
1592 | 1586 |
2519 ComputeUseCount(bb); | 2513 ComputeUseCount(bb); |
2520 | 2514 |
2521 // Schedule the remaining instructions in the block | 2515 // Schedule the remaining instructions in the block |
2522 while ( _available.size() > 0 ) { | 2516 while ( _available.size() > 0 ) { |
2523 Node *n = ChooseNodeToBundle(); | 2517 Node *n = ChooseNodeToBundle(); |
2518 guarantee(n != NULL, "no nodes available"); | |
2524 AddNodeToBundle(n,bb); | 2519 AddNodeToBundle(n,bb); |
2525 } | 2520 } |
2526 | 2521 |
2527 assert( _scheduled.size() == _bb_end - _bb_start, "wrong number of instructions" ); | 2522 assert( _scheduled.size() == _bb_end - _bb_start, "wrong number of instructions" ); |
2528 #ifdef ASSERT | 2523 #ifdef ASSERT |