@@ -1329,10 +1329,9 @@ void LinearScan::build_intervals() {
1329
1329
assert (block_to == instructions->at (instructions->length () - 1 )->id (), " must be" );
1330
1330
1331
1331
// Update intervals for registers live at the end of this block;
1332
- ResourceBitMap live = block->live_out ();
1333
- int size = (int )live.size ();
1334
- for (int number = (int )live.get_next_one_offset (0 , size); number < size; number = (int )live.get_next_one_offset (number + 1 , size)) {
1335
- assert (live.at (number), " should not stop here otherwise" );
1332
+ ResourceBitMap& live = block->live_out ();
1333
+ auto updater = [&](BitMap::idx_t index ) {
1334
+ int number = static_cast <int >(index );
1336
1335
assert (number >= LIR_Opr::vreg_base, " fixed intervals must not be live on block bounds" );
1337
1336
TRACE_LINEAR_SCAN (2 , tty->print_cr (" live in %d to %d" , number, block_to + 2 ));
1338
1337
@@ -1347,7 +1346,8 @@ void LinearScan::build_intervals() {
1347
1346
is_interval_in_loop (number, block->loop_index ())) {
1348
1347
interval_at (number)->add_use_pos (block_to + 1 , loopEndMarker);
1349
1348
}
1350
- }
1349
+ };
1350
+ live.iterate(updater);
1351
1351
1352
1352
// iterate all instructions of the block in reverse order.
1353
1353
// skip the first instruction because it is always a label
@@ -1738,11 +1738,10 @@ Interval* LinearScan::interval_at_op_id(int reg_num, int op_id) {
1738
1738
void LinearScan::resolve_collect_mappings (BlockBegin* from_block, BlockBegin* to_block, MoveResolver &move_resolver) {
1739
1739
DEBUG_ONLY (move_resolver.check_empty ());
1740
1740
1741
- const int size = live_set_size ();
1742
- const ResourceBitMap live_at_edge = to_block->live_in ();
1743
-
1744
1741
// visit all registers where the live_at_edge bit is set
1745
- for (int r = (int )live_at_edge.get_next_one_offset (0 , size); r < size; r = (int )live_at_edge.get_next_one_offset (r + 1 , size)) {
1742
+ const ResourceBitMap& live_at_edge = to_block->live_in ();
1743
+ auto visitor = [&](BitMap::idx_t index ) {
1744
+ int r = static_cast <int >(index );
1746
1745
assert (r < num_virtual_regs (), " live information set for not existing interval" );
1747
1746
assert (from_block->live_out ().at (r) && to_block->live_in ().at (r), " interval not live at this edge" );
1748
1747
@@ -1753,7 +1752,8 @@ void LinearScan::resolve_collect_mappings(BlockBegin* from_block, BlockBegin* to
1753
1752
// need to insert move instruction
1754
1753
move_resolver.add_mapping (from_interval, to_interval);
1755
1754
}
1756
- }
1755
+ };
1756
+ live_at_edge.iterate(visitor, 0 , live_set_size ());
1757
1757
}
1758
1758
1759
1759
@@ -1913,10 +1913,11 @@ void LinearScan::resolve_exception_entry(BlockBegin* block, MoveResolver &move_r
1913
1913
DEBUG_ONLY (move_resolver.check_empty ());
1914
1914
1915
1915
// visit all registers where the live_in bit is set
1916
- int size = live_set_size ();
1917
- for ( int r = ( int )block-> live_in (). get_next_one_offset ( 0 , size); r < size; r = ( int )block-> live_in (). get_next_one_offset (r + 1 , size)) {
1916
+ auto resolver = [&](BitMap:: idx_t index ) {
1917
+ int r = static_cast < int >( index );
1918
1918
resolve_exception_entry (block, r, move_resolver);
1919
- }
1919
+ };
1920
+ block->live_in ().iterate(resolver, 0 , live_set_size ());
1920
1921
1921
1922
// the live_in bits are not set for phi functions of the xhandler entry, so iterate them separately
1922
1923
for_each_phi_fun (block, phi,
@@ -1986,10 +1987,11 @@ void LinearScan::resolve_exception_edge(XHandler* handler, int throwing_op_id, M
1986
1987
1987
1988
// visit all registers where the live_in bit is set
1988
1989
BlockBegin* block = handler->entry_block ();
1989
- int size = live_set_size ();
1990
- for ( int r = ( int )block-> live_in (). get_next_one_offset ( 0 , size); r < size; r = ( int )block-> live_in (). get_next_one_offset (r + 1 , size)) {
1990
+ auto resolver = [&](BitMap:: idx_t index ) {
1991
+ int r = static_cast < int >( index );
1991
1992
resolve_exception_edge (handler, throwing_op_id, r, NULL , move_resolver);
1992
- }
1993
+ };
1994
+ block->live_in ().iterate(resolver, 0 , live_set_size ());
1993
1995
1994
1996
// the live_in bits are not set for phi functions of the xhandler entry, so iterate them separately
1995
1997
for_each_phi_fun (block, phi,
@@ -3466,10 +3468,11 @@ void LinearScan::verify_constants() {
3466
3468
3467
3469
for (int i = 0 ; i < num_blocks; i++) {
3468
3470
BlockBegin* block = block_at (i);
3469
- ResourceBitMap live_at_edge = block->live_in ();
3471
+ ResourceBitMap& live_at_edge = block->live_in ();
3470
3472
3471
3473
// visit all registers where the live_at_edge bit is set
3472
- for (int r = (int )live_at_edge.get_next_one_offset (0 , size); r < size; r = (int )live_at_edge.get_next_one_offset (r + 1 , size)) {
3474
+ auto visitor = [&](BitMap::idx_t index ) {
3475
+ int r = static_cast <int >(index );
3473
3476
TRACE_LINEAR_SCAN (4 , tty->print (" checking interval %d of block B%d" , r, block->block_id ()));
3474
3477
3475
3478
Value value = gen ()->instruction_for_vreg (r);
@@ -3478,7 +3481,8 @@ void LinearScan::verify_constants() {
3478
3481
assert (value->operand ()->is_register () && value->operand ()->is_virtual (), " value must have virtual operand" );
3479
3482
assert (value->operand ()->vreg_number () == r, " register number must match" );
3480
3483
// TKR assert(value->as_Constant() == NULL || value->is_pinned(), "only pinned constants can be alive across block boundaries");
3481
- }
3484
+ };
3485
+ live_at_edge.iterate(visitor, 0 , size);
3482
3486
}
3483
3487
}
3484
3488
0 commit comments