Skip to content

Commit 0a27f26

Browse files
author
Ivan Walulya
committed
8265057: G1: Investigate removal of maintenance of two BOT thresholds
Reviewed-by: ayang, tschatzl
1 parent eec64f5 commit 0a27f26

File tree

3 files changed

+23
-27
lines changed

3 files changed

+23
-27
lines changed

src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ void G1BlockOffsetTable::check_index(size_t index, const char* msg) const {
7575

7676
G1BlockOffsetTablePart::G1BlockOffsetTablePart(G1BlockOffsetTable* array, HeapRegion* hr) :
7777
_next_offset_threshold(NULL),
78-
_next_offset_index(0),
7978
DEBUG_ONLY(_object_can_span(false) COMMA)
8079
_bot(array),
8180
_hr(hr)
@@ -246,7 +245,7 @@ HeapWord* G1BlockOffsetTablePart::forward_to_block_containing_addr_slow(HeapWord
246245
}
247246
assert(q <= next_boundary && n > next_boundary, "Consequence of loop");
248247
// [q, n) is the block that crosses the boundary.
249-
alloc_block_work(&next_boundary, &next_index, q, n);
248+
alloc_block_work(&next_boundary, q, n);
250249
}
251250
return forward_to_block_containing_addr_const(q, n, addr);
252251
}
@@ -261,11 +260,11 @@ HeapWord* G1BlockOffsetTablePart::forward_to_block_containing_addr_slow(HeapWord
261260
// ( ^ ]
262261
// block-start
263262
//
264-
void G1BlockOffsetTablePart::alloc_block_work(HeapWord** threshold_, size_t* index_,
265-
HeapWord* blk_start, HeapWord* blk_end) {
263+
void G1BlockOffsetTablePart::alloc_block_work(HeapWord** threshold_, HeapWord* blk_start,
264+
HeapWord* blk_end) {
266265
// For efficiency, do copy-in/copy-out.
267266
HeapWord* threshold = *threshold_;
268-
size_t index = *index_;
267+
size_t index = _bot->index_for_raw(threshold);
269268

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

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

290289
// 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
307306
threshold = _bot->address_for_index(end_index) + BOTConstants::N_words;
308307
assert(threshold >= blk_end, "Incorrect offset threshold");
309308

310-
// index_ and threshold_ updated here.
311309
*threshold_ = threshold;
312-
*index_ = index;
313310

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

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

405402
HeapWord* G1BlockOffsetTablePart::initialize_threshold_raw() {
406-
_next_offset_index = _bot->index_for_raw(_hr->bottom());
407-
_next_offset_index++;
403+
size_t next_offset_index = _bot->index_for_raw(_hr->bottom()) + 1;
408404
_next_offset_threshold =
409-
_bot->address_for_index_raw(_next_offset_index);
405+
_bot->address_for_index_raw(next_offset_index);
410406
return _next_offset_threshold;
411407
}
412408

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

420416
HeapWord* G1BlockOffsetTablePart::initialize_threshold() {
421-
_next_offset_index = _bot->index_for(_hr->bottom());
422-
_next_offset_index++;
417+
size_t next_offset_index = _bot->index_for(_hr->bottom()) + 1 ;
423418
_next_offset_threshold =
424-
_bot->address_for_index(_next_offset_index);
419+
_bot->address_for_index(next_offset_index);
425420
return _next_offset_threshold;
426421
}
427422

src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ class G1BlockOffsetTablePart {
112112
private:
113113
// allocation boundary at which offset array must be updated
114114
HeapWord* _next_offset_threshold;
115-
size_t _next_offset_index; // index corresponding to that boundary
116115

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

168167
// Requires that "*threshold_" be the first array entry boundary at or
169-
// above "blk_start", and that "*index_" be the corresponding array
170-
// index. If the block starts at or crosses "*threshold_", records
168+
// above "blk_start". If the block starts at or crosses "*threshold_", records
171169
// "blk_start" as the appropriate block start for the array index
172170
// starting at "*threshold_", and for any other indices crossed by the
173-
// block. Updates "*threshold_" and "*index_" to correspond to the first
174-
// index after the block end.
175-
void alloc_block_work(HeapWord** threshold_, size_t* index_,
176-
HeapWord* blk_start, HeapWord* blk_end);
171+
// block. Updates "*threshold_" to correspond to the first index after
172+
// the block end.
173+
void alloc_block_work(HeapWord** threshold_,
174+
HeapWord* blk_start,
175+
HeapWord* blk_end);
177176

178177
void check_all_cards(size_t left_card, size_t right_card) const;
179178

@@ -214,7 +213,7 @@ class G1BlockOffsetTablePart {
214213
// never exceeds the "_next_offset_threshold".
215214
void alloc_block(HeapWord* blk_start, HeapWord* blk_end) {
216215
if (blk_end > _next_offset_threshold) {
217-
alloc_block_work(&_next_offset_threshold, &_next_offset_index, blk_start, blk_end);
216+
alloc_block_work(&_next_offset_threshold, blk_start, blk_end);
218217
}
219218
}
220219
void alloc_block(HeapWord* blk, size_t size) {

src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ inline HeapWord* G1BlockOffsetTablePart::block_at_or_preceding(const void* addr)
108108
assert(_object_can_span || _bot->offset_array(_bot->index_for(_hr->bottom())) == 0,
109109
"Object crossed region boundary, found offset %u instead of 0",
110110
(uint) _bot->offset_array(_bot->index_for(_hr->bottom())));
111-
size_t index = _bot->index_for(addr);
111+
112112
// We must make sure that the offset table entry we use is valid.
113-
assert(index < _next_offset_index, "Precondition");
113+
assert(addr < _next_offset_threshold, "Precondition");
114+
115+
size_t index = _bot->index_for(addr);
114116

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

0 commit comments

Comments
 (0)