@@ -82,35 +82,30 @@ inline HeapWord* HeapRegion::par_allocate_impl(size_t min_word_size,
82
82
} while (true );
83
83
}
84
84
85
- inline HeapWord* HeapRegion::forward_to_block_containing_addr (HeapWord* q, HeapWord* n,
86
- const void * addr,
87
- HeapWord* pb) const {
88
- while (n <= addr) {
89
- // When addr is not covered by the block starting at q we need to
90
- // step forward until we find the correct block. With the BOT
91
- // being precise, we should never have to step through more than
92
- // a single card.
93
- assert (!G1BlockOffsetTablePart::is_crossing_card_boundary (n, (HeapWord*)addr), " must be" );
94
- q = n;
95
- assert (cast_to_oop (q)->klass_or_null () != nullptr ,
96
- " start of block must be an initialized object" );
97
- n += block_size (q, pb);
98
- }
99
- assert (q <= addr, " wrong order for q and addr" );
100
- assert (addr < n, " wrong order for addr and n" );
101
- return q;
102
- }
103
-
104
85
inline HeapWord* HeapRegion::block_start (const void * addr) const {
105
86
return block_start (addr, parsable_bottom_acquire ());
106
87
}
107
88
89
+ inline HeapWord* HeapRegion::advance_to_block_containing_addr (const void * addr,
90
+ HeapWord* const pb,
91
+ HeapWord* first_block) const {
92
+ HeapWord* cur_block = first_block;
93
+ while (true ) {
94
+ HeapWord* next_block = cur_block + block_size (cur_block, pb);
95
+ if (next_block > addr) {
96
+ assert (cur_block <= addr, " postcondition" );
97
+ return cur_block;
98
+ }
99
+ cur_block = next_block;
100
+ // Because the BOT is precise, we should never step into the next card
101
+ // (i.e. crossing the card boundary).
102
+ assert (!G1BlockOffsetTablePart::is_crossing_card_boundary (cur_block, (HeapWord*)addr), " must be" );
103
+ }
104
+ }
105
+
108
106
inline HeapWord* HeapRegion::block_start (const void * addr, HeapWord* const pb) const {
109
- HeapWord* q = _bot_part.block_start_reaching_into_card (addr);
110
- // The returned address is the block that reaches into the card of addr. Walk
111
- // the heap to get to the block reaching into addr.
112
- HeapWord* n = q + block_size (q, pb);
113
- return forward_to_block_containing_addr (q, n, addr, pb);
107
+ HeapWord* first_block = _bot_part.block_start_reaching_into_card (addr);
108
+ return advance_to_block_containing_addr (addr, pb, first_block);
114
109
}
115
110
116
111
inline bool HeapRegion::obj_in_unparsable_area (oop obj, HeapWord* const pb) {
0 commit comments