7095194: G1: HeapRegion::GrainBytes, GrainWords, and CardsPerRegion should be size_t
Declare GrainBytes, GrainWords, and CardsPerRegion as size_t. Reviewed-by: jcoomes, tonyp, jmasa
This commit is contained in:
parent
a4523cfc7f
commit
6513930e7a
hotspot/src/share/vm/gc_implementation/g1
@ -4573,7 +4573,7 @@ G1PrintRegionLivenessInfoClosure(outputStream* out, const char* phase_name)
|
||||
G1PPRL_SUM_BYTE_FORMAT("region-size"),
|
||||
g1_committed.start(), g1_committed.end(),
|
||||
g1_reserved.start(), g1_reserved.end(),
|
||||
(size_t)HeapRegion::GrainBytes);
|
||||
HeapRegion::GrainBytes);
|
||||
_out->print_cr(G1PPRL_LINE_PREFIX);
|
||||
_out->print_cr(G1PPRL_LINE_PREFIX
|
||||
G1PPRL_TYPE_H_FORMAT
|
||||
@ -4604,7 +4604,7 @@ size_t G1PrintRegionLivenessInfoClosure::get_hum_bytes(size_t* hum_bytes) {
|
||||
// The > 0 check is to deal with the prev and next live bytes which
|
||||
// could be 0.
|
||||
if (*hum_bytes > 0) {
|
||||
bytes = MIN2((size_t) HeapRegion::GrainBytes, *hum_bytes);
|
||||
bytes = MIN2(HeapRegion::GrainBytes, *hum_bytes);
|
||||
*hum_bytes -= bytes;
|
||||
}
|
||||
return bytes;
|
||||
|
@ -552,8 +552,7 @@ G1CollectedHeap::new_region_try_secondary_free_list() {
|
||||
}
|
||||
|
||||
HeapRegion* G1CollectedHeap::new_region(size_t word_size, bool do_expand) {
|
||||
assert(!isHumongous(word_size) ||
|
||||
word_size <= (size_t) HeapRegion::GrainWords,
|
||||
assert(!isHumongous(word_size) || word_size <= HeapRegion::GrainWords,
|
||||
"the only time we use this to allocate a humongous region is "
|
||||
"when we are allocating a single humongous region");
|
||||
|
||||
@ -1170,7 +1169,7 @@ public:
|
||||
if (!hr->isHumongous()) {
|
||||
_hr_printer->post_compaction(hr, G1HRPrinter::Old);
|
||||
} else if (hr->startsHumongous()) {
|
||||
if (hr->capacity() == (size_t) HeapRegion::GrainBytes) {
|
||||
if (hr->capacity() == HeapRegion::GrainBytes) {
|
||||
// single humongous region
|
||||
_hr_printer->post_compaction(hr, G1HRPrinter::SingleHumongous);
|
||||
} else {
|
||||
@ -1971,7 +1970,7 @@ jint G1CollectedHeap::initialize() {
|
||||
|
||||
size_t max_cards_per_region = ((size_t)1 << (sizeof(CardIdx_t)*BitsPerByte-1)) - 1;
|
||||
guarantee(HeapRegion::CardsPerRegion > 0, "make sure it's initialized");
|
||||
guarantee((size_t) HeapRegion::CardsPerRegion < max_cards_per_region,
|
||||
guarantee(HeapRegion::CardsPerRegion < max_cards_per_region,
|
||||
"too many cards per region");
|
||||
|
||||
HeapRegionSet::set_unrealistically_long_length(max_regions() + 1);
|
||||
@ -3051,8 +3050,7 @@ void G1CollectedHeap::print_on(outputStream* st, bool extended) const {
|
||||
_g1_storage.high(),
|
||||
_g1_storage.high_boundary());
|
||||
st->cr();
|
||||
st->print(" region size " SIZE_FORMAT "K, ",
|
||||
HeapRegion::GrainBytes/K);
|
||||
st->print(" region size " SIZE_FORMAT "K, ", HeapRegion::GrainBytes / K);
|
||||
size_t young_regions = _young_list->length();
|
||||
st->print(SIZE_FORMAT " young (" SIZE_FORMAT "K), ",
|
||||
young_regions, young_regions * HeapRegion::GrainBytes / K);
|
||||
|
@ -298,10 +298,10 @@ G1CollectorPolicy::G1CollectorPolicy() :
|
||||
}
|
||||
|
||||
// Verify PLAB sizes
|
||||
const uint region_size = HeapRegion::GrainWords;
|
||||
const size_t region_size = HeapRegion::GrainWords;
|
||||
if (YoungPLABSize > region_size || OldPLABSize > region_size) {
|
||||
char buffer[128];
|
||||
jio_snprintf(buffer, sizeof(buffer), "%sPLABSize should be at most %u",
|
||||
jio_snprintf(buffer, sizeof(buffer), "%sPLABSize should be at most "SIZE_FORMAT,
|
||||
OldPLABSize > region_size ? "Old" : "Young", region_size);
|
||||
vm_exit_during_initialization(buffer);
|
||||
}
|
||||
|
@ -33,11 +33,11 @@
|
||||
#include "memory/iterator.hpp"
|
||||
#include "oops/oop.inline.hpp"
|
||||
|
||||
int HeapRegion::LogOfHRGrainBytes = 0;
|
||||
int HeapRegion::LogOfHRGrainWords = 0;
|
||||
int HeapRegion::GrainBytes = 0;
|
||||
int HeapRegion::GrainWords = 0;
|
||||
int HeapRegion::CardsPerRegion = 0;
|
||||
int HeapRegion::LogOfHRGrainBytes = 0;
|
||||
int HeapRegion::LogOfHRGrainWords = 0;
|
||||
size_t HeapRegion::GrainBytes = 0;
|
||||
size_t HeapRegion::GrainWords = 0;
|
||||
size_t HeapRegion::CardsPerRegion = 0;
|
||||
|
||||
HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1,
|
||||
HeapRegion* hr, OopClosure* cl,
|
||||
@ -322,11 +322,11 @@ void HeapRegion::setup_heap_region_size(uintx min_heap_size) {
|
||||
guarantee(GrainBytes == 0, "we should only set it once");
|
||||
// The cast to int is safe, given that we've bounded region_size by
|
||||
// MIN_REGION_SIZE and MAX_REGION_SIZE.
|
||||
GrainBytes = (int) region_size;
|
||||
GrainBytes = (size_t)region_size;
|
||||
|
||||
guarantee(GrainWords == 0, "we should only set it once");
|
||||
GrainWords = GrainBytes >> LogHeapWordSize;
|
||||
guarantee(1 << LogOfHRGrainWords == GrainWords, "sanity");
|
||||
guarantee((size_t)(1 << LogOfHRGrainWords) == GrainWords, "sanity");
|
||||
|
||||
guarantee(CardsPerRegion == 0, "we should only set it once");
|
||||
CardsPerRegion = GrainBytes >> CardTableModRefBS::card_shift;
|
||||
@ -379,8 +379,7 @@ void HeapRegion::hr_clear(bool par, bool clear_space) {
|
||||
|
||||
void HeapRegion::par_clear() {
|
||||
assert(used() == 0, "the region should have been already cleared");
|
||||
assert(capacity() == (size_t) HeapRegion::GrainBytes,
|
||||
"should be back to normal");
|
||||
assert(capacity() == HeapRegion::GrainBytes, "should be back to normal");
|
||||
HeapRegionRemSet* hrrs = rem_set();
|
||||
hrrs->clear();
|
||||
CardTableModRefBS* ct_bs =
|
||||
@ -436,7 +435,7 @@ void HeapRegion::set_notHumongous() {
|
||||
assert(end() == _orig_end, "sanity");
|
||||
}
|
||||
|
||||
assert(capacity() == (size_t) HeapRegion::GrainBytes, "pre-condition");
|
||||
assert(capacity() == HeapRegion::GrainBytes, "pre-condition");
|
||||
_humongous_type = NotHumongous;
|
||||
_humongous_start_region = NULL;
|
||||
}
|
||||
|
@ -346,16 +346,12 @@ class HeapRegion: public G1OffsetTableContigSpace {
|
||||
G1BlockOffsetSharedArray* sharedOffsetArray,
|
||||
MemRegion mr, bool is_zeroed);
|
||||
|
||||
static int LogOfHRGrainBytes;
|
||||
static int LogOfHRGrainWords;
|
||||
// The normal type of these should be size_t. However, they used to
|
||||
// be members of an enum before and they are assumed by the
|
||||
// compilers to be ints. To avoid going and fixing all their uses,
|
||||
// I'm declaring them as ints. I'm not anticipating heap region
|
||||
// sizes to reach anywhere near 2g, so using an int here is safe.
|
||||
static int GrainBytes;
|
||||
static int GrainWords;
|
||||
static int CardsPerRegion;
|
||||
static int LogOfHRGrainBytes;
|
||||
static int LogOfHRGrainWords;
|
||||
|
||||
static size_t GrainBytes;
|
||||
static size_t GrainWords;
|
||||
static size_t CardsPerRegion;
|
||||
|
||||
static size_t align_up_to_region_byte_size(size_t sz) {
|
||||
return (sz + (size_t) GrainBytes - 1) &
|
||||
|
@ -148,7 +148,7 @@ protected:
|
||||
CardIdx_t from_card = (CardIdx_t)
|
||||
hw_offset >> (CardTableModRefBS::card_shift - LogHeapWordSize);
|
||||
|
||||
assert(0 <= from_card && from_card < HeapRegion::CardsPerRegion,
|
||||
assert(0 <= from_card && (size_t)from_card < HeapRegion::CardsPerRegion,
|
||||
"Must be in range.");
|
||||
add_card_work(from_card, par);
|
||||
}
|
||||
@ -639,7 +639,7 @@ void OtherRegionsTable::add_reference(OopOrNarrowOopStar from, int tid) {
|
||||
uintptr_t(from_hr->bottom())
|
||||
>> CardTableModRefBS::card_shift;
|
||||
CardIdx_t card_index = from_card - from_hr_bot_card_index;
|
||||
assert(0 <= card_index && card_index < HeapRegion::CardsPerRegion,
|
||||
assert(0 <= card_index && (size_t)card_index < HeapRegion::CardsPerRegion,
|
||||
"Must be in range.");
|
||||
if (G1HRRSUseSparseTable &&
|
||||
_sparse_table.add_card(from_hrs_ind, card_index)) {
|
||||
@ -1066,7 +1066,7 @@ bool OtherRegionsTable::contains_reference_locked(OopOrNarrowOopStar from) const
|
||||
uintptr_t(hr->bottom()) >> CardTableModRefBS::card_shift;
|
||||
assert(from_card >= hr_bot_card_index, "Inv");
|
||||
CardIdx_t card_index = from_card - hr_bot_card_index;
|
||||
assert(0 <= card_index && card_index < HeapRegion::CardsPerRegion,
|
||||
assert(0 <= card_index && (size_t)card_index < HeapRegion::CardsPerRegion,
|
||||
"Must be in range.");
|
||||
return _sparse_table.contains_card(hr_ind, card_index);
|
||||
}
|
||||
@ -1191,7 +1191,7 @@ void HeapRegionRemSetIterator::initialize(const HeapRegionRemSet* hrrs) {
|
||||
_is = Sparse;
|
||||
// Set these values so that we increment to the first region.
|
||||
_coarse_cur_region_index = -1;
|
||||
_coarse_cur_region_cur_card = (HeapRegion::CardsPerRegion-1);;
|
||||
_coarse_cur_region_cur_card = (HeapRegion::CardsPerRegion-1);
|
||||
|
||||
_cur_region_cur_card = 0;
|
||||
|
||||
@ -1270,7 +1270,7 @@ bool HeapRegionRemSetIterator::fine_has_next(size_t& card_index) {
|
||||
bool HeapRegionRemSetIterator::fine_has_next() {
|
||||
return
|
||||
_fine_cur_prt != NULL &&
|
||||
_cur_region_cur_card < (size_t) HeapRegion::CardsPerRegion;
|
||||
_cur_region_cur_card < HeapRegion::CardsPerRegion;
|
||||
}
|
||||
|
||||
bool HeapRegionRemSetIterator::has_next(size_t& card_index) {
|
||||
|
@ -395,8 +395,8 @@ class HeapRegionRemSetIterator : public CHeapObj {
|
||||
// Coarse table iteration fields:
|
||||
|
||||
// Current region index;
|
||||
int _coarse_cur_region_index;
|
||||
int _coarse_cur_region_cur_card;
|
||||
int _coarse_cur_region_index;
|
||||
size_t _coarse_cur_region_cur_card;
|
||||
|
||||
bool coarse_has_next(size_t& card_index);
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
#define VM_STRUCTS_G1(nonstatic_field, static_field) \
|
||||
\
|
||||
static_field(HeapRegion, GrainBytes, int) \
|
||||
static_field(HeapRegion, GrainBytes, size_t) \
|
||||
\
|
||||
nonstatic_field(HeapRegionSeq, _regions, HeapRegion**) \
|
||||
nonstatic_field(HeapRegionSeq, _length, size_t) \
|
||||
|
Loading…
x
Reference in New Issue
Block a user