8146399: Refactor the BlockOffsetTable classes

Reviewed-by: mgerdin, jwilhelm, tschatzl
This commit is contained in:
David Lindholm 2016-01-07 16:25:53 +01:00
parent a476bf01f4
commit 98193d202b
17 changed files with 288 additions and 540 deletions

View File

@ -277,7 +277,7 @@ HeapRegion* OldGCAllocRegion::release() {
// Determine how far we are from the next card boundary. If it is smaller than // Determine how far we are from the next card boundary. If it is smaller than
// the minimum object size we can allocate into, expand into the next card. // the minimum object size we can allocate into, expand into the next card.
HeapWord* top = cur->top(); HeapWord* top = cur->top();
HeapWord* aligned_top = (HeapWord*)align_ptr_up(top, G1BlockOffsetSharedArray::N_bytes); HeapWord* aligned_top = (HeapWord*)align_ptr_up(top, G1BlockOffsetTable::N_bytes);
size_t to_allocate_words = pointer_delta(aligned_top, top, HeapWordSize); size_t to_allocate_words = pointer_delta(aligned_top, top, HeapWordSize);

View File

@ -35,35 +35,29 @@
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// G1BlockOffsetSharedArray // G1BlockOffsetTable
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
G1BlockOffsetSharedArray::G1BlockOffsetSharedArray(MemRegion heap, G1RegionToSpaceMapper* storage) : G1BlockOffsetTable::G1BlockOffsetTable(MemRegion heap, G1RegionToSpaceMapper* storage) :
_reserved(), _end(NULL), _listener(), _offset_array(NULL) { _reserved(heap), _offset_array(NULL) {
_reserved = heap;
_end = NULL;
MemRegion bot_reserved = storage->reserved(); MemRegion bot_reserved = storage->reserved();
_offset_array = (u_char*)bot_reserved.start(); _offset_array = (u_char*)bot_reserved.start();
_end = _reserved.end();
storage->set_mapping_changed_listener(&_listener); log_trace(gc, bot)("G1BlockOffsetTable::G1BlockOffsetTable: ");
log_trace(gc, bot)("G1BlockOffsetSharedArray::G1BlockOffsetSharedArray: ");
log_trace(gc, bot)(" rs.base(): " PTR_FORMAT " rs.size(): " SIZE_FORMAT " rs end(): " PTR_FORMAT, log_trace(gc, bot)(" rs.base(): " PTR_FORMAT " rs.size(): " SIZE_FORMAT " rs end(): " PTR_FORMAT,
p2i(bot_reserved.start()), bot_reserved.byte_size(), p2i(bot_reserved.end())); p2i(bot_reserved.start()), bot_reserved.byte_size(), p2i(bot_reserved.end()));
} }
bool G1BlockOffsetSharedArray::is_card_boundary(HeapWord* p) const { bool G1BlockOffsetTable::is_card_boundary(HeapWord* p) const {
assert(p >= _reserved.start(), "just checking"); assert(p >= _reserved.start(), "just checking");
size_t delta = pointer_delta(p, _reserved.start()); size_t delta = pointer_delta(p, _reserved.start());
return (delta & right_n_bits(LogN_words)) == (size_t)NoBits; return (delta & right_n_bits(LogN_words)) == (size_t)NoBits;
} }
#ifdef ASSERT #ifdef ASSERT
void G1BlockOffsetSharedArray::check_index(size_t index, const char* msg) const { void G1BlockOffsetTable::check_index(size_t index, const char* msg) const {
assert((index) < (_reserved.word_size() >> LogN_words), assert((index) < (_reserved.word_size() >> LogN_words),
"%s - index: " SIZE_FORMAT ", _vs.committed_size: " SIZE_FORMAT, "%s - index: " SIZE_FORMAT ", _vs.committed_size: " SIZE_FORMAT,
msg, (index), (_reserved.word_size() >> LogN_words)); msg, (index), (_reserved.word_size() >> LogN_words));
@ -77,25 +71,19 @@ void G1BlockOffsetSharedArray::check_index(size_t index, const char* msg) const
#endif // ASSERT #endif // ASSERT
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// G1BlockOffsetArray // G1BlockOffsetTablePart
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
G1BlockOffsetArray::G1BlockOffsetArray(G1BlockOffsetSharedArray* array, G1BlockOffsetTablePart::G1BlockOffsetTablePart(G1BlockOffsetTable* array, G1ContiguousSpace* gsp) :
MemRegion mr) : _bot(array),
G1BlockOffsetTable(mr.start(), mr.end()), _space(gsp),
_unallocated_block(_bottom), _next_offset_threshold(NULL),
_array(array), _gsp(NULL) { _next_offset_index(0)
assert(_bottom <= _end, "arguments out of order"); { }
}
void G1BlockOffsetArray::set_space(G1OffsetTableContigSpace* sp) {
_gsp = sp;
}
// The arguments follow the normal convention of denoting // The arguments follow the normal convention of denoting
// a right-open interval: [start, end) // a right-open interval: [start, end)
void void G1BlockOffsetTablePart:: set_remainder_to_point_to_start(HeapWord* start, HeapWord* end) {
G1BlockOffsetArray:: set_remainder_to_point_to_start(HeapWord* start, HeapWord* end) {
if (start >= end) { if (start >= end) {
// The start address is equal to the end address (or to // The start address is equal to the end address (or to
@ -137,23 +125,22 @@ G1BlockOffsetArray:: set_remainder_to_point_to_start(HeapWord* start, HeapWord*
// Move back N (e.g., 8) entries and repeat with the // Move back N (e.g., 8) entries and repeat with the
// value of the new entry // value of the new entry
// //
size_t start_card = _array->index_for(start); size_t start_card = _bot->index_for(start);
size_t end_card = _array->index_for(end-1); size_t end_card = _bot->index_for(end-1);
assert(start ==_array->address_for_index(start_card), "Precondition"); assert(start ==_bot->address_for_index(start_card), "Precondition");
assert(end ==_array->address_for_index(end_card)+N_words, "Precondition"); assert(end ==_bot->address_for_index(end_card)+N_words, "Precondition");
set_remainder_to_point_to_start_incl(start_card, end_card); // closed interval set_remainder_to_point_to_start_incl(start_card, end_card); // closed interval
} }
// Unlike the normal convention in this code, the argument here denotes // Unlike the normal convention in this code, the argument here denotes
// a closed, inclusive interval: [start_card, end_card], cf set_remainder_to_point_to_start() // a closed, inclusive interval: [start_card, end_card], cf set_remainder_to_point_to_start()
// above. // above.
void void G1BlockOffsetTablePart::set_remainder_to_point_to_start_incl(size_t start_card, size_t end_card) {
G1BlockOffsetArray::set_remainder_to_point_to_start_incl(size_t start_card, size_t end_card) {
if (start_card > end_card) { if (start_card > end_card) {
return; return;
} }
assert(start_card > _array->index_for(_bottom), "Cannot be first card"); assert(start_card > _bot->index_for(_space->bottom()), "Cannot be first card");
assert(_array->offset_array(start_card-1) <= N_words, assert(_bot->offset_array(start_card-1) <= N_words,
"Offset card has an unexpected value"); "Offset card has an unexpected value");
size_t start_card_for_region = start_card; size_t start_card_for_region = start_card;
u_char offset = max_jubyte; u_char offset = max_jubyte;
@ -164,11 +151,11 @@ G1BlockOffsetArray::set_remainder_to_point_to_start_incl(size_t start_card, size
size_t reach = start_card - 1 + (BlockOffsetArray::power_to_cards_back(i+1) - 1); size_t reach = start_card - 1 + (BlockOffsetArray::power_to_cards_back(i+1) - 1);
offset = N_words + i; offset = N_words + i;
if (reach >= end_card) { if (reach >= end_card) {
_array->set_offset_array(start_card_for_region, end_card, offset); _bot->set_offset_array(start_card_for_region, end_card, offset);
start_card_for_region = reach + 1; start_card_for_region = reach + 1;
break; break;
} }
_array->set_offset_array(start_card_for_region, reach, offset); _bot->set_offset_array(start_card_for_region, reach, offset);
start_card_for_region = reach + 1; start_card_for_region = reach + 1;
} }
assert(start_card_for_region > end_card, "Sanity check"); assert(start_card_for_region > end_card, "Sanity check");
@ -178,77 +165,42 @@ G1BlockOffsetArray::set_remainder_to_point_to_start_incl(size_t start_card, size
// The card-interval [start_card, end_card] is a closed interval; this // The card-interval [start_card, end_card] is a closed interval; this
// is an expensive check -- use with care and only under protection of // is an expensive check -- use with care and only under protection of
// suitable flag. // suitable flag.
void G1BlockOffsetArray::check_all_cards(size_t start_card, size_t end_card) const { void G1BlockOffsetTablePart::check_all_cards(size_t start_card, size_t end_card) const {
if (end_card < start_card) { if (end_card < start_card) {
return; return;
} }
guarantee(_array->offset_array(start_card) == N_words, "Wrong value in second card"); guarantee(_bot->offset_array(start_card) == N_words, "Wrong value in second card");
for (size_t c = start_card + 1; c <= end_card; c++ /* yeah! */) { for (size_t c = start_card + 1; c <= end_card; c++ /* yeah! */) {
u_char entry = _array->offset_array(c); u_char entry = _bot->offset_array(c);
if (c - start_card > BlockOffsetArray::power_to_cards_back(1)) { if (c - start_card > BlockOffsetArray::power_to_cards_back(1)) {
guarantee(entry > N_words, guarantee(entry > N_words,
"Should be in logarithmic region - " "Should be in logarithmic region - "
"entry: %u, " "entry: %u, "
"_array->offset_array(c): %u, " "_array->offset_array(c): %u, "
"N_words: %u", "N_words: %u",
(uint)entry, (uint)_array->offset_array(c), (uint)N_words); (uint)entry, (uint)_bot->offset_array(c), (uint)N_words);
} }
size_t backskip = BlockOffsetArray::entry_to_cards_back(entry); size_t backskip = BlockOffsetArray::entry_to_cards_back(entry);
size_t landing_card = c - backskip; size_t landing_card = c - backskip;
guarantee(landing_card >= (start_card - 1), "Inv"); guarantee(landing_card >= (start_card - 1), "Inv");
if (landing_card >= start_card) { if (landing_card >= start_card) {
guarantee(_array->offset_array(landing_card) <= entry, guarantee(_bot->offset_array(landing_card) <= entry,
"Monotonicity - landing_card offset: %u, " "Monotonicity - landing_card offset: %u, "
"entry: %u", "entry: %u",
(uint)_array->offset_array(landing_card), (uint)entry); (uint)_bot->offset_array(landing_card), (uint)entry);
} else { } else {
guarantee(landing_card == start_card - 1, "Tautology"); guarantee(landing_card == start_card - 1, "Tautology");
// Note that N_words is the maximum offset value // Note that N_words is the maximum offset value
guarantee(_array->offset_array(landing_card) <= N_words, guarantee(_bot->offset_array(landing_card) <= N_words,
"landing card offset: %u, " "landing card offset: %u, "
"N_words: %u", "N_words: %u",
(uint)_array->offset_array(landing_card), (uint)N_words); (uint)_bot->offset_array(landing_card), (uint)N_words);
} }
} }
} }
HeapWord* G1BlockOffsetArray::block_start_unsafe(const void* addr) { HeapWord* G1BlockOffsetTablePart::forward_to_block_containing_addr_slow(HeapWord* q,
assert(_bottom <= addr && addr < _end,
"addr must be covered by this Array");
// Must read this exactly once because it can be modified by parallel
// allocation.
HeapWord* ub = _unallocated_block;
if (BlockOffsetArrayUseUnallocatedBlock && addr >= ub) {
assert(ub < _end, "tautology (see above)");
return ub;
}
// Otherwise, find the block start using the table.
HeapWord* q = block_at_or_preceding(addr, false, 0);
return forward_to_block_containing_addr(q, addr);
}
// This duplicates a little code from the above: unavoidable.
HeapWord*
G1BlockOffsetArray::block_start_unsafe_const(const void* addr) const {
assert(_bottom <= addr && addr < _end,
"addr must be covered by this Array");
// Must read this exactly once because it can be modified by parallel
// allocation.
HeapWord* ub = _unallocated_block;
if (BlockOffsetArrayUseUnallocatedBlock && addr >= ub) {
assert(ub < _end, "tautology (see above)");
return ub;
}
// Otherwise, find the block start using the table.
HeapWord* q = block_at_or_preceding(addr, false, 0);
HeapWord* n = q + block_size(q);
return forward_to_block_containing_addr_const(q, n, addr);
}
HeapWord*
G1BlockOffsetArray::forward_to_block_containing_addr_slow(HeapWord* q,
HeapWord* n, HeapWord* n,
const void* addr) { const void* addr) {
// We're not in the normal case. We need to handle an important subcase // We're not in the normal case. We need to handle an important subcase
@ -260,17 +212,17 @@ G1BlockOffsetArray::forward_to_block_containing_addr_slow(HeapWord* q,
// If the fist object's end q is at the card boundary. Start refining // If the fist object's end q is at the card boundary. Start refining
// with the corresponding card (the value of the entry will be basically // with the corresponding card (the value of the entry will be basically
// set to 0). If the object crosses the boundary -- start from the next card. // set to 0). If the object crosses the boundary -- start from the next card.
size_t n_index = _array->index_for(n); size_t n_index = _bot->index_for(n);
size_t next_index = _array->index_for(n) + !_array->is_card_boundary(n); size_t next_index = _bot->index_for(n) + !_bot->is_card_boundary(n);
// Calculate a consistent next boundary. If "n" is not at the boundary // Calculate a consistent next boundary. If "n" is not at the boundary
// already, step to the boundary. // already, step to the boundary.
HeapWord* next_boundary = _array->address_for_index(n_index) + HeapWord* next_boundary = _bot->address_for_index(n_index) +
(n_index == next_index ? 0 : N_words); (n_index == next_index ? 0 : N_words);
assert(next_boundary <= _array->_end, assert(next_boundary <= _bot->_reserved.end(),
"next_boundary is beyond the end of the covered region " "next_boundary is beyond the end of the covered region "
" next_boundary " PTR_FORMAT " _array->_end " PTR_FORMAT, " next_boundary " PTR_FORMAT " _array->_end " PTR_FORMAT,
p2i(next_boundary), p2i(_array->_end)); p2i(next_boundary), p2i(_bot->_reserved.end()));
if (addr >= gsp()->top()) return gsp()->top(); if (addr >= _space->top()) return _space->top();
while (next_boundary < addr) { while (next_boundary < addr) {
while (n <= next_boundary) { while (n <= next_boundary) {
q = n; q = n;
@ -280,18 +232,11 @@ G1BlockOffsetArray::forward_to_block_containing_addr_slow(HeapWord* q,
} }
assert(q <= next_boundary && n > next_boundary, "Consequence of loop"); assert(q <= next_boundary && n > next_boundary, "Consequence of loop");
// [q, n) is the block that crosses the boundary. // [q, n) is the block that crosses the boundary.
alloc_block_work2(&next_boundary, &next_index, q, n); alloc_block_work(&next_boundary, &next_index, q, n);
} }
return forward_to_block_containing_addr_const(q, n, addr); return forward_to_block_containing_addr_const(q, n, addr);
} }
// Note that the committed size of the covered space may have changed,
// so the table size might also wish to change.
void G1BlockOffsetArray::resize(size_t new_word_size) {
HeapWord* new_end = _bottom + new_word_size;
_end = new_end; // update _end
}
// //
// threshold_ // threshold_
// | _index_ // | _index_
@ -302,7 +247,7 @@ void G1BlockOffsetArray::resize(size_t new_word_size) {
// ( ^ ] // ( ^ ]
// block-start // block-start
// //
void G1BlockOffsetArray::alloc_block_work2(HeapWord** threshold_, size_t* index_, void G1BlockOffsetTablePart::alloc_block_work(HeapWord** threshold_, size_t* index_,
HeapWord* blk_start, HeapWord* blk_end) { HeapWord* blk_start, HeapWord* blk_end) {
// For efficiency, do copy-in/copy-out. // For efficiency, do copy-in/copy-out.
HeapWord* threshold = *threshold_; HeapWord* threshold = *threshold_;
@ -318,7 +263,7 @@ void G1BlockOffsetArray::alloc_block_work2(HeapWord** threshold_, size_t* index_
"reference must be into the heap"); "reference must be into the heap");
assert(G1CollectedHeap::heap()->is_in_reserved(blk_end-1), assert(G1CollectedHeap::heap()->is_in_reserved(blk_end-1),
"limit must be within the heap"); "limit must be within the heap");
assert(threshold == _array->_reserved.start() + index*N_words, assert(threshold == _bot->_reserved.start() + index*N_words,
"index must agree with threshold"); "index must agree with threshold");
DEBUG_ONLY(size_t orig_index = index;) DEBUG_ONLY(size_t orig_index = index;)
@ -326,26 +271,26 @@ void G1BlockOffsetArray::alloc_block_work2(HeapWord** threshold_, size_t* index_
// Mark the card that holds the offset into the block. Note // Mark the card that holds the offset into the block. Note
// that _next_offset_index and _next_offset_threshold are not // that _next_offset_index and _next_offset_threshold are not
// updated until the end of this method. // updated until the end of this method.
_array->set_offset_array(index, threshold, blk_start); _bot->set_offset_array(index, threshold, blk_start);
// We need to now mark the subsequent cards that this blk spans. // We need to now mark the subsequent cards that this blk spans.
// Index of card on which blk ends. // Index of card on which blk ends.
size_t end_index = _array->index_for(blk_end - 1); size_t end_index = _bot->index_for(blk_end - 1);
// Are there more cards left to be updated? // Are there more cards left to be updated?
if (index + 1 <= end_index) { if (index + 1 <= end_index) {
HeapWord* rem_st = _array->address_for_index(index + 1); HeapWord* rem_st = _bot->address_for_index(index + 1);
// Calculate rem_end this way because end_index // Calculate rem_end this way because end_index
// may be the last valid index in the covered region. // may be the last valid index in the covered region.
HeapWord* rem_end = _array->address_for_index(end_index) + N_words; HeapWord* rem_end = _bot->address_for_index(end_index) + N_words;
set_remainder_to_point_to_start(rem_st, rem_end); set_remainder_to_point_to_start(rem_st, rem_end);
} }
index = end_index + 1; index = end_index + 1;
// Calculate threshold_ this way because end_index // Calculate threshold_ this way because end_index
// may be the last valid index in the covered region. // may be the last valid index in the covered region.
threshold = _array->address_for_index(end_index) + N_words; threshold = _bot->address_for_index(end_index) + N_words;
assert(threshold >= blk_end, "Incorrect offset threshold"); assert(threshold >= blk_end, "Incorrect offset threshold");
// index_ and threshold_ updated here. // index_ and threshold_ updated here.
@ -355,49 +300,49 @@ void G1BlockOffsetArray::alloc_block_work2(HeapWord** threshold_, size_t* index_
#ifdef ASSERT #ifdef ASSERT
// The offset can be 0 if the block starts on a boundary. That // The offset can be 0 if the block starts on a boundary. That
// is checked by an assertion above. // is checked by an assertion above.
size_t start_index = _array->index_for(blk_start); size_t start_index = _bot->index_for(blk_start);
HeapWord* boundary = _array->address_for_index(start_index); HeapWord* boundary = _bot->address_for_index(start_index);
assert((_array->offset_array(orig_index) == 0 && blk_start == boundary) || assert((_bot->offset_array(orig_index) == 0 && blk_start == boundary) ||
(_array->offset_array(orig_index) > 0 && _array->offset_array(orig_index) <= N_words), (_bot->offset_array(orig_index) > 0 && _bot->offset_array(orig_index) <= N_words),
"offset array should have been set - " "offset array should have been set - "
"orig_index offset: %u, " "orig_index offset: %u, "
"blk_start: " PTR_FORMAT ", " "blk_start: " PTR_FORMAT ", "
"boundary: " PTR_FORMAT, "boundary: " PTR_FORMAT,
(uint)_array->offset_array(orig_index), (uint)_bot->offset_array(orig_index),
p2i(blk_start), p2i(boundary)); p2i(blk_start), p2i(boundary));
for (size_t j = orig_index + 1; j <= end_index; j++) { for (size_t j = orig_index + 1; j <= end_index; j++) {
assert(_array->offset_array(j) > 0 && assert(_bot->offset_array(j) > 0 &&
_array->offset_array(j) <= _bot->offset_array(j) <=
(u_char) (N_words+BlockOffsetArray::N_powers-1), (u_char) (N_words+BlockOffsetArray::N_powers-1),
"offset array should have been set - " "offset array should have been set - "
"%u not > 0 OR %u not <= %u", "%u not > 0 OR %u not <= %u",
(uint) _array->offset_array(j), (uint) _bot->offset_array(j),
(uint) _array->offset_array(j), (uint) _bot->offset_array(j),
(uint) (N_words+BlockOffsetArray::N_powers-1)); (uint) (N_words+BlockOffsetArray::N_powers-1));
} }
#endif #endif
} }
void G1BlockOffsetArray::verify() const { void G1BlockOffsetTablePart::verify() const {
assert(gsp()->bottom() < gsp()->top(), "Only non-empty regions should be verified."); assert(_space->bottom() < _space->top(), "Only non-empty regions should be verified.");
size_t start_card = _array->index_for(gsp()->bottom()); size_t start_card = _bot->index_for(_space->bottom());
size_t end_card = _array->index_for(gsp()->top() - 1); size_t end_card = _bot->index_for(_space->top() - 1);
for (size_t current_card = start_card; current_card < end_card; current_card++) { for (size_t current_card = start_card; current_card < end_card; current_card++) {
u_char entry = _array->offset_array(current_card); u_char entry = _bot->offset_array(current_card);
if (entry < N_words) { if (entry < N_words) {
// The entry should point to an object before the current card. Verify that // The entry should point to an object before the current card. Verify that
// it is possible to walk from that object in to the current card by just // it is possible to walk from that object in to the current card by just
// iterating over the objects following it. // iterating over the objects following it.
HeapWord* card_address = _array->address_for_index(current_card); HeapWord* card_address = _bot->address_for_index(current_card);
HeapWord* obj_end = card_address - entry; HeapWord* obj_end = card_address - entry;
while (obj_end < card_address) { while (obj_end < card_address) {
HeapWord* obj = obj_end; HeapWord* obj = obj_end;
size_t obj_size = block_size(obj); size_t obj_size = block_size(obj);
obj_end = obj + obj_size; obj_end = obj + obj_size;
guarantee(obj_end > obj && obj_end <= gsp()->top(), guarantee(obj_end > obj && obj_end <= _space->top(),
"Invalid object end. obj: " PTR_FORMAT " obj_size: " SIZE_FORMAT " obj_end: " PTR_FORMAT " top: " PTR_FORMAT, "Invalid object end. obj: " PTR_FORMAT " obj_size: " SIZE_FORMAT " obj_end: " PTR_FORMAT " top: " PTR_FORMAT,
p2i(obj), obj_size, p2i(obj_end), p2i(gsp()->top())); p2i(obj), obj_size, p2i(obj_end), p2i(_space->top()));
} }
} else { } else {
// Because we refine the BOT based on which cards are dirty there is not much we can verify here. // Because we refine the BOT based on which cards are dirty there is not much we can verify here.
@ -411,103 +356,66 @@ void G1BlockOffsetArray::verify() const {
"Going backwards beyond the start_card. start_card: " SIZE_FORMAT " current_card: " SIZE_FORMAT " backskip: " SIZE_FORMAT, "Going backwards beyond the start_card. start_card: " SIZE_FORMAT " current_card: " SIZE_FORMAT " backskip: " SIZE_FORMAT,
start_card, current_card, backskip); start_card, current_card, backskip);
HeapWord* backskip_address = _array->address_for_index(current_card - backskip); HeapWord* backskip_address = _bot->address_for_index(current_card - backskip);
guarantee(backskip_address >= gsp()->bottom(), guarantee(backskip_address >= _space->bottom(),
"Going backwards beyond bottom of the region: bottom: " PTR_FORMAT ", backskip_address: " PTR_FORMAT, "Going backwards beyond bottom of the region: bottom: " PTR_FORMAT ", backskip_address: " PTR_FORMAT,
p2i(gsp()->bottom()), p2i(backskip_address)); p2i(_space->bottom()), p2i(backskip_address));
} }
} }
} }
#ifndef PRODUCT #ifndef PRODUCT
void void
G1BlockOffsetArray::print_on(outputStream* out) { G1BlockOffsetTablePart::print_on(outputStream* out) {
size_t from_index = _array->index_for(_bottom); size_t from_index = _bot->index_for(_space->bottom());
size_t to_index = _array->index_for(_end); size_t to_index = _bot->index_for(_space->end());
out->print_cr(">> BOT for area [" PTR_FORMAT "," PTR_FORMAT ") " out->print_cr(">> BOT for area [" PTR_FORMAT "," PTR_FORMAT ") "
"cards [" SIZE_FORMAT "," SIZE_FORMAT ")", "cards [" SIZE_FORMAT "," SIZE_FORMAT ")",
p2i(_bottom), p2i(_end), from_index, to_index); p2i(_space->bottom()), p2i(_space->end()), from_index, to_index);
for (size_t i = from_index; i < to_index; ++i) { for (size_t i = from_index; i < to_index; ++i) {
out->print_cr(" entry " SIZE_FORMAT_W(8) " | " PTR_FORMAT " : %3u", out->print_cr(" entry " SIZE_FORMAT_W(8) " | " PTR_FORMAT " : %3u",
i, p2i(_array->address_for_index(i)), i, p2i(_bot->address_for_index(i)),
(uint) _array->offset_array(i)); (uint) _bot->offset_array(i));
} }
}
#endif // !PRODUCT
//////////////////////////////////////////////////////////////////////
// G1BlockOffsetArrayContigSpace
//////////////////////////////////////////////////////////////////////
HeapWord*
G1BlockOffsetArrayContigSpace::block_start_unsafe(const void* addr) {
assert(_bottom <= addr && addr < _end,
"addr must be covered by this Array");
HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
return forward_to_block_containing_addr(q, addr);
}
HeapWord*
G1BlockOffsetArrayContigSpace::
block_start_unsafe_const(const void* addr) const {
assert(_bottom <= addr && addr < _end,
"addr must be covered by this Array");
HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
HeapWord* n = q + block_size(q);
return forward_to_block_containing_addr_const(q, n, addr);
}
G1BlockOffsetArrayContigSpace::
G1BlockOffsetArrayContigSpace(G1BlockOffsetSharedArray* array,
MemRegion mr) :
G1BlockOffsetArray(array, mr)
{
_next_offset_threshold = NULL;
_next_offset_index = 0;
}
HeapWord* G1BlockOffsetArrayContigSpace::initialize_threshold_raw() {
assert(!G1CollectedHeap::heap()->is_in_reserved(_array->_offset_array),
"just checking");
_next_offset_index = _array->index_for_raw(_bottom);
_next_offset_index++;
_next_offset_threshold =
_array->address_for_index_raw(_next_offset_index);
return _next_offset_threshold;
}
void G1BlockOffsetArrayContigSpace::zero_bottom_entry_raw() {
assert(!G1CollectedHeap::heap()->is_in_reserved(_array->_offset_array),
"just checking");
size_t bottom_index = _array->index_for_raw(_bottom);
assert(_array->address_for_index_raw(bottom_index) == _bottom,
"Precondition of call");
_array->set_offset_array_raw(bottom_index, 0);
}
HeapWord* G1BlockOffsetArrayContigSpace::initialize_threshold() {
assert(!G1CollectedHeap::heap()->is_in_reserved(_array->_offset_array),
"just checking");
_next_offset_index = _array->index_for(_bottom);
_next_offset_index++;
_next_offset_threshold =
_array->address_for_index(_next_offset_index);
return _next_offset_threshold;
}
void G1BlockOffsetArrayContigSpace::set_for_starts_humongous(HeapWord* obj_top, size_t fill_size) {
// The first BOT entry should have offset 0.
reset_bot();
alloc_block(_bottom, obj_top);
if (fill_size > 0) {
alloc_block(obj_top, fill_size);
}
}
#ifndef PRODUCT
void G1BlockOffsetArrayContigSpace::print_on(outputStream* out) {
G1BlockOffsetArray::print_on(out);
out->print_cr(" next offset threshold: " PTR_FORMAT, p2i(_next_offset_threshold)); out->print_cr(" next offset threshold: " PTR_FORMAT, p2i(_next_offset_threshold));
out->print_cr(" next offset index: " SIZE_FORMAT, _next_offset_index); out->print_cr(" next offset index: " SIZE_FORMAT, _next_offset_index);
} }
#endif // !PRODUCT #endif // !PRODUCT
HeapWord* G1BlockOffsetTablePart::initialize_threshold_raw() {
assert(!G1CollectedHeap::heap()->is_in_reserved(_bot->_offset_array),
"just checking");
_next_offset_index = _bot->index_for_raw(_space->bottom());
_next_offset_index++;
_next_offset_threshold =
_bot->address_for_index_raw(_next_offset_index);
return _next_offset_threshold;
}
void G1BlockOffsetTablePart::zero_bottom_entry_raw() {
assert(!G1CollectedHeap::heap()->is_in_reserved(_bot->_offset_array),
"just checking");
size_t bottom_index = _bot->index_for_raw(_space->bottom());
assert(_bot->address_for_index_raw(bottom_index) == _space->bottom(),
"Precondition of call");
_bot->set_offset_array_raw(bottom_index, 0);
}
HeapWord* G1BlockOffsetTablePart::initialize_threshold() {
assert(!G1CollectedHeap::heap()->is_in_reserved(_bot->_offset_array),
"just checking");
_next_offset_index = _bot->index_for(_space->bottom());
_next_offset_index++;
_next_offset_threshold =
_bot->address_for_index(_next_offset_index);
return _next_offset_threshold;
}
void G1BlockOffsetTablePart::set_for_starts_humongous(HeapWord* obj_top, size_t fill_size) {
// The first BOT entry should have offset 0.
reset_bot();
alloc_block(_space->bottom(), obj_top);
if (fill_size > 0) {
alloc_block(obj_top, fill_size);
}
}

View File

@ -30,119 +30,25 @@
#include "memory/virtualspace.hpp" #include "memory/virtualspace.hpp"
#include "utilities/globalDefinitions.hpp" #include "utilities/globalDefinitions.hpp"
// The CollectedHeap type requires subtypes to implement a method
// "block_start". For some subtypes, notably generational
// systems using card-table-based write barriers, the efficiency of this
// operation may be important. Implementations of the "BlockOffsetArray"
// class may be useful in providing such efficient implementations.
//
// While generally mirroring the structure of the BOT for GenCollectedHeap,
// the following types are tailored more towards G1's uses; these should,
// however, be merged back into a common BOT to avoid code duplication
// and reduce maintenance overhead.
//
// G1BlockOffsetTable (abstract)
// -- G1BlockOffsetArray (uses G1BlockOffsetSharedArray)
// -- G1BlockOffsetArrayContigSpace
//
// A main impediment to the consolidation of this code might be the
// effect of making some of the block_start*() calls non-const as
// below. Whether that might adversely affect performance optimizations
// that compilers might normally perform in the case of non-G1
// collectors needs to be carefully investigated prior to any such
// consolidation.
// Forward declarations // Forward declarations
class G1BlockOffsetSharedArray; class G1BlockOffsetTable;
class G1OffsetTableContigSpace; class G1ContiguousSpace;
class G1BlockOffsetTable VALUE_OBJ_CLASS_SPEC {
friend class VMStructs;
protected:
// These members describe the region covered by the table.
// The space this table is covering.
HeapWord* _bottom; // == reserved.start
HeapWord* _end; // End of currently allocated region.
public:
// Initialize the table to cover the given space.
// The contents of the initial table are undefined.
G1BlockOffsetTable(HeapWord* bottom, HeapWord* end) :
_bottom(bottom), _end(end)
{
assert(_bottom <= _end, "arguments out of order");
}
// Note that the committed size of the covered space may have changed,
// so the table size might also wish to change.
virtual void resize(size_t new_word_size) = 0;
virtual void set_bottom(HeapWord* new_bottom) {
assert(new_bottom <= _end,
"new_bottom (" PTR_FORMAT ") > _end (" PTR_FORMAT ")",
p2i(new_bottom), p2i(_end));
_bottom = new_bottom;
resize(pointer_delta(_end, _bottom));
}
// Requires "addr" to be contained by a block, and returns the address of
// the start of that block. (May have side effects, namely updating of
// shared array entries that "point" too far backwards. This can occur,
// for example, when LAB allocation is used in a space covered by the
// table.)
virtual HeapWord* block_start_unsafe(const void* addr) = 0;
// Same as above, but does not have any of the possible side effects
// discussed above.
virtual HeapWord* block_start_unsafe_const(const void* addr) const = 0;
// Returns the address of the start of the block containing "addr", or
// else "null" if it is covered by no block. (May have side effects,
// namely updating of shared array entries that "point" too far
// backwards. This can occur, for example, when lab allocation is used
// in a space covered by the table.)
inline HeapWord* block_start(const void* addr);
// Same as above, but does not have any of the possible side effects
// discussed above.
inline HeapWord* block_start_const(const void* addr) const;
};
class G1BlockOffsetSharedArrayMappingChangedListener : public G1MappingChangedListener {
public:
virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled) {
// Nothing to do. The BOT is hard-wired to be part of the HeapRegion, and we cannot
// retrieve it here since this would cause firing of several asserts. The code
// executed after commit of a region already needs to do some re-initialization of
// the HeapRegion, so we combine that.
}
};
// This implementation of "G1BlockOffsetTable" divides the covered region // This implementation of "G1BlockOffsetTable" divides the covered region
// into "N"-word subregions (where "N" = 2^"LogN". An array with an entry // into "N"-word subregions (where "N" = 2^"LogN". An array with an entry
// for each such subregion indicates how far back one must go to find the // for each such subregion indicates how far back one must go to find the
// start of the chunk that includes the first word of the subregion. // start of the chunk that includes the first word of the subregion.
// //
// Each BlockOffsetArray is owned by a Space. However, the actual array // Each G1BlockOffsetTablePart is owned by a G1ContiguousSpace.
// may be shared by several BlockOffsetArrays; this is useful
// when a single resizable area (such as a generation) is divided up into
// several spaces in which contiguous allocation takes place,
// such as, for example, in G1 or in the train generation.)
// Here is the shared array type. class G1BlockOffsetTable: public CHeapObj<mtGC> {
friend class G1BlockOffsetTablePart;
class G1BlockOffsetSharedArray: public CHeapObj<mtGC> {
friend class G1BlockOffsetArray;
friend class G1BlockOffsetArrayContigSpace;
friend class VMStructs; friend class VMStructs;
private: private:
G1BlockOffsetSharedArrayMappingChangedListener _listener; // The reserved region covered by the table.
// The reserved region covered by the shared array.
MemRegion _reserved; MemRegion _reserved;
// End of the current committed region.
HeapWord* _end;
// Array for keeping offsets for retrieving object start fast given an // Array for keeping offsets for retrieving object start fast given an
// address. // address.
u_char* _offset_array; // byte array keeping backwards offsets u_char* _offset_array; // byte array keeping backwards offsets
@ -192,13 +98,9 @@ public:
N_words = 1 << LogN_words N_words = 1 << LogN_words
}; };
// Initialize the table to cover from "base" to (at least) // Initialize the Block Offset Table to cover the memory region passed
// "base + init_word_size". In the future, the table may be expanded // in the heap parameter.
// (see "resize" below) up to the size of "_reserved" (which must be at G1BlockOffsetTable(MemRegion heap, G1RegionToSpaceMapper* storage);
// least "init_word_size".) The contents of the initial table are
// undefined; it is the responsibility of the constituent
// G1BlockOffsetTable(s) to initialize cards.
G1BlockOffsetSharedArray(MemRegion heap, G1RegionToSpaceMapper* storage);
// Return the appropriate index into "_offset_array" for "p". // Return the appropriate index into "_offset_array" for "p".
inline size_t index_for(const void* p) const; inline size_t index_for(const void* p) const;
@ -213,29 +115,24 @@ public:
} }
}; };
// And here is the G1BlockOffsetTable subtype that uses the array. class G1BlockOffsetTablePart VALUE_OBJ_CLASS_SPEC {
friend class G1BlockOffsetTable;
class G1BlockOffsetArray: public G1BlockOffsetTable {
friend class G1BlockOffsetSharedArray;
friend class G1BlockOffsetArrayContigSpace;
friend class VMStructs; friend class VMStructs;
private: private:
enum SomePrivateConstants { enum SomePrivateConstants {
N_words = G1BlockOffsetSharedArray::N_words, N_words = G1BlockOffsetTable::N_words,
LogN = G1BlockOffsetSharedArray::LogN LogN = G1BlockOffsetTable::LogN
}; };
// This is the array, which can be shared by several BlockOffsetArray's // allocation boundary at which offset array must be updated
// servicing different HeapWord* _next_offset_threshold;
G1BlockOffsetSharedArray* _array; size_t _next_offset_index; // index corresponding to that boundary
// This is the global BlockOffsetTable.
G1BlockOffsetTable* _bot;
// The space that owns this subregion. // The space that owns this subregion.
G1OffsetTableContigSpace* _gsp; G1ContiguousSpace* _space;
// The portion [_unallocated_block, _sp.end()) of the space that
// is a single block known not to contain any objects.
// NOTE: See BlockOffsetArrayUseUnallocatedBlock flag.
HeapWord* _unallocated_block;
// Sets the entries // Sets the entries
// corresponding to the cards starting at "start" and ending at "end" // corresponding to the cards starting at "start" and ending at "end"
@ -246,9 +143,12 @@ private:
// that is closed: [start_index, end_index] // that is closed: [start_index, end_index]
void set_remainder_to_point_to_start_incl(size_t start, size_t end); void set_remainder_to_point_to_start_incl(size_t start, size_t end);
protected: // Zero out the entry for _bottom (offset will be zero). Does not check for availability of the
// memory first.
G1OffsetTableContigSpace* gsp() const { return _gsp; } void zero_bottom_entry_raw();
// Variant of initialize_threshold that does not check for availability of the
// memory first.
HeapWord* initialize_threshold_raw();
inline size_t block_size(const HeapWord* p) const; inline size_t block_size(const HeapWord* p) const;
@ -263,8 +163,7 @@ protected:
// next block (or the end of the space.) Return the address of the // next block (or the end of the space.) Return the address of the
// beginning of the block that contains "addr". Does so without side // beginning of the block that contains "addr". Does so without side
// effects (see, e.g., spec of block_start.) // effects (see, e.g., spec of block_start.)
inline HeapWord* inline HeapWord* forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n,
forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n,
const void* addr) const; const void* addr) const;
// "q" is a block boundary that is <= "addr"; return the address of the // "q" is a block boundary that is <= "addr"; return the address of the
@ -288,60 +187,26 @@ protected:
// starting at "*threshold_", and for any other indices crossed by the // starting at "*threshold_", and for any other indices crossed by the
// block. Updates "*threshold_" and "*index_" to correspond to the first // block. Updates "*threshold_" and "*index_" to correspond to the first
// index after the block end. // index after the block end.
void alloc_block_work2(HeapWord** threshold_, size_t* index_, void alloc_block_work(HeapWord** threshold_, size_t* index_,
HeapWord* blk_start, HeapWord* blk_end); HeapWord* blk_start, HeapWord* blk_end);
public:
// The space may not have it's bottom and top set yet, which is why the
// region is passed as a parameter. The elements of the array are
// initialized to zero.
G1BlockOffsetArray(G1BlockOffsetSharedArray* array, MemRegion mr);
// Note: this ought to be part of the constructor, but that would require
// "this" to be passed as a parameter to a member constructor for
// the containing concrete subtype of Space.
// This would be legal C++, but MS VC++ doesn't allow it.
void set_space(G1OffsetTableContigSpace* sp);
// Resets the covered region to one with the same _bottom as before but
// the "new_word_size".
void resize(size_t new_word_size);
virtual HeapWord* block_start_unsafe(const void* addr);
virtual HeapWord* block_start_unsafe_const(const void* addr) const;
void check_all_cards(size_t left_card, size_t right_card) const; void check_all_cards(size_t left_card, size_t right_card) const;
public:
// The elements of the array are initialized to zero.
G1BlockOffsetTablePart(G1BlockOffsetTable* array, G1ContiguousSpace* gsp);
void verify() const; void verify() const;
virtual void print_on(outputStream* out) PRODUCT_RETURN; // Returns the address of the start of the block containing "addr", or
}; // else "null" if it is covered by no block. (May have side effects,
// namely updating of shared array entries that "point" too far
// A subtype of BlockOffsetArray that takes advantage of the fact // backwards. This can occur, for example, when lab allocation is used
// that its underlying space is a ContiguousSpace, so that its "active" // in a space covered by the table.)
// region can be more efficiently tracked (than for a non-contiguous space). inline HeapWord* block_start(const void* addr);
class G1BlockOffsetArrayContigSpace: public G1BlockOffsetArray { // Same as above, but does not have any of the possible side effects
friend class VMStructs; // discussed above.
inline HeapWord* block_start_const(const void* addr) const;
// allocation boundary at which offset array must be updated
HeapWord* _next_offset_threshold;
size_t _next_offset_index; // index corresponding to that boundary
// Work function to be called when allocation start crosses the next
// threshold in the contig space.
void alloc_block_work1(HeapWord* blk_start, HeapWord* blk_end) {
alloc_block_work2(&_next_offset_threshold, &_next_offset_index,
blk_start, blk_end);
}
// Zero out the entry for _bottom (offset will be zero). Does not check for availability of the
// memory first.
void zero_bottom_entry_raw();
// Variant of initialize_threshold that does not check for availability of the
// memory first.
HeapWord* initialize_threshold_raw();
public:
G1BlockOffsetArrayContigSpace(G1BlockOffsetSharedArray* array, MemRegion mr);
// Initialize the threshold to reflect the first boundary after the // Initialize the threshold to reflect the first boundary after the
// bottom of the covered region. // bottom of the covered region.
@ -362,19 +227,16 @@ class G1BlockOffsetArrayContigSpace: public G1BlockOffsetArray {
// never exceeds the "_next_offset_threshold". // never exceeds the "_next_offset_threshold".
void alloc_block(HeapWord* blk_start, HeapWord* blk_end) { void alloc_block(HeapWord* blk_start, HeapWord* blk_end) {
if (blk_end > _next_offset_threshold) { if (blk_end > _next_offset_threshold) {
alloc_block_work1(blk_start, blk_end); alloc_block_work(&_next_offset_threshold, &_next_offset_index, blk_start, blk_end);
} }
} }
void alloc_block(HeapWord* blk, size_t size) { void alloc_block(HeapWord* blk, size_t size) {
alloc_block(blk, blk+size); alloc_block(blk, blk+size);
} }
HeapWord* block_start_unsafe(const void* addr);
HeapWord* block_start_unsafe_const(const void* addr) const;
void set_for_starts_humongous(HeapWord* obj_top, size_t fill_size); void set_for_starts_humongous(HeapWord* obj_top, size_t fill_size);
virtual void print_on(outputStream* out) PRODUCT_RETURN; void print_on(outputStream* out) PRODUCT_RETURN;
}; };
#endif // SHARE_VM_GC_G1_G1BLOCKOFFSETTABLE_HPP #endif // SHARE_VM_GC_G1_G1BLOCKOFFSETTABLE_HPP

View File

@ -30,34 +30,36 @@
#include "gc/shared/memset_with_concurrent_readers.hpp" #include "gc/shared/memset_with_concurrent_readers.hpp"
#include "gc/shared/space.hpp" #include "gc/shared/space.hpp"
inline HeapWord* G1BlockOffsetTable::block_start(const void* addr) { inline HeapWord* G1BlockOffsetTablePart::block_start(const void* addr) {
if (addr >= _bottom && addr < _end) { if (addr >= _space->bottom() && addr < _space->end()) {
return block_start_unsafe(addr); HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
return forward_to_block_containing_addr(q, addr);
} else { } else {
return NULL; return NULL;
} }
} }
inline HeapWord* inline HeapWord* G1BlockOffsetTablePart::block_start_const(const void* addr) const {
G1BlockOffsetTable::block_start_const(const void* addr) const { if (addr >= _space->bottom() && addr < _space->end()) {
if (addr >= _bottom && addr < _end) { HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
return block_start_unsafe_const(addr); HeapWord* n = q + block_size(q);
return forward_to_block_containing_addr_const(q, n, addr);
} else { } else {
return NULL; return NULL;
} }
} }
u_char G1BlockOffsetSharedArray::offset_array(size_t index) const { u_char G1BlockOffsetTable::offset_array(size_t index) const {
check_index(index, "index out of range"); check_index(index, "index out of range");
return _offset_array[index]; return _offset_array[index];
} }
void G1BlockOffsetSharedArray::set_offset_array(size_t index, u_char offset) { void G1BlockOffsetTable::set_offset_array(size_t index, u_char offset) {
check_index(index, "index out of range"); check_index(index, "index out of range");
set_offset_array_raw(index, offset); set_offset_array_raw(index, offset);
} }
void G1BlockOffsetSharedArray::set_offset_array(size_t index, HeapWord* high, HeapWord* low) { void G1BlockOffsetTable::set_offset_array(size_t index, HeapWord* high, HeapWord* low) {
check_index(index, "index out of range"); check_index(index, "index out of range");
assert(high >= low, "addresses out of order"); assert(high >= low, "addresses out of order");
size_t offset = pointer_delta(high, low); size_t offset = pointer_delta(high, low);
@ -65,7 +67,7 @@ void G1BlockOffsetSharedArray::set_offset_array(size_t index, HeapWord* high, He
set_offset_array(index, (u_char)offset); set_offset_array(index, (u_char)offset);
} }
void G1BlockOffsetSharedArray::set_offset_array(size_t left, size_t right, u_char offset) { void G1BlockOffsetTable::set_offset_array(size_t left, size_t right, u_char offset) {
check_index(right, "right index out of range"); check_index(right, "right index out of range");
assert(left <= right, "indexes out of order"); assert(left <= right, "indexes out of order");
size_t num_cards = right - left + 1; size_t num_cards = right - left + 1;
@ -73,11 +75,11 @@ void G1BlockOffsetSharedArray::set_offset_array(size_t left, size_t right, u_cha
} }
// Variant of index_for that does not check the index for validity. // Variant of index_for that does not check the index for validity.
inline size_t G1BlockOffsetSharedArray::index_for_raw(const void* p) const { inline size_t G1BlockOffsetTable::index_for_raw(const void* p) const {
return pointer_delta((char*)p, _reserved.start(), sizeof(char)) >> LogN; return pointer_delta((char*)p, _reserved.start(), sizeof(char)) >> LogN;
} }
inline size_t G1BlockOffsetSharedArray::index_for(const void* p) const { inline size_t G1BlockOffsetTable::index_for(const void* p) const {
char* pc = (char*)p; char* pc = (char*)p;
assert(pc >= (char*)_reserved.start() && assert(pc >= (char*)_reserved.start() &&
pc < (char*)_reserved.end(), pc < (char*)_reserved.end(),
@ -88,8 +90,7 @@ inline size_t G1BlockOffsetSharedArray::index_for(const void* p) const {
return result; return result;
} }
inline HeapWord* inline HeapWord* G1BlockOffsetTable::address_for_index(size_t index) const {
G1BlockOffsetSharedArray::address_for_index(size_t index) const {
check_index(index, "index out of range"); check_index(index, "index out of range");
HeapWord* result = address_for_index_raw(index); HeapWord* result = address_for_index_raw(index);
assert(result >= _reserved.start() && result < _reserved.end(), assert(result >= _reserved.start() && result < _reserved.end(),
@ -99,47 +100,45 @@ G1BlockOffsetSharedArray::address_for_index(size_t index) const {
return result; return result;
} }
inline size_t inline size_t G1BlockOffsetTablePart::block_size(const HeapWord* p) const {
G1BlockOffsetArray::block_size(const HeapWord* p) const { return _space->block_size(p);
return gsp()->block_size(p);
} }
inline HeapWord* inline HeapWord* G1BlockOffsetTablePart::block_at_or_preceding(const void* addr,
G1BlockOffsetArray::block_at_or_preceding(const void* addr,
bool has_max_index, bool has_max_index,
size_t max_index) const { size_t max_index) const {
assert(_array->offset_array(0) == 0, "objects can't cross covered areas"); assert(_bot->offset_array(0) == 0, "objects can't cross covered areas");
size_t index = _array->index_for(addr); size_t index = _bot->index_for(addr);
// We must make sure that the offset table entry we use is valid. If // We must make sure that the offset table entry we use is valid. If
// "addr" is past the end, start at the last known one and go forward. // "addr" is past the end, start at the last known one and go forward.
if (has_max_index) { if (has_max_index) {
index = MIN2(index, max_index); index = MIN2(index, max_index);
} }
HeapWord* q = _array->address_for_index(index); HeapWord* q = _bot->address_for_index(index);
uint offset = _array->offset_array(index); // Extend u_char to uint. uint offset = _bot->offset_array(index); // Extend u_char to uint.
while (offset >= N_words) { while (offset >= N_words) {
// The excess of the offset from N_words indicates a power of Base // The excess of the offset from N_words indicates a power of Base
// to go back by. // to go back by.
size_t n_cards_back = BlockOffsetArray::entry_to_cards_back(offset); size_t n_cards_back = BlockOffsetArray::entry_to_cards_back(offset);
q -= (N_words * n_cards_back); q -= (N_words * n_cards_back);
index -= n_cards_back; index -= n_cards_back;
offset = _array->offset_array(index); offset = _bot->offset_array(index);
} }
assert(offset < N_words, "offset too large"); assert(offset < N_words, "offset too large");
q -= offset; q -= offset;
return q; return q;
} }
inline HeapWord* inline HeapWord* G1BlockOffsetTablePart::forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n,
G1BlockOffsetArray::
forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n,
const void* addr) const { const void* addr) const {
if (addr >= gsp()->top()) return gsp()->top(); if (addr >= _space->top()) return _space->top();
while (n <= addr) { while (n <= addr) {
q = n; q = n;
oop obj = oop(q); oop obj = oop(q);
if (obj->klass_or_null() == NULL) return q; if (obj->klass_or_null() == NULL) {
return q;
}
n += block_size(q); n += block_size(q);
} }
assert(q <= n, "wrong order for q and addr"); assert(q <= n, "wrong order for q and addr");
@ -147,10 +146,11 @@ forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n,
return q; return q;
} }
inline HeapWord* inline HeapWord* G1BlockOffsetTablePart::forward_to_block_containing_addr(HeapWord* q,
G1BlockOffsetArray::forward_to_block_containing_addr(HeapWord* q,
const void* addr) { const void* addr) {
if (oop(q)->klass_or_null() == NULL) return q; if (oop(q)->klass_or_null() == NULL) {
return q;
}
HeapWord* n = q + block_size(q); HeapWord* n = q + block_size(q);
// In the normal case, where the query "addr" is a card boundary, and the // In the normal case, where the query "addr" is a card boundary, and the
// offset table chunks are the same size as cards, the block starting at // offset table chunks are the same size as cards, the block starting at

View File

@ -1745,7 +1745,7 @@ G1CollectedHeap::G1CollectedHeap(G1CollectorPolicy* policy_) :
_is_alive_closure_stw(this), _is_alive_closure_stw(this),
_ref_processor_cm(NULL), _ref_processor_cm(NULL),
_ref_processor_stw(NULL), _ref_processor_stw(NULL),
_bot_shared(NULL), _bot(NULL),
_cg1r(NULL), _cg1r(NULL),
_g1mm(NULL), _g1mm(NULL),
_refine_cte_cl(NULL), _refine_cte_cl(NULL),
@ -1906,8 +1906,8 @@ jint G1CollectedHeap::initialize() {
// Create storage for the BOT, card table, card counts table (hot card cache) and the bitmaps. // Create storage for the BOT, card table, card counts table (hot card cache) and the bitmaps.
G1RegionToSpaceMapper* bot_storage = G1RegionToSpaceMapper* bot_storage =
create_aux_memory_mapper("Block offset table", create_aux_memory_mapper("Block offset table",
G1BlockOffsetSharedArray::compute_size(g1_rs.size() / HeapWordSize), G1BlockOffsetTable::compute_size(g1_rs.size() / HeapWordSize),
G1BlockOffsetSharedArray::heap_map_factor()); G1BlockOffsetTable::heap_map_factor());
ReservedSpace cardtable_rs(G1SATBCardTableLoggingModRefBS::compute_size(g1_rs.size() / HeapWordSize)); ReservedSpace cardtable_rs(G1SATBCardTableLoggingModRefBS::compute_size(g1_rs.size() / HeapWordSize));
G1RegionToSpaceMapper* cardtable_storage = G1RegionToSpaceMapper* cardtable_storage =
@ -1945,7 +1945,7 @@ jint G1CollectedHeap::initialize() {
FreeRegionList::set_unrealistically_long_length(max_regions() + 1); FreeRegionList::set_unrealistically_long_length(max_regions() + 1);
_bot_shared = new G1BlockOffsetSharedArray(reserved_region(), bot_storage); _bot = new G1BlockOffsetTable(reserved_region(), bot_storage);
{ {
HeapWord* start = _hrm.reserved().start(); HeapWord* start = _hrm.reserved().start();

View File

@ -154,7 +154,7 @@ private:
uint _expansion_regions; uint _expansion_regions;
// The block offset table for the G1 heap. // The block offset table for the G1 heap.
G1BlockOffsetSharedArray* _bot_shared; G1BlockOffsetTable* _bot;
// Tears down the region sets / lists so that they are empty and the // Tears down the region sets / lists so that they are empty and the
// regions on the heap do not belong to a region set / list. The // regions on the heap do not belong to a region set / list. The
@ -1008,7 +1008,7 @@ public:
void iterate_dirty_card_closure(CardTableEntryClosure* cl, uint worker_i); void iterate_dirty_card_closure(CardTableEntryClosure* cl, uint worker_i);
// The shared block offset table array. // The shared block offset table array.
G1BlockOffsetSharedArray* bot_shared() const { return _bot_shared; } G1BlockOffsetTable* bot() const { return _bot; }
// Reference Processing accessors // Reference Processing accessors

View File

@ -36,5 +36,5 @@ bool G1CollectedHeap::copy_allocation_context_stats(const jint* contexts,
HeapRegion* G1CollectedHeap::new_heap_region(uint hrs_index, HeapRegion* G1CollectedHeap::new_heap_region(uint hrs_index,
MemRegion mr) { MemRegion mr) {
return new HeapRegion(hrs_index, bot_shared(), mr); return new HeapRegion(hrs_index, bot(), mr);
} }

View File

@ -97,7 +97,7 @@ ScanRSClosure::ScanRSClosure(G1ParPushHeapRSClosure* oc,
_worker_i(worker_i), _worker_i(worker_i),
_try_claimed(false) { _try_claimed(false) {
_g1h = G1CollectedHeap::heap(); _g1h = G1CollectedHeap::heap();
_bot_shared = _g1h->bot_shared(); _bot = _g1h->bot();
_ct_bs = _g1h->g1_barrier_set(); _ct_bs = _g1h->g1_barrier_set();
_block_size = MAX2<size_t>(G1RSetScanBlockSize, 1); _block_size = MAX2<size_t>(G1RSetScanBlockSize, 1);
} }
@ -109,7 +109,7 @@ void ScanRSClosure::scanCard(size_t index, HeapRegion *r) {
// Set the "from" region in the closure. // Set the "from" region in the closure.
_oc->set_region(r); _oc->set_region(r);
MemRegion card_region(_bot_shared->address_for_index(index), G1BlockOffsetSharedArray::N_words); MemRegion card_region(_bot->address_for_index(index), G1BlockOffsetTable::N_words);
MemRegion pre_gc_allocated(r->bottom(), r->scan_top()); MemRegion pre_gc_allocated(r->bottom(), r->scan_top());
MemRegion mr = pre_gc_allocated.intersection(card_region); MemRegion mr = pre_gc_allocated.intersection(card_region);
if (!mr.is_empty() && !_ct_bs->is_card_claimed(index)) { if (!mr.is_empty() && !_ct_bs->is_card_claimed(index)) {
@ -153,7 +153,7 @@ bool ScanRSClosure::doHeapRegion(HeapRegion* r) {
jump_to_card = hrrs->iter_claimed_next(_block_size); jump_to_card = hrrs->iter_claimed_next(_block_size);
} }
if (current_card < jump_to_card) continue; if (current_card < jump_to_card) continue;
HeapWord* card_start = _g1h->bot_shared()->address_for_index(card_index); HeapWord* card_start = _g1h->bot()->address_for_index(card_index);
HeapRegion* card_region = _g1h->heap_region_containing(card_start); HeapRegion* card_region = _g1h->heap_region_containing(card_start);
_cards++; _cards++;

View File

@ -36,7 +36,7 @@
class BitMap; class BitMap;
class CardTableModRefBS; class CardTableModRefBS;
class G1BlockOffsetSharedArray; class G1BlockOffsetTable;
class ConcurrentG1Refine; class ConcurrentG1Refine;
class CodeBlobClosure; class CodeBlobClosure;
class G1CollectedHeap; class G1CollectedHeap;
@ -171,7 +171,7 @@ class ScanRSClosure : public HeapRegionClosure {
G1ParPushHeapRSClosure* _oc; G1ParPushHeapRSClosure* _oc;
CodeBlobClosure* _code_root_cl; CodeBlobClosure* _code_root_cl;
G1BlockOffsetSharedArray* _bot_shared; G1BlockOffsetTable* _bot;
G1SATBCardTableModRefBS *_ct_bs; G1SATBCardTableModRefBS *_ct_bs;
double _strong_code_root_scan_time_sec; double _strong_code_root_scan_time_sec;

View File

@ -153,7 +153,7 @@ void HeapRegion::setup_heap_region_size(size_t initial_heap_size, size_t max_hea
} }
void HeapRegion::reset_after_compaction() { void HeapRegion::reset_after_compaction() {
G1OffsetTableContigSpace::reset_after_compaction(); G1ContiguousSpace::reset_after_compaction();
// After a compaction the mark bitmap is invalid, so we must // After a compaction the mark bitmap is invalid, so we must
// treat all objects as being inside the unmarked area. // treat all objects as being inside the unmarked area.
zero_marked_bytes(); zero_marked_bytes();
@ -183,7 +183,6 @@ void HeapRegion::hr_clear(bool par, bool clear_space, bool locked) {
} }
zero_marked_bytes(); zero_marked_bytes();
_offsets.resize(HeapRegion::GrainWords);
init_top_at_mark_start(); init_top_at_mark_start();
if (clear_space) clear(SpaceDecorator::Mangle); if (clear_space) clear(SpaceDecorator::Mangle);
} }
@ -219,7 +218,7 @@ void HeapRegion::set_starts_humongous(HeapWord* obj_top, size_t fill_size) {
_type.set_starts_humongous(); _type.set_starts_humongous();
_humongous_start_region = this; _humongous_start_region = this;
_offsets.set_for_starts_humongous(obj_top, fill_size); _bot_part.set_for_starts_humongous(obj_top, fill_size);
} }
void HeapRegion::set_continues_humongous(HeapRegion* first_hr) { void HeapRegion::set_continues_humongous(HeapRegion* first_hr) {
@ -239,9 +238,9 @@ void HeapRegion::clear_humongous() {
} }
HeapRegion::HeapRegion(uint hrm_index, HeapRegion::HeapRegion(uint hrm_index,
G1BlockOffsetSharedArray* sharedOffsetArray, G1BlockOffsetTable* bot,
MemRegion mr) : MemRegion mr) :
G1OffsetTableContigSpace(sharedOffsetArray, mr), G1ContiguousSpace(bot),
_hrm_index(hrm_index), _hrm_index(hrm_index),
_allocation_context(AllocationContext::system()), _allocation_context(AllocationContext::system()),
_humongous_start_region(NULL), _humongous_start_region(NULL),
@ -257,7 +256,7 @@ HeapRegion::HeapRegion(uint hrm_index,
_rem_set(NULL), _recorded_rs_length(0), _predicted_elapsed_time_ms(0), _rem_set(NULL), _recorded_rs_length(0), _predicted_elapsed_time_ms(0),
_predicted_bytes_to_copy(0) _predicted_bytes_to_copy(0)
{ {
_rem_set = new HeapRegionRemSet(sharedOffsetArray, this); _rem_set = new HeapRegionRemSet(bot, this);
initialize(mr); initialize(mr);
} }
@ -265,7 +264,7 @@ HeapRegion::HeapRegion(uint hrm_index,
void HeapRegion::initialize(MemRegion mr, bool clear_space, bool mangle_space) { void HeapRegion::initialize(MemRegion mr, bool clear_space, bool mangle_space) {
assert(_rem_set->is_empty(), "Remembered set must be empty"); assert(_rem_set->is_empty(), "Remembered set must be empty");
G1OffsetTableContigSpace::initialize(mr, clear_space, mangle_space); G1ContiguousSpace::initialize(mr, clear_space, mangle_space);
hr_clear(false /*par*/, false /*clear_space*/); hr_clear(false /*par*/, false /*clear_space*/);
set_top(bottom()); set_top(bottom());
@ -773,7 +772,7 @@ void HeapRegion::verify(VerifyOption vo,
} }
if (!is_young() && !is_empty()) { if (!is_young() && !is_empty()) {
_offsets.verify(); _bot_part.verify();
} }
if (is_region_humongous) { if (is_region_humongous) {
@ -797,7 +796,7 @@ void HeapRegion::verify(VerifyOption vo,
if (p < the_end) { if (p < the_end) {
// Look up top // Look up top
HeapWord* addr_1 = p; HeapWord* addr_1 = p;
HeapWord* b_start_1 = _offsets.block_start_const(addr_1); HeapWord* b_start_1 = _bot_part.block_start_const(addr_1);
if (b_start_1 != p) { if (b_start_1 != p) {
log_info(gc, verify)("BOT look up for top: " PTR_FORMAT " " log_info(gc, verify)("BOT look up for top: " PTR_FORMAT " "
" yielded " PTR_FORMAT ", expecting " PTR_FORMAT, " yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
@ -809,7 +808,7 @@ void HeapRegion::verify(VerifyOption vo,
// Look up top + 1 // Look up top + 1
HeapWord* addr_2 = p + 1; HeapWord* addr_2 = p + 1;
if (addr_2 < the_end) { if (addr_2 < the_end) {
HeapWord* b_start_2 = _offsets.block_start_const(addr_2); HeapWord* b_start_2 = _bot_part.block_start_const(addr_2);
if (b_start_2 != p) { if (b_start_2 != p) {
log_info(gc, verify)("BOT look up for top + 1: " PTR_FORMAT " " log_info(gc, verify)("BOT look up for top + 1: " PTR_FORMAT " "
" yielded " PTR_FORMAT ", expecting " PTR_FORMAT, " yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
@ -823,7 +822,7 @@ void HeapRegion::verify(VerifyOption vo,
size_t diff = pointer_delta(the_end, p) / 2; size_t diff = pointer_delta(the_end, p) / 2;
HeapWord* addr_3 = p + diff; HeapWord* addr_3 = p + diff;
if (addr_3 < the_end) { if (addr_3 < the_end) {
HeapWord* b_start_3 = _offsets.block_start_const(addr_3); HeapWord* b_start_3 = _bot_part.block_start_const(addr_3);
if (b_start_3 != p) { if (b_start_3 != p) {
log_info(gc, verify)("BOT look up for top + diff: " PTR_FORMAT " " log_info(gc, verify)("BOT look up for top + diff: " PTR_FORMAT " "
" yielded " PTR_FORMAT ", expecting " PTR_FORMAT, " yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
@ -835,7 +834,7 @@ void HeapRegion::verify(VerifyOption vo,
// Look up end - 1 // Look up end - 1
HeapWord* addr_4 = the_end - 1; HeapWord* addr_4 = the_end - 1;
HeapWord* b_start_4 = _offsets.block_start_const(addr_4); HeapWord* b_start_4 = _bot_part.block_start_const(addr_4);
if (b_start_4 != p) { if (b_start_4 != p) {
log_info(gc, verify)("BOT look up for end - 1: " PTR_FORMAT " " log_info(gc, verify)("BOT look up for end - 1: " PTR_FORMAT " "
" yielded " PTR_FORMAT ", expecting " PTR_FORMAT, " yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
@ -860,52 +859,41 @@ void HeapRegion::prepare_for_compaction(CompactPoint* cp) {
// G1OffsetTableContigSpace code; copied from space.cpp. Hope this can go // G1OffsetTableContigSpace code; copied from space.cpp. Hope this can go
// away eventually. // away eventually.
void G1OffsetTableContigSpace::clear(bool mangle_space) { void G1ContiguousSpace::clear(bool mangle_space) {
set_top(bottom()); set_top(bottom());
_scan_top = bottom(); _scan_top = bottom();
CompactibleSpace::clear(mangle_space); CompactibleSpace::clear(mangle_space);
reset_bot(); reset_bot();
} }
void G1OffsetTableContigSpace::set_bottom(HeapWord* new_bottom) {
Space::set_bottom(new_bottom);
_offsets.set_bottom(new_bottom);
}
void G1OffsetTableContigSpace::set_end(HeapWord* new_end) {
assert(new_end == _bottom + HeapRegion::GrainWords, "set_end should only ever be set to _bottom + HeapRegion::GrainWords");
Space::set_end(new_end);
_offsets.resize(new_end - bottom());
}
#ifndef PRODUCT #ifndef PRODUCT
void G1OffsetTableContigSpace::mangle_unused_area() { void G1ContiguousSpace::mangle_unused_area() {
mangle_unused_area_complete(); mangle_unused_area_complete();
} }
void G1OffsetTableContigSpace::mangle_unused_area_complete() { void G1ContiguousSpace::mangle_unused_area_complete() {
SpaceMangler::mangle_region(MemRegion(top(), end())); SpaceMangler::mangle_region(MemRegion(top(), end()));
} }
#endif #endif
void G1OffsetTableContigSpace::print() const { void G1ContiguousSpace::print() const {
print_short(); print_short();
tty->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " tty->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", "
INTPTR_FORMAT ", " INTPTR_FORMAT ")", INTPTR_FORMAT ", " INTPTR_FORMAT ")",
p2i(bottom()), p2i(top()), p2i(_offsets.threshold()), p2i(end())); p2i(bottom()), p2i(top()), p2i(_bot_part.threshold()), p2i(end()));
} }
HeapWord* G1OffsetTableContigSpace::initialize_threshold() { HeapWord* G1ContiguousSpace::initialize_threshold() {
return _offsets.initialize_threshold(); return _bot_part.initialize_threshold();
} }
HeapWord* G1OffsetTableContigSpace::cross_threshold(HeapWord* start, HeapWord* G1ContiguousSpace::cross_threshold(HeapWord* start,
HeapWord* end) { HeapWord* end) {
_offsets.alloc_block(start, end); _bot_part.alloc_block(start, end);
return _offsets.threshold(); return _bot_part.threshold();
} }
HeapWord* G1OffsetTableContigSpace::scan_top() const { HeapWord* G1ContiguousSpace::scan_top() const {
G1CollectedHeap* g1h = G1CollectedHeap::heap(); G1CollectedHeap* g1h = G1CollectedHeap::heap();
HeapWord* local_top = top(); HeapWord* local_top = top();
OrderAccess::loadload(); OrderAccess::loadload();
@ -918,7 +906,7 @@ HeapWord* G1OffsetTableContigSpace::scan_top() const {
} }
} }
void G1OffsetTableContigSpace::record_timestamp() { void G1ContiguousSpace::record_timestamp() {
G1CollectedHeap* g1h = G1CollectedHeap::heap(); G1CollectedHeap* g1h = G1CollectedHeap::heap();
unsigned curr_gc_time_stamp = g1h->get_gc_time_stamp(); unsigned curr_gc_time_stamp = g1h->get_gc_time_stamp();
@ -935,17 +923,17 @@ void G1OffsetTableContigSpace::record_timestamp() {
} }
} }
void G1OffsetTableContigSpace::record_retained_region() { void G1ContiguousSpace::record_retained_region() {
// scan_top is the maximum address where it's safe for the next gc to // scan_top is the maximum address where it's safe for the next gc to
// scan this region. // scan this region.
_scan_top = top(); _scan_top = top();
} }
void G1OffsetTableContigSpace::safe_object_iterate(ObjectClosure* blk) { void G1ContiguousSpace::safe_object_iterate(ObjectClosure* blk) {
object_iterate(blk); object_iterate(blk);
} }
void G1OffsetTableContigSpace::object_iterate(ObjectClosure* blk) { void G1ContiguousSpace::object_iterate(ObjectClosure* blk) {
HeapWord* p = bottom(); HeapWord* p = bottom();
while (p < top()) { while (p < top()) {
if (block_is_obj(p)) { if (block_is_obj(p)) {
@ -955,17 +943,14 @@ void G1OffsetTableContigSpace::object_iterate(ObjectClosure* blk) {
} }
} }
G1OffsetTableContigSpace:: G1ContiguousSpace::G1ContiguousSpace(G1BlockOffsetTable* bot) :
G1OffsetTableContigSpace(G1BlockOffsetSharedArray* sharedOffsetArray, _bot_part(bot, this),
MemRegion mr) :
_offsets(sharedOffsetArray, mr),
_par_alloc_lock(Mutex::leaf, "OffsetTableContigSpace par alloc lock", true), _par_alloc_lock(Mutex::leaf, "OffsetTableContigSpace par alloc lock", true),
_gc_time_stamp(0) _gc_time_stamp(0)
{ {
_offsets.set_space(this);
} }
void G1OffsetTableContigSpace::initialize(MemRegion mr, bool clear_space, bool mangle_space) { void G1ContiguousSpace::initialize(MemRegion mr, bool clear_space, bool mangle_space) {
CompactibleSpace::initialize(mr, clear_space, mangle_space); CompactibleSpace::initialize(mr, clear_space, mangle_space);
_top = bottom(); _top = bottom();
_scan_top = bottom(); _scan_top = bottom();

View File

@ -115,12 +115,12 @@ public:
// The time stamps are re-initialized to zero at cleanup and at Full GCs. // The time stamps are re-initialized to zero at cleanup and at Full GCs.
// The current scheme that uses sequential unsigned ints will fail only if we have 4b // The current scheme that uses sequential unsigned ints will fail only if we have 4b
// evacuation pauses between two cleanups, which is _highly_ unlikely. // evacuation pauses between two cleanups, which is _highly_ unlikely.
class G1OffsetTableContigSpace: public CompactibleSpace { class G1ContiguousSpace: public CompactibleSpace {
friend class VMStructs; friend class VMStructs;
HeapWord* volatile _top; HeapWord* volatile _top;
HeapWord* volatile _scan_top; HeapWord* volatile _scan_top;
protected: protected:
G1BlockOffsetArrayContigSpace _offsets; G1BlockOffsetTablePart _bot_part;
Mutex _par_alloc_lock; Mutex _par_alloc_lock;
volatile unsigned _gc_time_stamp; volatile unsigned _gc_time_stamp;
// When we need to retire an allocation region, while other threads // When we need to retire an allocation region, while other threads
@ -132,14 +132,13 @@ class G1OffsetTableContigSpace: public CompactibleSpace {
HeapWord* _pre_dummy_top; HeapWord* _pre_dummy_top;
public: public:
G1OffsetTableContigSpace(G1BlockOffsetSharedArray* sharedOffsetArray, G1ContiguousSpace(G1BlockOffsetTable* bot);
MemRegion mr);
void set_top(HeapWord* value) { _top = value; } void set_top(HeapWord* value) { _top = value; }
HeapWord* top() const { return _top; } HeapWord* top() const { return _top; }
protected: protected:
// Reset the G1OffsetTableContigSpace. // Reset the G1ContiguousSpace.
virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space); virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space);
HeapWord* volatile* top_addr() { return &_top; } HeapWord* volatile* top_addr() { return &_top; }
@ -167,9 +166,6 @@ class G1OffsetTableContigSpace: public CompactibleSpace {
void object_iterate(ObjectClosure* blk); void object_iterate(ObjectClosure* blk);
void safe_object_iterate(ObjectClosure* blk); void safe_object_iterate(ObjectClosure* blk);
void set_bottom(HeapWord* value);
void set_end(HeapWord* value);
void mangle_unused_area() PRODUCT_RETURN; void mangle_unused_area() PRODUCT_RETURN;
void mangle_unused_area_complete() PRODUCT_RETURN; void mangle_unused_area_complete() PRODUCT_RETURN;
@ -213,15 +209,15 @@ class G1OffsetTableContigSpace: public CompactibleSpace {
virtual void print() const; virtual void print() const;
void reset_bot() { void reset_bot() {
_offsets.reset_bot(); _bot_part.reset_bot();
} }
void print_bot_on(outputStream* out) { void print_bot_on(outputStream* out) {
_offsets.print_on(out); _bot_part.print_on(out);
} }
}; };
class HeapRegion: public G1OffsetTableContigSpace { class HeapRegion: public G1ContiguousSpace {
friend class VMStructs; friend class VMStructs;
// Allow scan_and_forward to call (private) overrides for auxiliary functions on this class // Allow scan_and_forward to call (private) overrides for auxiliary functions on this class
template <typename SpaceType> template <typename SpaceType>
@ -233,8 +229,6 @@ class HeapRegion: public G1OffsetTableContigSpace {
// issues.) // issues.)
HeapRegionRemSet* _rem_set; HeapRegionRemSet* _rem_set;
G1BlockOffsetArrayContigSpace* offsets() { return &_offsets; }
// Auxiliary functions for scan_and_forward support. // Auxiliary functions for scan_and_forward support.
// See comments for CompactibleSpace for more information. // See comments for CompactibleSpace for more information.
inline HeapWord* scan_limit() const { inline HeapWord* scan_limit() const {
@ -330,7 +324,7 @@ class HeapRegion: public G1OffsetTableContigSpace {
public: public:
HeapRegion(uint hrm_index, HeapRegion(uint hrm_index,
G1BlockOffsetSharedArray* sharedOffsetArray, G1BlockOffsetTable* bot,
MemRegion mr); MemRegion mr);
// Initializing the HeapRegion not only resets the data structure, but also // Initializing the HeapRegion not only resets the data structure, but also

View File

@ -32,7 +32,7 @@
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
#include "runtime/atomic.inline.hpp" #include "runtime/atomic.inline.hpp"
inline HeapWord* G1OffsetTableContigSpace::allocate_impl(size_t min_word_size, inline HeapWord* G1ContiguousSpace::allocate_impl(size_t min_word_size,
size_t desired_word_size, size_t desired_word_size,
size_t* actual_size) { size_t* actual_size) {
HeapWord* obj = top(); HeapWord* obj = top();
@ -49,7 +49,7 @@ inline HeapWord* G1OffsetTableContigSpace::allocate_impl(size_t min_word_size,
} }
} }
inline HeapWord* G1OffsetTableContigSpace::par_allocate_impl(size_t min_word_size, inline HeapWord* G1ContiguousSpace::par_allocate_impl(size_t min_word_size,
size_t desired_word_size, size_t desired_word_size,
size_t* actual_size) { size_t* actual_size) {
do { do {
@ -73,22 +73,22 @@ inline HeapWord* G1OffsetTableContigSpace::par_allocate_impl(size_t min_word_siz
} while (true); } while (true);
} }
inline HeapWord* G1OffsetTableContigSpace::allocate(size_t min_word_size, inline HeapWord* G1ContiguousSpace::allocate(size_t min_word_size,
size_t desired_word_size, size_t desired_word_size,
size_t* actual_size) { size_t* actual_size) {
HeapWord* res = allocate_impl(min_word_size, desired_word_size, actual_size); HeapWord* res = allocate_impl(min_word_size, desired_word_size, actual_size);
if (res != NULL) { if (res != NULL) {
_offsets.alloc_block(res, *actual_size); _bot_part.alloc_block(res, *actual_size);
} }
return res; return res;
} }
inline HeapWord* G1OffsetTableContigSpace::allocate(size_t word_size) { inline HeapWord* G1ContiguousSpace::allocate(size_t word_size) {
size_t temp; size_t temp;
return allocate(word_size, word_size, &temp); return allocate(word_size, word_size, &temp);
} }
inline HeapWord* G1OffsetTableContigSpace::par_allocate(size_t word_size) { inline HeapWord* G1ContiguousSpace::par_allocate(size_t word_size) {
size_t temp; size_t temp;
return par_allocate(word_size, word_size, &temp); return par_allocate(word_size, word_size, &temp);
} }
@ -96,20 +96,20 @@ inline HeapWord* G1OffsetTableContigSpace::par_allocate(size_t word_size) {
// Because of the requirement of keeping "_offsets" up to date with the // Because of the requirement of keeping "_offsets" up to date with the
// allocations, we sequentialize these with a lock. Therefore, best if // allocations, we sequentialize these with a lock. Therefore, best if
// this is used for larger LAB allocations only. // this is used for larger LAB allocations only.
inline HeapWord* G1OffsetTableContigSpace::par_allocate(size_t min_word_size, inline HeapWord* G1ContiguousSpace::par_allocate(size_t min_word_size,
size_t desired_word_size, size_t desired_word_size,
size_t* actual_size) { size_t* actual_size) {
MutexLocker x(&_par_alloc_lock); MutexLocker x(&_par_alloc_lock);
return allocate(min_word_size, desired_word_size, actual_size); return allocate(min_word_size, desired_word_size, actual_size);
} }
inline HeapWord* G1OffsetTableContigSpace::block_start(const void* p) { inline HeapWord* G1ContiguousSpace::block_start(const void* p) {
return _offsets.block_start(p); return _bot_part.block_start(p);
} }
inline HeapWord* inline HeapWord*
G1OffsetTableContigSpace::block_start_const(const void* p) const { G1ContiguousSpace::block_start_const(const void* p) const {
return _offsets.block_start_const(p); return _bot_part.block_start_const(p);
} }
inline bool inline bool

View File

@ -687,9 +687,9 @@ OtherRegionsTable::do_cleanup_work(HRRSCleanupTask* hrrs_cleanup_task) {
_sparse_table.do_cleanup_work(hrrs_cleanup_task); _sparse_table.do_cleanup_work(hrrs_cleanup_task);
} }
HeapRegionRemSet::HeapRegionRemSet(G1BlockOffsetSharedArray* bosa, HeapRegionRemSet::HeapRegionRemSet(G1BlockOffsetTable* bot,
HeapRegion* hr) HeapRegion* hr)
: _bosa(bosa), : _bot(bot),
_m(Mutex::leaf, FormatBuffer<128>("HeapRegionRemSet lock #%u", hr->hrm_index()), true, Monitor::_safepoint_check_never), _m(Mutex::leaf, FormatBuffer<128>("HeapRegionRemSet lock #%u", hr->hrm_index()), true, Monitor::_safepoint_check_never),
_code_roots(), _other_regions(hr, &_m), _iter_state(Unclaimed), _iter_claimed(0) { _code_roots(), _other_regions(hr, &_m), _iter_state(Unclaimed), _iter_claimed(0) {
reset_for_par_iteration(); reset_for_par_iteration();
@ -728,8 +728,7 @@ void HeapRegionRemSet::print() {
HeapRegionRemSetIterator iter(this); HeapRegionRemSetIterator iter(this);
size_t card_index; size_t card_index;
while (iter.has_next(card_index)) { while (iter.has_next(card_index)) {
HeapWord* card_start = HeapWord* card_start = _bot->address_for_index(card_index);
G1CollectedHeap::heap()->bot_shared()->address_for_index(card_index);
tty->print_cr(" Card " PTR_FORMAT, p2i(card_start)); tty->print_cr(" Card " PTR_FORMAT, p2i(card_start));
} }
if (iter.n_yielded() != occupied()) { if (iter.n_yielded() != occupied()) {
@ -825,7 +824,7 @@ HeapRegionRemSetIterator:: HeapRegionRemSetIterator(HeapRegionRemSet* hrrs) :
_hrrs(hrrs), _hrrs(hrrs),
_g1h(G1CollectedHeap::heap()), _g1h(G1CollectedHeap::heap()),
_coarse_map(&hrrs->_other_regions._coarse_map), _coarse_map(&hrrs->_other_regions._coarse_map),
_bosa(hrrs->_bosa), _bot(hrrs->_bot),
_is(Sparse), _is(Sparse),
// Set these values so that we increment to the first region. // Set these values so that we increment to the first region.
_coarse_cur_region_index(-1), _coarse_cur_region_index(-1),
@ -852,7 +851,7 @@ bool HeapRegionRemSetIterator::coarse_has_next(size_t& card_index) {
_coarse_cur_region_cur_card = 0; _coarse_cur_region_cur_card = 0;
HeapWord* r_bot = HeapWord* r_bot =
_g1h->region_at((uint) _coarse_cur_region_index)->bottom(); _g1h->region_at((uint) _coarse_cur_region_index)->bottom();
_cur_region_card_offset = _bosa->index_for(r_bot); _cur_region_card_offset = _bot->index_for(r_bot);
} else { } else {
return false; return false;
} }
@ -893,7 +892,7 @@ void HeapRegionRemSetIterator::switch_to_prt(PerRegionTable* prt) {
_fine_cur_prt = prt; _fine_cur_prt = prt;
HeapWord* r_bot = _fine_cur_prt->hr()->bottom(); HeapWord* r_bot = _fine_cur_prt->hr()->bottom();
_cur_region_card_offset = _bosa->index_for(r_bot); _cur_region_card_offset = _bot->index_for(r_bot);
// The bitmap scan for the PRT always scans from _cur_region_cur_card + 1. // The bitmap scan for the PRT always scans from _cur_region_cur_card + 1.
// To avoid special-casing this start case, and not miss the first bitmap // To avoid special-casing this start case, and not miss the first bitmap
@ -1001,7 +1000,7 @@ void HeapRegionRemSet::test() {
size_t card_index; size_t card_index;
while (iter.has_next(card_index)) { while (iter.has_next(card_index)) {
HeapWord* card_start = HeapWord* card_start =
G1CollectedHeap::heap()->bot_shared()->address_for_index(card_index); G1CollectedHeap::heap()->bot()->address_for_index(card_index);
tty->print_cr(" Card " PTR_FORMAT ".", p2i(card_start)); tty->print_cr(" Card " PTR_FORMAT ".", p2i(card_start));
sum++; sum++;
} }

View File

@ -34,7 +34,7 @@
// abstractly, in terms of what the "BlockOffsetTable" in use can parse. // abstractly, in terms of what the "BlockOffsetTable" in use can parse.
class G1CollectedHeap; class G1CollectedHeap;
class G1BlockOffsetSharedArray; class G1BlockOffsetTable;
class HeapRegion; class HeapRegion;
class HeapRegionRemSetIterator; class HeapRegionRemSetIterator;
class PerRegionTable; class PerRegionTable;
@ -174,7 +174,7 @@ class HeapRegionRemSet : public CHeapObj<mtGC> {
friend class HeapRegionRemSetIterator; friend class HeapRegionRemSetIterator;
private: private:
G1BlockOffsetSharedArray* _bosa; G1BlockOffsetTable* _bot;
// A set of code blobs (nmethods) whose code contains pointers into // A set of code blobs (nmethods) whose code contains pointers into
// the region that owns this RSet. // the region that owns this RSet.
@ -189,7 +189,7 @@ private:
volatile size_t _iter_claimed; volatile size_t _iter_claimed;
public: public:
HeapRegionRemSet(G1BlockOffsetSharedArray* bosa, HeapRegion* hr); HeapRegionRemSet(G1BlockOffsetTable* bot, HeapRegion* hr);
static void setup_remset_size(); static void setup_remset_size();
@ -350,7 +350,7 @@ class HeapRegionRemSetIterator : public StackObj {
// Local caching of HRRS fields. // Local caching of HRRS fields.
const BitMap* _coarse_map; const BitMap* _coarse_map;
G1BlockOffsetSharedArray* _bosa; G1BlockOffsetTable* _bot;
G1CollectedHeap* _g1h; G1CollectedHeap* _g1h;
// The number of cards yielded since initialization. // The number of cards yielded since initialization.

View File

@ -381,17 +381,17 @@ void FreeRegionList_test() {
MemRegion heap(NULL, num_regions_in_test * HeapRegion::GrainWords); MemRegion heap(NULL, num_regions_in_test * HeapRegion::GrainWords);
// Allocate a fake BOT because the HeapRegion constructor initializes // Allocate a fake BOT because the HeapRegion constructor initializes
// the BOT. // the BOT.
size_t bot_size = G1BlockOffsetSharedArray::compute_size(heap.word_size()); size_t bot_size = G1BlockOffsetTable::compute_size(heap.word_size());
HeapWord* bot_data = NEW_C_HEAP_ARRAY(HeapWord, bot_size, mtGC); HeapWord* bot_data = NEW_C_HEAP_ARRAY(HeapWord, bot_size, mtGC);
ReservedSpace bot_rs(G1BlockOffsetSharedArray::compute_size(heap.word_size())); ReservedSpace bot_rs(G1BlockOffsetTable::compute_size(heap.word_size()));
G1RegionToSpaceMapper* bot_storage = G1RegionToSpaceMapper* bot_storage =
G1RegionToSpaceMapper::create_mapper(bot_rs, G1RegionToSpaceMapper::create_mapper(bot_rs,
bot_rs.size(), bot_rs.size(),
os::vm_page_size(), os::vm_page_size(),
HeapRegion::GrainBytes, HeapRegion::GrainBytes,
G1BlockOffsetSharedArray::N_bytes, G1BlockOffsetTable::N_bytes,
mtGC); mtGC);
G1BlockOffsetSharedArray oa(heap, bot_storage); G1BlockOffsetTable bot(heap, bot_storage);
bot_storage->commit_regions(0, num_regions_in_test); bot_storage->commit_regions(0, num_regions_in_test);
// Set up memory regions for the heap regions. // Set up memory regions for the heap regions.
@ -401,11 +401,11 @@ void FreeRegionList_test() {
MemRegion mr3(mr2.end(), HeapRegion::GrainWords); MemRegion mr3(mr2.end(), HeapRegion::GrainWords);
MemRegion mr4(mr3.end(), HeapRegion::GrainWords); MemRegion mr4(mr3.end(), HeapRegion::GrainWords);
HeapRegion hr0(0, &oa, mr0); HeapRegion hr0(0, &bot, mr0);
HeapRegion hr1(1, &oa, mr1); HeapRegion hr1(1, &bot, mr1);
HeapRegion hr2(2, &oa, mr2); HeapRegion hr2(2, &bot, mr2);
HeapRegion hr3(3, &oa, mr3); HeapRegion hr3(3, &bot, mr3);
HeapRegion hr4(4, &oa, mr4); HeapRegion hr4(4, &bot, mr4);
l.add_ordered(&hr1); l.add_ordered(&hr1);
l.add_ordered(&hr0); l.add_ordered(&hr0);
l.add_ordered(&hr3); l.add_ordered(&hr3);

View File

@ -35,7 +35,7 @@
static_field(HeapRegion, GrainBytes, size_t) \ static_field(HeapRegion, GrainBytes, size_t) \
static_field(HeapRegion, LogOfHRGrainBytes, int) \ static_field(HeapRegion, LogOfHRGrainBytes, int) \
\ \
nonstatic_field(G1OffsetTableContigSpace, _top, HeapWord* volatile) \ nonstatic_field(G1ContiguousSpace, _top, HeapWord* volatile) \
\ \
nonstatic_field(G1HeapRegionTable, _base, address) \ nonstatic_field(G1HeapRegionTable, _base, address) \
nonstatic_field(G1HeapRegionTable, _length, size_t) \ nonstatic_field(G1HeapRegionTable, _length, size_t) \
@ -96,8 +96,8 @@
\ \
declare_type(G1CollectedHeap, CollectedHeap) \ declare_type(G1CollectedHeap, CollectedHeap) \
\ \
declare_type(G1OffsetTableContigSpace, CompactibleSpace) \ declare_type(G1ContiguousSpace, CompactibleSpace) \
declare_type(HeapRegion, G1OffsetTableContigSpace) \ declare_type(HeapRegion, G1ContiguousSpace) \
declare_toplevel_type(HeapRegionManager) \ declare_toplevel_type(HeapRegionManager) \
declare_toplevel_type(HeapRegionSetBase) \ declare_toplevel_type(HeapRegionSetBase) \
declare_toplevel_type(G1MonitoringSupport) \ declare_toplevel_type(G1MonitoringSupport) \

View File

@ -248,7 +248,7 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class BlockOffsetArray: public BlockOffsetTable { class BlockOffsetArray: public BlockOffsetTable {
friend class VMStructs; friend class VMStructs;
friend class G1BlockOffsetArray; // temp. until we restructure and cleanup friend class G1BlockOffsetTablePart; // temp. until we restructure and cleanup
protected: protected:
// The following enums are used by do_block_internal() below // The following enums are used by do_block_internal() below
enum Action { enum Action {