8146694: Break out shared constants and static BOT functions.
Reviewed-by: jwilhelm, tbenson
--- a/hotspot/src/share/vm/gc/g1/g1AllocRegion.cpp Sun Jan 10 20:02:50 2016 -0500
+++ b/hotspot/src/share/vm/gc/g1/g1AllocRegion.cpp Mon Jan 11 09:14:01 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -277,7 +277,7 @@
// 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.
HeapWord* top = cur->top();
- HeapWord* aligned_top = (HeapWord*)align_ptr_up(top, G1BlockOffsetTable::N_bytes);
+ HeapWord* aligned_top = (HeapWord*)align_ptr_up(top, BOTConstants::N_bytes);
size_t to_allocate_words = pointer_delta(aligned_top, top, HeapWordSize);
--- a/hotspot/src/share/vm/gc/g1/g1BlockOffsetTable.cpp Sun Jan 10 20:02:50 2016 -0500
+++ b/hotspot/src/share/vm/gc/g1/g1BlockOffsetTable.cpp Mon Jan 11 09:14:01 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -53,14 +53,14 @@
bool G1BlockOffsetTable::is_card_boundary(HeapWord* p) const {
assert(p >= _reserved.start(), "just checking");
size_t delta = pointer_delta(p, _reserved.start());
- return (delta & right_n_bits(LogN_words)) == (size_t)NoBits;
+ return (delta & right_n_bits((int)BOTConstants::LogN_words)) == (size_t)NoBits;
}
#ifdef ASSERT
void G1BlockOffsetTable::check_index(size_t index, const char* msg) const {
- assert((index) < (_reserved.word_size() >> LogN_words),
+ assert((index) < (_reserved.word_size() >> BOTConstants::LogN_words),
"%s - index: " SIZE_FORMAT ", _vs.committed_size: " SIZE_FORMAT,
- msg, (index), (_reserved.word_size() >> LogN_words));
+ msg, (index), (_reserved.word_size() >> BOTConstants::LogN_words));
assert(G1CollectedHeap::heap()->is_in_exact(address_for_index_raw(index)),
"Index " SIZE_FORMAT " corresponding to " PTR_FORMAT
" (%u) is not in committed area.",
@@ -128,7 +128,7 @@
size_t start_card = _bot->index_for(start);
size_t end_card = _bot->index_for(end-1);
assert(start ==_bot->address_for_index(start_card), "Precondition");
- assert(end ==_bot->address_for_index(end_card)+N_words, "Precondition");
+ assert(end ==_bot->address_for_index(end_card)+BOTConstants::N_words, "Precondition");
set_remainder_to_point_to_start_incl(start_card, end_card); // closed interval
}
@@ -140,16 +140,16 @@
return;
}
assert(start_card > _bot->index_for(_space->bottom()), "Cannot be first card");
- assert(_bot->offset_array(start_card-1) <= N_words,
+ assert(_bot->offset_array(start_card-1) <= BOTConstants::N_words,
"Offset card has an unexpected value");
size_t start_card_for_region = start_card;
u_char offset = max_jubyte;
- for (int i = 0; i < BlockOffsetArray::N_powers; i++) {
+ for (uint i = 0; i < BOTConstants::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.
- size_t reach = start_card - 1 + (BlockOffsetArray::power_to_cards_back(i+1) - 1);
- offset = N_words + i;
+ size_t reach = start_card - 1 + (BOTConstants::power_to_cards_back(i+1) - 1);
+ offset = BOTConstants::N_words + i;
if (reach >= end_card) {
_bot->set_offset_array(start_card_for_region, end_card, offset);
start_card_for_region = reach + 1;
@@ -170,18 +170,18 @@
if (end_card < start_card) {
return;
}
- guarantee(_bot->offset_array(start_card) == N_words, "Wrong value in second card");
+ guarantee(_bot->offset_array(start_card) == BOTConstants::N_words, "Wrong value in second card");
for (size_t c = start_card + 1; c <= end_card; c++ /* yeah! */) {
u_char entry = _bot->offset_array(c);
- if (c - start_card > BlockOffsetArray::power_to_cards_back(1)) {
- guarantee(entry > N_words,
+ if (c - start_card > BOTConstants::power_to_cards_back(1)) {
+ guarantee(entry > BOTConstants::N_words,
"Should be in logarithmic region - "
"entry: %u, "
"_array->offset_array(c): %u, "
"N_words: %u",
- (uint)entry, (uint)_bot->offset_array(c), (uint)N_words);
+ (uint)entry, (uint)_bot->offset_array(c), BOTConstants::N_words);
}
- size_t backskip = BlockOffsetArray::entry_to_cards_back(entry);
+ size_t backskip = BOTConstants::entry_to_cards_back(entry);
size_t landing_card = c - backskip;
guarantee(landing_card >= (start_card - 1), "Inv");
if (landing_card >= start_card) {
@@ -192,10 +192,10 @@
} else {
guarantee(landing_card == start_card - 1, "Tautology");
// Note that N_words is the maximum offset value
- guarantee(_bot->offset_array(landing_card) <= N_words,
+ guarantee(_bot->offset_array(landing_card) <= BOTConstants::N_words,
"landing card offset: %u, "
"N_words: %u",
- (uint)_bot->offset_array(landing_card), (uint)N_words);
+ (uint)_bot->offset_array(landing_card), (uint)BOTConstants::N_words);
}
}
}
@@ -217,7 +217,7 @@
// Calculate a consistent next boundary. If "n" is not at the boundary
// already, step to the boundary.
HeapWord* next_boundary = _bot->address_for_index(n_index) +
- (n_index == next_index ? 0 : N_words);
+ (n_index == next_index ? 0 : BOTConstants::N_words);
assert(next_boundary <= _bot->_reserved.end(),
"next_boundary is beyond the end of the covered region "
" next_boundary " PTR_FORMAT " _array->_end " PTR_FORMAT,
@@ -257,13 +257,13 @@
"phantom block");
assert(blk_end > threshold, "should be past threshold");
assert(blk_start <= threshold, "blk_start should be at or before threshold");
- assert(pointer_delta(threshold, blk_start) <= N_words,
+ assert(pointer_delta(threshold, blk_start) <= BOTConstants::N_words,
"offset should be <= BlockOffsetSharedArray::N");
assert(G1CollectedHeap::heap()->is_in_reserved(blk_start),
"reference must be into the heap");
assert(G1CollectedHeap::heap()->is_in_reserved(blk_end-1),
"limit must be within the heap");
- assert(threshold == _bot->_reserved.start() + index*N_words,
+ assert(threshold == _bot->_reserved.start() + index*BOTConstants::N_words,
"index must agree with threshold");
DEBUG_ONLY(size_t orig_index = index;)
@@ -283,14 +283,14 @@
HeapWord* rem_st = _bot->address_for_index(index + 1);
// Calculate rem_end this way because end_index
// may be the last valid index in the covered region.
- HeapWord* rem_end = _bot->address_for_index(end_index) + N_words;
+ HeapWord* rem_end = _bot->address_for_index(end_index) + BOTConstants::N_words;
set_remainder_to_point_to_start(rem_st, rem_end);
}
index = end_index + 1;
// Calculate threshold_ this way because end_index
// may be the last valid index in the covered region.
- threshold = _bot->address_for_index(end_index) + N_words;
+ threshold = _bot->address_for_index(end_index) + BOTConstants::N_words;
assert(threshold >= blk_end, "Incorrect offset threshold");
// index_ and threshold_ updated here.
@@ -303,7 +303,7 @@
size_t start_index = _bot->index_for(blk_start);
HeapWord* boundary = _bot->address_for_index(start_index);
assert((_bot->offset_array(orig_index) == 0 && blk_start == boundary) ||
- (_bot->offset_array(orig_index) > 0 && _bot->offset_array(orig_index) <= N_words),
+ (_bot->offset_array(orig_index) > 0 && _bot->offset_array(orig_index) <= BOTConstants::N_words),
"offset array should have been set - "
"orig_index offset: %u, "
"blk_start: " PTR_FORMAT ", "
@@ -313,12 +313,12 @@
for (size_t j = orig_index + 1; j <= end_index; j++) {
assert(_bot->offset_array(j) > 0 &&
_bot->offset_array(j) <=
- (u_char) (N_words+BlockOffsetArray::N_powers-1),
+ (u_char) (BOTConstants::N_words+BOTConstants::N_powers-1),
"offset array should have been set - "
"%u not > 0 OR %u not <= %u",
(uint) _bot->offset_array(j),
(uint) _bot->offset_array(j),
- (uint) (N_words+BlockOffsetArray::N_powers-1));
+ (uint) (BOTConstants::N_words+BOTConstants::N_powers-1));
}
#endif
}
@@ -330,7 +330,7 @@
for (size_t current_card = start_card; current_card < end_card; current_card++) {
u_char entry = _bot->offset_array(current_card);
- if (entry < N_words) {
+ if (entry < BOTConstants::N_words) {
// 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
// iterating over the objects following it.
@@ -348,7 +348,7 @@
// Because we refine the BOT based on which cards are dirty there is not much we can verify here.
// We need to make sure that we are going backwards and that we don't pass the start of the
// corresponding heap region. But that is about all we can verify.
- size_t backskip = BlockOffsetArray::entry_to_cards_back(entry);
+ size_t backskip = BOTConstants::entry_to_cards_back(entry);
guarantee(backskip >= 1, "Must be going back at least one card.");
size_t max_backskip = current_card - start_card;
--- a/hotspot/src/share/vm/gc/g1/g1BlockOffsetTable.hpp Sun Jan 10 20:02:50 2016 -0500
+++ b/hotspot/src/share/vm/gc/g1/g1BlockOffsetTable.hpp Mon Jan 11 09:14:01 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
#define SHARE_VM_GC_G1_G1BLOCKOFFSETTABLE_HPP
#include "gc/g1/g1RegionToSpaceMapper.hpp"
+#include "gc/shared/blockOffsetTable.hpp"
#include "memory/memRegion.hpp"
#include "memory/virtualspace.hpp"
#include "utilities/globalDefinitions.hpp"
@@ -54,9 +55,9 @@
u_char* _offset_array; // byte array keeping backwards offsets
void check_offset(size_t offset, const char* msg) const {
- assert(offset <= N_words,
+ assert(offset <= BOTConstants::N_words,
"%s - offset: " SIZE_FORMAT ", N_words: %u",
- msg, offset, (uint)N_words);
+ msg, offset, BOTConstants::N_words);
}
// Bounds checking accessors:
@@ -82,22 +83,15 @@
// Return the number of slots needed for an offset array
// that covers mem_region_words words.
static size_t compute_size(size_t mem_region_words) {
- size_t number_of_slots = (mem_region_words / N_words);
+ size_t number_of_slots = (mem_region_words / BOTConstants::N_words);
return ReservedSpace::allocation_align_size_up(number_of_slots);
}
// Returns how many bytes of the heap a single byte of the BOT corresponds to.
static size_t heap_map_factor() {
- return N_bytes;
+ return BOTConstants::N_bytes;
}
- enum SomePublicConstants {
- LogN = 9,
- LogN_words = LogN - LogHeapWordSize,
- N_bytes = 1 << LogN,
- N_words = 1 << LogN_words
- };
-
// Initialize the Block Offset Table to cover the memory region passed
// in the heap parameter.
G1BlockOffsetTable(MemRegion heap, G1RegionToSpaceMapper* storage);
@@ -111,7 +105,7 @@
inline HeapWord* address_for_index(size_t index) const;
// Variant of address_for_index that does not check the index for validity.
inline HeapWord* address_for_index_raw(size_t index) const {
- return _reserved.start() + (index << LogN_words);
+ return _reserved.start() + (index << BOTConstants::LogN_words);
}
};
@@ -119,11 +113,6 @@
friend class G1BlockOffsetTable;
friend class VMStructs;
private:
- enum SomePrivateConstants {
- N_words = G1BlockOffsetTable::N_words,
- LogN = G1BlockOffsetTable::LogN
- };
-
// allocation boundary at which offset array must be updated
HeapWord* _next_offset_threshold;
size_t _next_offset_index; // index corresponding to that boundary
--- a/hotspot/src/share/vm/gc/g1/g1BlockOffsetTable.inline.hpp Sun Jan 10 20:02:50 2016 -0500
+++ b/hotspot/src/share/vm/gc/g1/g1BlockOffsetTable.inline.hpp Mon Jan 11 09:14:01 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -76,7 +76,7 @@
// Variant of index_for that does not check the index for validity.
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)) >> BOTConstants::LogN;
}
inline size_t G1BlockOffsetTable::index_for(const void* p) const {
@@ -117,15 +117,15 @@
HeapWord* q = _bot->address_for_index(index);
uint offset = _bot->offset_array(index); // Extend u_char to uint.
- while (offset >= N_words) {
+ while (offset >= BOTConstants::N_words) {
// The excess of the offset from N_words indicates a power of Base
// to go back by.
- size_t n_cards_back = BlockOffsetArray::entry_to_cards_back(offset);
- q -= (N_words * n_cards_back);
+ size_t n_cards_back = BOTConstants::entry_to_cards_back(offset);
+ q -= (BOTConstants::N_words * n_cards_back);
index -= n_cards_back;
offset = _bot->offset_array(index);
}
- assert(offset < N_words, "offset too large");
+ assert(offset < BOTConstants::N_words, "offset too large");
q -= offset;
return q;
}
--- a/hotspot/src/share/vm/gc/g1/g1RemSet.cpp Sun Jan 10 20:02:50 2016 -0500
+++ b/hotspot/src/share/vm/gc/g1/g1RemSet.cpp Mon Jan 11 09:14:01 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -109,7 +109,7 @@
// Set the "from" region in the closure.
_oc->set_region(r);
- MemRegion card_region(_bot->address_for_index(index), G1BlockOffsetTable::N_words);
+ MemRegion card_region(_bot->address_for_index(index), BOTConstants::N_words);
MemRegion pre_gc_allocated(r->bottom(), r->scan_top());
MemRegion mr = pre_gc_allocated.intersection(card_region);
if (!mr.is_empty() && !_ct_bs->is_card_claimed(index)) {
--- a/hotspot/src/share/vm/gc/g1/heapRegionSet.cpp Sun Jan 10 20:02:50 2016 -0500
+++ b/hotspot/src/share/vm/gc/g1/heapRegionSet.cpp Mon Jan 11 09:14:01 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -389,7 +389,7 @@
bot_rs.size(),
os::vm_page_size(),
HeapRegion::GrainBytes,
- G1BlockOffsetTable::N_bytes,
+ BOTConstants::N_bytes,
mtGC);
G1BlockOffsetTable bot(heap, bot_storage);
bot_storage->commit_regions(0, num_regions_in_test);
--- a/hotspot/src/share/vm/gc/shared/blockOffsetTable.cpp Sun Jan 10 20:02:50 2016 -0500
+++ b/hotspot/src/share/vm/gc/shared/blockOffsetTable.cpp Mon Jan 11 09:14:01 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -87,7 +87,7 @@
bool BlockOffsetSharedArray::is_card_boundary(HeapWord* p) const {
assert(p >= _reserved.start(), "just checking");
size_t delta = pointer_delta(p, _reserved.start());
- return (delta & right_n_bits(LogN_words)) == (size_t)NoBits;
+ return (delta & right_n_bits((int)BOTConstants::LogN_words)) == (size_t)NoBits;
}
@@ -104,7 +104,7 @@
set_init_to_zero(init_to_zero_);
if (!init_to_zero_) {
// initialize cards to point back to mr.start()
- set_remainder_to_point_to_start(mr.start() + N_words, mr.end());
+ set_remainder_to_point_to_start(mr.start() + BOTConstants::N_words, mr.end());
_array->set_offset_array(0, 0); // set first card to 0
}
}
@@ -160,7 +160,7 @@
size_t start_card = _array->index_for(start);
size_t end_card = _array->index_for(end-1);
assert(start ==_array->address_for_index(start_card), "Precondition");
- assert(end ==_array->address_for_index(end_card)+N_words, "Precondition");
+ assert(end ==_array->address_for_index(end_card)+BOTConstants::N_words, "Precondition");
set_remainder_to_point_to_start_incl(start_card, end_card, reducing); // closed interval
}
@@ -176,16 +176,16 @@
return;
}
assert(start_card > _array->index_for(_bottom), "Cannot be first card");
- assert(_array->offset_array(start_card-1) <= N_words,
+ assert(_array->offset_array(start_card-1) <= BOTConstants::N_words,
"Offset card has an unexpected value");
size_t start_card_for_region = start_card;
u_char offset = max_jubyte;
- for (int i = 0; i < N_powers; i++) {
+ for (uint i = 0; i < BOTConstants::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.
- size_t reach = start_card - 1 + (power_to_cards_back(i+1) - 1);
- offset = N_words + i;
+ size_t reach = start_card - 1 + (BOTConstants::power_to_cards_back(i+1) - 1);
+ offset = BOTConstants::N_words + i;
if (reach >= end_card) {
_array->set_offset_array(start_card_for_region, end_card, offset, reducing);
start_card_for_region = reach + 1;
@@ -206,15 +206,15 @@
if (end_card < start_card) {
return;
}
- guarantee(_array->offset_array(start_card) == N_words, "Wrong value in second card");
- u_char last_entry = N_words;
+ guarantee(_array->offset_array(start_card) == BOTConstants::N_words, "Wrong value in second card");
+ u_char last_entry = BOTConstants::N_words;
for (size_t c = start_card + 1; c <= end_card; c++ /* yeah! */) {
u_char entry = _array->offset_array(c);
guarantee(entry >= last_entry, "Monotonicity");
- if (c - start_card > power_to_cards_back(1)) {
- guarantee(entry > N_words, "Should be in logarithmic region");
+ if (c - start_card > BOTConstants::power_to_cards_back(1)) {
+ guarantee(entry > BOTConstants::N_words, "Should be in logarithmic region");
}
- size_t backskip = entry_to_cards_back(entry);
+ size_t backskip = BOTConstants::entry_to_cards_back(entry);
size_t landing_card = c - backskip;
guarantee(landing_card >= (start_card - 1), "Inv");
if (landing_card >= start_card) {
@@ -222,7 +222,7 @@
} else {
guarantee(landing_card == (start_card - 1), "Tautology");
// Note that N_words is the maximum offset value
- guarantee(_array->offset_array(landing_card) <= N_words, "Offset value");
+ guarantee(_array->offset_array(landing_card) <= BOTConstants::N_words, "Offset value");
}
last_entry = entry; // remember for monotonicity test
}
@@ -254,7 +254,7 @@
uintptr_t start_ui = (uintptr_t)blk_start;
// Calculate the last card boundary preceding end of blk
intptr_t boundary_before_end = (intptr_t)end_ui;
- clear_bits(boundary_before_end, right_n_bits(LogN));
+ clear_bits(boundary_before_end, right_n_bits((int)BOTConstants::LogN));
if (start_ui <= (uintptr_t)boundary_before_end) {
// blk starts at or crosses a boundary
// Calculate index of card on which blk begins
@@ -267,7 +267,7 @@
if (blk_start != boundary) {
// blk starts strictly after boundary
// adjust card boundary and start_index forward to next card
- boundary += N_words;
+ boundary += BOTConstants::N_words;
start_index++;
}
assert(start_index <= end_index, "monotonicity of index_for()");
@@ -284,8 +284,8 @@
// We have finished marking the "offset card". We need to now
// mark the subsequent cards that this blk spans.
if (start_index < end_index) {
- HeapWord* rem_st = _array->address_for_index(start_index) + N_words;
- HeapWord* rem_end = _array->address_for_index(end_index) + N_words;
+ HeapWord* rem_st = _array->address_for_index(start_index) + BOTConstants::N_words;
+ HeapWord* rem_end = _array->address_for_index(end_index) + BOTConstants::N_words;
set_remainder_to_point_to_start(rem_st, rem_end, reducing);
}
break;
@@ -450,8 +450,8 @@
bool more = true;
uint i = 1;
// Fix the first power block with back_by > num_pref_cards.
- while (more && (i < N_powers)) {
- size_t back_by = power_to_cards_back(i);
+ while (more && (i < BOTConstants::N_powers)) {
+ size_t back_by = BOTConstants::power_to_cards_back(i);
size_t right_index = suff_index + back_by - 1;
size_t left_index = right_index - num_pref_cards + 1;
if (right_index >= end_index - 1) { // last iteration
@@ -466,7 +466,7 @@
// is non-null.
if (left_index <= right_index) {
_array->set_offset_array(left_index, right_index,
- N_words + i - 1, true /* reducing */);
+ BOTConstants::N_words + i - 1, true /* reducing */);
} else {
more = false; // we are done
assert((end_index - 1) == right_index, "Must be at the end.");
@@ -477,8 +477,8 @@
i++;
}
// Fix the rest of the power blocks.
- while (more && (i < N_powers)) {
- size_t back_by = power_to_cards_back(i);
+ while (more && (i < BOTConstants::N_powers)) {
+ size_t back_by = BOTConstants::power_to_cards_back(i);
size_t right_index = suff_index + back_by - 1;
size_t left_index = right_index - num_pref_cards + 1;
if (right_index >= end_index - 1) { // last iteration
@@ -489,7 +489,7 @@
more = false;
}
assert(left_index <= right_index, "Error");
- _array->set_offset_array(left_index, right_index, N_words + i - 1, true /* reducing */);
+ _array->set_offset_array(left_index, right_index, BOTConstants::N_words + i - 1, true /* reducing */);
i++;
}
}
@@ -530,11 +530,11 @@
HeapWord* q = _array->address_for_index(index);
uint offset = _array->offset_array(index); // Extend u_char to uint.
- while (offset >= N_words) {
+ while (offset >= BOTConstants::N_words) {
// The excess of the offset from N_words indicates a power of Base
// to go back by.
- size_t n_cards_back = entry_to_cards_back(offset);
- q -= (N_words * n_cards_back);
+ size_t n_cards_back = BOTConstants::entry_to_cards_back(offset);
+ q -= (BOTConstants::N_words * n_cards_back);
assert(q >= _sp->bottom(),
"q = " PTR_FORMAT " crossed below bottom = " PTR_FORMAT,
p2i(q), p2i(_sp->bottom()));
@@ -544,7 +544,7 @@
index -= n_cards_back;
offset = _array->offset_array(index);
}
- assert(offset < N_words, "offset too large");
+ assert(offset < BOTConstants::N_words, "offset too large");
index--;
q -= offset;
assert(q >= _sp->bottom(),
@@ -599,14 +599,14 @@
uint offset;
do {
offset = _array->offset_array(index);
- if (offset < N_words) {
+ if (offset < BOTConstants::N_words) {
q -= offset;
} else {
- size_t n_cards_back = entry_to_cards_back(offset);
- q -= (n_cards_back * N_words);
+ size_t n_cards_back = BOTConstants::entry_to_cards_back(offset);
+ q -= (n_cards_back * BOTConstants::N_words);
index -= n_cards_back;
}
- } while (offset >= N_words);
+ } while (offset >= BOTConstants::N_words);
assert(q <= addr, "block start should be to left of arg");
return q;
}
@@ -668,22 +668,22 @@
HeapWord* q = _array->address_for_index(index);
uint offset = _array->offset_array(index); // Extend u_char to uint.
- while (offset > N_words) {
+ while (offset > BOTConstants::N_words) {
// The excess of the offset from N_words indicates a power of Base
// to go back by.
- size_t n_cards_back = entry_to_cards_back(offset);
- q -= (N_words * n_cards_back);
+ size_t n_cards_back = BOTConstants::entry_to_cards_back(offset);
+ q -= (BOTConstants::N_words * n_cards_back);
assert(q >= _sp->bottom(), "Went below bottom!");
index -= n_cards_back;
offset = _array->offset_array(index);
}
- while (offset == N_words) {
+ while (offset == BOTConstants::N_words) {
assert(q >= _sp->bottom(), "Went below bottom!");
- q -= N_words;
+ q -= BOTConstants::N_words;
index--;
offset = _array->offset_array(index);
}
- assert(offset < N_words, "offset too large");
+ assert(offset < BOTConstants::N_words, "offset too large");
q -= offset;
HeapWord* n = q;
@@ -716,14 +716,14 @@
"should be past threshold");
assert(blk_start <= _next_offset_threshold,
"blk_start should be at or before threshold");
- assert(pointer_delta(_next_offset_threshold, blk_start) <= N_words,
+ assert(pointer_delta(_next_offset_threshold, blk_start) <= BOTConstants::N_words,
"offset should be <= BlockOffsetSharedArray::N");
assert(Universe::heap()->is_in_reserved(blk_start),
"reference must be into the heap");
assert(Universe::heap()->is_in_reserved(blk_end-1),
"limit must be within the heap");
assert(_next_offset_threshold ==
- _array->_reserved.start() + _next_offset_index*N_words,
+ _array->_reserved.start() + _next_offset_index*BOTConstants::N_words,
"index must agree with threshold");
debug_only(size_t orig_next_offset_index = _next_offset_index;)
@@ -745,7 +745,7 @@
HeapWord* rem_st = _array->address_for_index(_next_offset_index + 1);
// Calculate rem_end this way because end_index
// may be the last valid index in the covered region.
- HeapWord* rem_end = _array->address_for_index(end_index) + N_words;
+ HeapWord* rem_end = _array->address_for_index(end_index) + BOTConstants::N_words;
set_remainder_to_point_to_start(rem_st, rem_end);
}
@@ -753,7 +753,7 @@
_next_offset_index = end_index + 1;
// Calculate _next_offset_threshold this way because end_index
// may be the last valid index in the covered region.
- _next_offset_threshold = _array->address_for_index(end_index) + N_words;
+ _next_offset_threshold = _array->address_for_index(end_index) + BOTConstants::N_words;
assert(_next_offset_threshold >= blk_end, "Incorrect offset threshold");
#ifdef ASSERT
@@ -764,11 +764,11 @@
assert((_array->offset_array(orig_next_offset_index) == 0 &&
blk_start == boundary) ||
(_array->offset_array(orig_next_offset_index) > 0 &&
- _array->offset_array(orig_next_offset_index) <= N_words),
+ _array->offset_array(orig_next_offset_index) <= BOTConstants::N_words),
"offset array should have been set");
for (size_t j = orig_next_offset_index + 1; j <= end_index; j++) {
assert(_array->offset_array(j) > 0 &&
- _array->offset_array(j) <= (u_char) (N_words+N_powers-1),
+ _array->offset_array(j) <= (u_char) (BOTConstants::N_words+BOTConstants::N_powers-1),
"offset array should have been set");
}
#endif
--- a/hotspot/src/share/vm/gc/shared/blockOffsetTable.hpp Sun Jan 10 20:02:50 2016 -0500
+++ b/hotspot/src/share/vm/gc/shared/blockOffsetTable.hpp Mon Jan 11 09:14:01 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -46,6 +46,34 @@
class ContiguousSpace;
+class BOTConstants : public AllStatic {
+public:
+ static const uint LogN = 9;
+ static const uint LogN_words = LogN - LogHeapWordSize;
+ static const uint N_bytes = 1 << LogN;
+ static const uint N_words = 1 << LogN_words;
+ // entries "e" of at least N_words mean "go back by Base^(e-N_words)."
+ // All entries are less than "N_words + N_powers".
+ static const uint LogBase = 4;
+ static const uint Base = (1 << LogBase);
+ static const uint N_powers = 14;
+
+ static size_t power_to_cards_back(uint i) {
+ return (size_t)1 << (LogBase * i);
+ }
+ static size_t power_to_words_back(uint i) {
+ return power_to_cards_back(i) * N_words;
+ }
+ static size_t entry_to_cards_back(u_char entry) {
+ assert(entry >= N_words, "Precondition");
+ return power_to_cards_back(entry - N_words);
+ }
+ static size_t entry_to_words_back(u_char entry) {
+ assert(entry >= N_words, "Precondition");
+ return power_to_words_back(entry - N_words);
+ }
+};
+
//////////////////////////////////////////////////////////////////////////
// The BlockOffsetTable "interface"
//////////////////////////////////////////////////////////////////////////
@@ -109,13 +137,6 @@
friend class VMStructs;
private:
- enum SomePrivateConstants {
- LogN = 9,
- LogN_words = LogN - LogHeapWordSize,
- N_bytes = 1 << LogN,
- N_words = 1 << LogN_words
- };
-
bool _init_to_zero;
// The reserved region covered by the shared array.
@@ -163,7 +184,7 @@
check_reducing_assertion(reducing);
assert(index < _vs.committed_size(), "index out of range");
assert(high >= low, "addresses out of order");
- assert(pointer_delta(high, low) <= N_words, "offset too large");
+ assert(pointer_delta(high, low) <= BOTConstants::N_words, "offset too large");
assert(!reducing || _offset_array[index] >= (u_char)pointer_delta(high, low),
"Not reducing");
_offset_array[index] = (u_char)pointer_delta(high, low);
@@ -174,7 +195,7 @@
assert(index_for(right - 1) < _vs.committed_size(),
"right address out of range");
assert(left < right, "Heap addresses out of order");
- size_t num_cards = pointer_delta(right, left) >> LogN_words;
+ size_t num_cards = pointer_delta(right, left) >> BOTConstants::LogN_words;
fill_range(index_for(left), num_cards, offset);
}
@@ -191,7 +212,7 @@
void check_offset_array(size_t index, HeapWord* high, HeapWord* low) const {
assert(index < _vs.committed_size(), "index out of range");
assert(high >= low, "addresses out of order");
- assert(pointer_delta(high, low) <= N_words, "offset too large");
+ assert(pointer_delta(high, low) <= BOTConstants::N_words, "offset too large");
assert(_offset_array[index] == pointer_delta(high, low),
"Wrong offset");
}
@@ -206,7 +227,7 @@
// to be reserved.
size_t compute_size(size_t mem_region_words) {
- size_t number_of_slots = (mem_region_words / N_words) + 1;
+ size_t number_of_slots = (mem_region_words / BOTConstants::N_words) + 1;
return ReservedSpace::allocation_align_size_up(number_of_slots);
}
@@ -248,7 +269,6 @@
//////////////////////////////////////////////////////////////////////////
class BlockOffsetArray: public BlockOffsetTable {
friend class VMStructs;
- friend class G1BlockOffsetTablePart; // temp. until we restructure and cleanup
protected:
// The following enums are used by do_block_internal() below
enum Action {
@@ -258,31 +278,6 @@
// (see verify_single_block()).
};
- enum SomePrivateConstants {
- N_words = BlockOffsetSharedArray::N_words,
- LogN = BlockOffsetSharedArray::LogN,
- // entries "e" of at least N_words mean "go back by Base^(e-N_words)."
- // All entries are less than "N_words + N_powers".
- LogBase = 4,
- Base = (1 << LogBase),
- N_powers = 14
- };
-
- static size_t power_to_cards_back(uint i) {
- return (size_t)1 << (LogBase * i);
- }
- static size_t power_to_words_back(uint i) {
- return power_to_cards_back(i) * N_words;
- }
- static size_t entry_to_cards_back(u_char entry) {
- assert(entry >= N_words, "Precondition");
- return power_to_cards_back(entry - N_words);
- }
- static size_t entry_to_words_back(u_char entry) {
- assert(entry >= N_words, "Precondition");
- return power_to_words_back(entry - N_words);
- }
-
// The shared array, which is shared with other BlockOffsetArray's
// corresponding to different spaces within a generation or span of
// memory.
@@ -344,7 +339,7 @@
assert(_array->is_card_boundary(new_end),
"new _end would not be a card boundary");
// set all the newly added cards
- _array->set_offset_array(_end, new_end, N_words);
+ _array->set_offset_array(_end, new_end, BOTConstants::N_words);
}
_end = new_end; // update _end
}
--- a/hotspot/src/share/vm/gc/shared/blockOffsetTable.inline.hpp Sun Jan 10 20:02:50 2016 -0500
+++ b/hotspot/src/share/vm/gc/shared/blockOffsetTable.inline.hpp Mon Jan 11 09:14:01 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -49,14 +49,14 @@
pc < (char*)_reserved.end(),
"p not in range.");
size_t delta = pointer_delta(pc, _reserved.start(), sizeof(char));
- size_t result = delta >> LogN;
+ size_t result = delta >> BOTConstants::LogN;
assert(result < _vs.committed_size(), "bad index from address");
return result;
}
inline HeapWord* BlockOffsetSharedArray::address_for_index(size_t index) const {
assert(index < _vs.committed_size(), "bad index");
- HeapWord* result = _reserved.start() + (index << LogN_words);
+ HeapWord* result = _reserved.start() + (index << BOTConstants::LogN_words);
assert(result >= _reserved.start() && result < _reserved.end(),
"bad address from index");
return result;
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp Sun Jan 10 20:02:50 2016 -0500
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp Mon Jan 11 09:14:01 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -2320,12 +2320,13 @@
declare_constant(BarrierSet::G1SATBCT) \
declare_constant(BarrierSet::G1SATBCTLogging) \
\
- declare_constant(BlockOffsetSharedArray::LogN) \
- declare_constant(BlockOffsetSharedArray::LogN_words) \
- declare_constant(BlockOffsetSharedArray::N_bytes) \
- declare_constant(BlockOffsetSharedArray::N_words) \
- \
- declare_constant(BlockOffsetArray::N_words) \
+ declare_constant(BOTConstants::LogN) \
+ declare_constant(BOTConstants::LogN_words) \
+ declare_constant(BOTConstants::N_bytes) \
+ declare_constant(BOTConstants::N_words) \
+ declare_constant(BOTConstants::LogBase) \
+ declare_constant(BOTConstants::Base) \
+ declare_constant(BOTConstants::N_powers) \
\
declare_constant(CardTableModRefBS::clean_card) \
declare_constant(CardTableModRefBS::last_card) \