mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-18 01:17:57 +00:00
8290291: G1: Merge multiple calls of block_size in HeapRegion::block_start
Reviewed-by: tschatzl, iwalulya
This commit is contained in:
parent
fd4b2f2868
commit
ec96b1f187
@ -139,12 +139,9 @@ private:
|
||||
// This version synchronizes with other calls to par_allocate_impl().
|
||||
inline HeapWord* par_allocate_impl(size_t min_word_size, size_t desired_word_size, size_t* actual_word_size);
|
||||
|
||||
// Return the address of the beginning of the block that contains "addr".
|
||||
// "q" is a block boundary that is <= "addr"; "n" is the address of the
|
||||
// next block (or the end of the HeapRegion.)
|
||||
inline HeapWord* forward_to_block_containing_addr(HeapWord* q, HeapWord* n,
|
||||
const void* addr,
|
||||
HeapWord* pb) const;
|
||||
inline HeapWord* advance_to_block_containing_addr(const void* addr,
|
||||
HeapWord* const pb,
|
||||
HeapWord* first_block) const;
|
||||
|
||||
static bool obj_is_filler(oop obj);
|
||||
|
||||
|
||||
@ -82,35 +82,30 @@ inline HeapWord* HeapRegion::par_allocate_impl(size_t min_word_size,
|
||||
} while (true);
|
||||
}
|
||||
|
||||
inline HeapWord* HeapRegion::forward_to_block_containing_addr(HeapWord* q, HeapWord* n,
|
||||
const void* addr,
|
||||
HeapWord* pb) const {
|
||||
while (n <= addr) {
|
||||
// When addr is not covered by the block starting at q we need to
|
||||
// step forward until we find the correct block. With the BOT
|
||||
// being precise, we should never have to step through more than
|
||||
// a single card.
|
||||
assert(!G1BlockOffsetTablePart::is_crossing_card_boundary(n, (HeapWord*)addr), "must be");
|
||||
q = n;
|
||||
assert(cast_to_oop(q)->klass_or_null() != nullptr,
|
||||
"start of block must be an initialized object");
|
||||
n += block_size(q, pb);
|
||||
}
|
||||
assert(q <= addr, "wrong order for q and addr");
|
||||
assert(addr < n, "wrong order for addr and n");
|
||||
return q;
|
||||
}
|
||||
|
||||
inline HeapWord* HeapRegion::block_start(const void* addr) const {
|
||||
return block_start(addr, parsable_bottom_acquire());
|
||||
}
|
||||
|
||||
inline HeapWord* HeapRegion::advance_to_block_containing_addr(const void* addr,
|
||||
HeapWord* const pb,
|
||||
HeapWord* first_block) const {
|
||||
HeapWord* cur_block = first_block;
|
||||
while (true) {
|
||||
HeapWord* next_block = cur_block + block_size(cur_block, pb);
|
||||
if (next_block > addr) {
|
||||
assert(cur_block <= addr, "postcondition");
|
||||
return cur_block;
|
||||
}
|
||||
cur_block = next_block;
|
||||
// Because the BOT is precise, we should never step into the next card
|
||||
// (i.e. crossing the card boundary).
|
||||
assert(!G1BlockOffsetTablePart::is_crossing_card_boundary(cur_block, (HeapWord*)addr), "must be");
|
||||
}
|
||||
}
|
||||
|
||||
inline HeapWord* HeapRegion::block_start(const void* addr, HeapWord* const pb) const {
|
||||
HeapWord* q = _bot_part.block_start_reaching_into_card(addr);
|
||||
// The returned address is the block that reaches into the card of addr. Walk
|
||||
// the heap to get to the block reaching into addr.
|
||||
HeapWord* n = q + block_size(q, pb);
|
||||
return forward_to_block_containing_addr(q, n, addr, pb);
|
||||
HeapWord* first_block = _bot_part.block_start_reaching_into_card(addr);
|
||||
return advance_to_block_containing_addr(addr, pb, first_block);
|
||||
}
|
||||
|
||||
inline bool HeapRegion::obj_in_unparsable_area(oop obj, HeapWord* const pb) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user