/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp"
#include "oops/oop.inline.hpp"
#include "services/memTracker.hpp"
//////////////////////////////////////////////////////////////////////
// G1BlockOffsetSharedArray
//////////////////////////////////////////////////////////////////////
{
if (!rs.is_reserved()) {
vm_exit_during_initialization("Could not reserve enough space for heap offset array");
}
vm_exit_during_initialization("Could not reserve enough space for heap offset array");
}
if (TraceBlockOffsetTable) {
" rs.base(): " INTPTR_FORMAT
" rs.size(): " INTPTR_FORMAT
" rs end(): " INTPTR_FORMAT,
" _vs.low_boundary(): " INTPTR_FORMAT
" _vs.high_boundary(): " INTPTR_FORMAT,
_vs.low_boundary(),
_vs.high_boundary());
}
}
// Do better than this for Merlin
}
// Initialization of the contents is left to the
// G1BlockOffsetArray that uses it.
} else {
if (delta == 0) return;
}
}
}
//////////////////////////////////////////////////////////////////////
// G1BlockOffsetArray
//////////////////////////////////////////////////////////////////////
if (!_init_to_zero) {
// initialize cards to point back to mr.start()
}
}
}
// The arguments follow the normal convention of denoting
// a right-open interval: [start, end)
void
// The start address is equal to the end address (or to
// the right of the end address) so there are not cards
// that need to be updated..
return;
}
// Write the backskip value for each region.
//
// offset
// card 2nd 3rd
// | +- 1st | |
// v v v v
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-
// |x|0|0|0|0|0|0|0|1|1|1|1|1|1| ... |1|1|1|1|2|2|2|2|2|2| ...
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-
// 11 19 75
// 12
//
// offset card is the card that points to the start of an object
// x - offset value of offset card
// 1st - start of first logarithmic region
// 0 corresponds to logarithmic value N_words + 0 and 2**(3 * 0) = 1
// 2nd - start of second logarithmic region
// 1 corresponds to logarithmic value N_words + 1 and 2**(3 * 1) = 8
// 3rd - start of third logarithmic region
// 2 corresponds to logarithmic value N_words + 2 and 2**(3 * 2) = 64
//
// integer below the block offset entry is an example of
// the index of the entry
//
// Given an address,
// Find the index for the address
// Find the block offset table entry
// Convert the entry to a back slide
// (e.g., with today's, offset = 0x81 =>
// back slip = 2**(3*(0x81 - N_words)) = 2**3) = 8
// Move back N (e.g., 8) entries and repeat with the
// value of the new entry
//
}
// 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()
// above.
void
if (start_card > end_card) {
return;
}
"Offset card has an unexpected value");
for (int i = 0; i < BlockOffsetArray::N_powers; i++) {
// -1 so that the the card with the actual offset is counted. Another -1
// so that the reach ends in this region and not at the start
// of the next.
break;
}
}
}
// The block [blk_start, blk_end) has been allocated;
// adjust the block offset table to represent this information;
// right-open interval: [blk_start, blk_end)
void
}
// Adjust BOT to show that a previously whole block has been split
// into two.
// Verify that the BOT shows [blk, blk + blk_size) to be one block.
// Update the BOT to indicate that [blk + left_blk_size, blk + blk_size)
// is one single block.
}
// Action_mark - update the BOT for the block [blk_start, blk_end).
// Current typical use is for splitting a block.
// Action_single - update the BOT for an allocation.
// Action_verify - BOT verification.
"reference must be into the heap");
"limit must be within the heap");
// This is optimized to make the test fast, assuming we only rarely
// cross boundaries.
// Calculate the last card boundary preceding end of blk
// blk starts at or crosses a boundary
// Calculate index of card on which blk begins
// Index of card on which blk ends
// Start address of card on which blk begins
// blk starts strictly after boundary
// adjust card boundary and start_index forward to next card
start_index++;
}
switch (action) {
case Action_mark: {
if (init_to_zero()) {
break;
} // Else fall through to the next case
}
case Action_single: {
// We have finished marking the "offset card". We need to now
// mark the subsequent cards that this blk spans.
if (start_index < end_index) {
}
break;
}
case Action_check: {
// We have finished checking the "offset card". We need to now
// check the subsequent cards that this blk spans.
break;
}
default:
}
}
}
// The card-interval [start_card, end_card] is a closed interval; this
// is an expensive check -- use with care and only under protection of
// suitable flag.
if (end_card < start_card) {
return;
}
err_msg("Should be in logarithmic region - "
"N_words: " UINT32_FORMAT,
}
if (landing_card >= start_card) {
"entry: " UINT32_FORMAT,
} else {
// Note that N_words is the maximum offset value
"N_words: " UINT32_FORMAT,
}
}
}
// The range [blk_start, blk_end) represents a single contiguous block
// of storage; modify the block offset table to represent this
// information; Right-open interval: [blk_start, blk_end)
// NOTE: this method does _not_ adjust _unallocated_block.
void
}
// Mark the BOT such that if [blk_start, blk_end) straddles a card
// boundary, the card following the first such boundary is marked
// with the appropriate offset.
// NOTE: this method does _not_ adjust _unallocated_block or
// any cards subsequent to the first one.
void
}
"addr must be covered by this Array");
// Must read this exactly once because it can be modified by parallel
// allocation.
return ub;
}
// Otherwise, find the block start using the table.
return forward_to_block_containing_addr(q, addr);
}
// This duplicates a little code from the above: unavoidable.
"addr must be covered by this Array");
// Must read this exactly once because it can be modified by parallel
// allocation.
return ub;
}
// Otherwise, find the block start using the table.
return forward_to_block_containing_addr_const(q, n, addr);
}
HeapWord* n,
const void* addr) {
// We're not in the normal case. We need to handle an important subcase
// here: LAB allocation. An allocation previously recorded in the
// offset table was actually a lab allocation, and was divided into
// several objects subsequently. Fix this situation as we answer the
// query, by updating entries as we cross them.
// 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
// set to 0). If the object crosses the boundary -- start from the next card.
while (next_boundary < addr) {
while (n <= next_boundary) {
q = n;
}
// [q, n) is the block that crosses the boundary.
}
} else {
while (next_boundary < addr) {
while (n <= next_boundary) {
q = n;
n += _sp->block_size(q);
}
// [q, n) is the block that crosses the boundary.
}
}
return forward_to_block_containing_addr_const(q, n, addr);
}
"addr must be covered by this Array");
// Must read this exactly once because it can be modified by parallel
// allocation.
return ub;
}
// Otherwise, find the block start using the table, but taking
// on the cards themsleves.
"arg should be start of card");
do {
q -= offset;
return q;
}
// Note that the committed size of the covered space may have changed,
// so the table size might also wish to change.
// verify that the old and new boundaries are also card boundaries
"_end not a card boundary");
"new _end would not be a card boundary");
// set all the newly added cards
}
}
}
//
// threshold_
// | _index_
// v v
// +-------+-------+-------+-------+-------+
// | i-1 | i | i+1 | i+2 | i+3 |
// +-------+-------+-------+-------+-------+
// ( ^ ]
// block-start
//
"phantom block");
"offset should be <= BlockOffsetSharedArray::N");
"reference must be into the heap");
"limit must be within the heap");
"index must agree with threshold");
// 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.
// We need to now mark the subsequent cards that this blk spans.
// Index of card on which blk ends.
// Are there more cards left to be updated?
// Calculate rem_end this way because end_index
// may be the last valid index in the covered region.
}
// Calculate threshold_ this way because end_index
// may be the last valid index in the covered region.
// index_ and threshold_ updated here.
*threshold_ = threshold;
#ifdef ASSERT
// The offset can be 0 if the block starts on a boundary. That
// is checked by an assertion above.
err_msg("offset array should have been set - "
"boundary: " PTR_FORMAT,
_array->offset_array(j) <=
err_msg("offset array should have been set - "
UINT32_FORMAT " not > 0 OR "
_array->offset_array(j),
_array->offset_array(j),
}
#endif
}
bool
// If the object is not on a card boundary the BOT entry of the
// first card should point to another object so we should not
// check that one.
first_card += 1;
}
if (block_start != obj_start) {
return false;
}
}
return true;
}
#ifndef PRODUCT
void
i, _array->address_for_index(i),
}
}
#endif // !PRODUCT
//////////////////////////////////////////////////////////////////////
// G1BlockOffsetArrayContigSpace
//////////////////////////////////////////////////////////////////////
"addr must be covered by this Array");
return forward_to_block_containing_addr(q, addr);
}
"addr must be covered by this Array");
return forward_to_block_containing_addr_const(q, n, addr);
}
{
_next_offset_index = 0;
}
"just checking");
return _next_offset_threshold;
}
"just checking");
"Precondition of call");
}
void
// The first BOT entry should have offset 0.
}
#ifndef PRODUCT
void
}
#endif // !PRODUCT