Skip to content
Permalink
Browse files
8265057: G1: Investigate removal of maintenance of two BOT thresholds
Reviewed-by: ayang, tschatzl
  • Loading branch information
Ivan Walulya committed Aug 4, 2021
1 parent eec64f5 commit 0a27f264da5a21d581e099573e48485bdeea7790
Showing 3 changed files with 23 additions and 27 deletions.
@@ -75,7 +75,6 @@ void G1BlockOffsetTable::check_index(size_t index, const char* msg) const {

G1BlockOffsetTablePart::G1BlockOffsetTablePart(G1BlockOffsetTable* array, HeapRegion* hr) :
_next_offset_threshold(NULL),
_next_offset_index(0),
DEBUG_ONLY(_object_can_span(false) COMMA)
_bot(array),
_hr(hr)
@@ -246,7 +245,7 @@ HeapWord* G1BlockOffsetTablePart::forward_to_block_containing_addr_slow(HeapWord
}
assert(q <= next_boundary && n > next_boundary, "Consequence of loop");
// [q, n) is the block that crosses the boundary.
alloc_block_work(&next_boundary, &next_index, q, n);
alloc_block_work(&next_boundary, q, n);
}
return forward_to_block_containing_addr_const(q, n, addr);
}
@@ -261,11 +260,11 @@ HeapWord* G1BlockOffsetTablePart::forward_to_block_containing_addr_slow(HeapWord
// ( ^ ]
// block-start
//
void G1BlockOffsetTablePart::alloc_block_work(HeapWord** threshold_, size_t* index_,
HeapWord* blk_start, HeapWord* blk_end) {
void G1BlockOffsetTablePart::alloc_block_work(HeapWord** threshold_, HeapWord* blk_start,
HeapWord* blk_end) {
// For efficiency, do copy-in/copy-out.
HeapWord* threshold = *threshold_;
size_t index = *index_;
size_t index = _bot->index_for_raw(threshold);

assert(blk_start != NULL && blk_end > blk_start,
"phantom block");
@@ -283,8 +282,8 @@ void G1BlockOffsetTablePart::alloc_block_work(HeapWord** threshold_, size_t* ind
DEBUG_ONLY(size_t orig_index = index;)

// Mark the card that holds the offset into the block. Note
// that _next_offset_index and _next_offset_threshold are not
// updated until the end of this method.
// that _next_offset_threshold is not updated until the end
// of this method.
_bot->set_offset_array(index, threshold, blk_start);

// We need to now mark the subsequent cards that this blk spans.
@@ -307,9 +306,7 @@ void G1BlockOffsetTablePart::alloc_block_work(HeapWord** threshold_, size_t* ind
threshold = _bot->address_for_index(end_index) + BOTConstants::N_words;
assert(threshold >= blk_end, "Incorrect offset threshold");

// index_ and threshold_ updated here.
*threshold_ = threshold;
*index_ = index;

#ifdef ASSERT
// The offset can be 0 if the block starts on a boundary. That
@@ -341,7 +338,8 @@ void G1BlockOffsetTablePart::verify() const {
assert(_hr->bottom() < _hr->top(), "Only non-empty regions should be verified.");
size_t start_card = _bot->index_for(_hr->bottom());
// Do not verify beyond the BOT allocation threshold.
size_t end_card = MIN2(_bot->index_for(_hr->top() - 1), _next_offset_index - 1);
size_t next_offset_index = _bot->index_for_raw(_next_offset_threshold);
size_t end_card = MIN2(_bot->index_for(_hr->top() - 1), next_offset_index - 1);

for (size_t current_card = start_card; current_card < end_card; current_card++) {
u_char entry = _bot->offset_array(current_card);
@@ -398,15 +396,13 @@ void G1BlockOffsetTablePart::print_on(outputStream* out) {
(uint) _bot->offset_array(i));
}
out->print_cr(" next offset threshold: " PTR_FORMAT, p2i(_next_offset_threshold));
out->print_cr(" next offset index: " SIZE_FORMAT, _next_offset_index);
}
#endif // !PRODUCT

HeapWord* G1BlockOffsetTablePart::initialize_threshold_raw() {
_next_offset_index = _bot->index_for_raw(_hr->bottom());
_next_offset_index++;
size_t next_offset_index = _bot->index_for_raw(_hr->bottom()) + 1;
_next_offset_threshold =
_bot->address_for_index_raw(_next_offset_index);
_bot->address_for_index_raw(next_offset_index);
return _next_offset_threshold;
}

@@ -418,10 +414,9 @@ void G1BlockOffsetTablePart::zero_bottom_entry_raw() {
}

HeapWord* G1BlockOffsetTablePart::initialize_threshold() {
_next_offset_index = _bot->index_for(_hr->bottom());
_next_offset_index++;
size_t next_offset_index = _bot->index_for(_hr->bottom()) + 1 ;
_next_offset_threshold =
_bot->address_for_index(_next_offset_index);
_bot->address_for_index(next_offset_index);
return _next_offset_threshold;
}

@@ -112,7 +112,6 @@ class G1BlockOffsetTablePart {
private:
// allocation boundary at which offset array must be updated
HeapWord* _next_offset_threshold;
size_t _next_offset_index; // index corresponding to that boundary

// Indicates if an object can span into this G1BlockOffsetTablePart.
debug_only(bool _object_can_span;)
@@ -166,14 +165,14 @@ class G1BlockOffsetTablePart {
const void* addr);

// Requires that "*threshold_" be the first array entry boundary at or
// above "blk_start", and that "*index_" be the corresponding array
// index. If the block starts at or crosses "*threshold_", records
// above "blk_start". If the block starts at or crosses "*threshold_", records
// "blk_start" as the appropriate block start for the array index
// starting at "*threshold_", and for any other indices crossed by the
// block. Updates "*threshold_" and "*index_" to correspond to the first
// index after the block end.
void alloc_block_work(HeapWord** threshold_, size_t* index_,
HeapWord* blk_start, HeapWord* blk_end);
// block. Updates "*threshold_" to correspond to the first index after
// the block end.
void alloc_block_work(HeapWord** threshold_,
HeapWord* blk_start,
HeapWord* blk_end);

void check_all_cards(size_t left_card, size_t right_card) const;

@@ -214,7 +213,7 @@ class G1BlockOffsetTablePart {
// never exceeds the "_next_offset_threshold".
void alloc_block(HeapWord* blk_start, HeapWord* blk_end) {
if (blk_end > _next_offset_threshold) {
alloc_block_work(&_next_offset_threshold, &_next_offset_index, blk_start, blk_end);
alloc_block_work(&_next_offset_threshold, blk_start, blk_end);
}
}
void alloc_block(HeapWord* blk, size_t size) {
@@ -108,9 +108,11 @@ inline HeapWord* G1BlockOffsetTablePart::block_at_or_preceding(const void* addr)
assert(_object_can_span || _bot->offset_array(_bot->index_for(_hr->bottom())) == 0,
"Object crossed region boundary, found offset %u instead of 0",
(uint) _bot->offset_array(_bot->index_for(_hr->bottom())));
size_t index = _bot->index_for(addr);

// We must make sure that the offset table entry we use is valid.
assert(index < _next_offset_index, "Precondition");
assert(addr < _next_offset_threshold, "Precondition");

size_t index = _bot->index_for(addr);

HeapWord* q = _bot->address_for_index(index);

1 comment on commit 0a27f26

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 0a27f26 Aug 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.