提交 c76e243e 编写于 作者: J johnc

7095194: G1: HeapRegion::GrainBytes, GrainWords, and CardsPerRegion should be size_t

Summary: Declare GrainBytes, GrainWords, and CardsPerRegion as size_t.
Reviewed-by: jcoomes, tonyp, jmasa
上级 931196f1
...@@ -4573,7 +4573,7 @@ G1PrintRegionLivenessInfoClosure(outputStream* out, const char* phase_name) ...@@ -4573,7 +4573,7 @@ G1PrintRegionLivenessInfoClosure(outputStream* out, const char* phase_name)
G1PPRL_SUM_BYTE_FORMAT("region-size"), G1PPRL_SUM_BYTE_FORMAT("region-size"),
g1_committed.start(), g1_committed.end(), g1_committed.start(), g1_committed.end(),
g1_reserved.start(), g1_reserved.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);
_out->print_cr(G1PPRL_LINE_PREFIX _out->print_cr(G1PPRL_LINE_PREFIX
G1PPRL_TYPE_H_FORMAT G1PPRL_TYPE_H_FORMAT
...@@ -4604,7 +4604,7 @@ size_t G1PrintRegionLivenessInfoClosure::get_hum_bytes(size_t* hum_bytes) { ...@@ -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 // The > 0 check is to deal with the prev and next live bytes which
// could be 0. // could be 0.
if (*hum_bytes > 0) { if (*hum_bytes > 0) {
bytes = MIN2((size_t) HeapRegion::GrainBytes, *hum_bytes); bytes = MIN2(HeapRegion::GrainBytes, *hum_bytes);
*hum_bytes -= bytes; *hum_bytes -= bytes;
} }
return bytes; return bytes;
......
...@@ -552,8 +552,7 @@ G1CollectedHeap::new_region_try_secondary_free_list() { ...@@ -552,8 +552,7 @@ G1CollectedHeap::new_region_try_secondary_free_list() {
} }
HeapRegion* G1CollectedHeap::new_region(size_t word_size, bool do_expand) { HeapRegion* G1CollectedHeap::new_region(size_t word_size, bool do_expand) {
assert(!isHumongous(word_size) || assert(!isHumongous(word_size) || word_size <= HeapRegion::GrainWords,
word_size <= (size_t) HeapRegion::GrainWords,
"the only time we use this to allocate a humongous region is " "the only time we use this to allocate a humongous region is "
"when we are allocating a single humongous region"); "when we are allocating a single humongous region");
...@@ -1170,7 +1169,7 @@ public: ...@@ -1170,7 +1169,7 @@ public:
if (!hr->isHumongous()) { if (!hr->isHumongous()) {
_hr_printer->post_compaction(hr, G1HRPrinter::Old); _hr_printer->post_compaction(hr, G1HRPrinter::Old);
} else if (hr->startsHumongous()) { } else if (hr->startsHumongous()) {
if (hr->capacity() == (size_t) HeapRegion::GrainBytes) { if (hr->capacity() == HeapRegion::GrainBytes) {
// single humongous region // single humongous region
_hr_printer->post_compaction(hr, G1HRPrinter::SingleHumongous); _hr_printer->post_compaction(hr, G1HRPrinter::SingleHumongous);
} else { } else {
...@@ -1971,7 +1970,7 @@ jint G1CollectedHeap::initialize() { ...@@ -1971,7 +1970,7 @@ jint G1CollectedHeap::initialize() {
size_t max_cards_per_region = ((size_t)1 << (sizeof(CardIdx_t)*BitsPerByte-1)) - 1; 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(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"); "too many cards per region");
HeapRegionSet::set_unrealistically_long_length(max_regions() + 1); HeapRegionSet::set_unrealistically_long_length(max_regions() + 1);
...@@ -3051,8 +3050,7 @@ void G1CollectedHeap::print_on(outputStream* st, bool extended) const { ...@@ -3051,8 +3050,7 @@ void G1CollectedHeap::print_on(outputStream* st, bool extended) const {
_g1_storage.high(), _g1_storage.high(),
_g1_storage.high_boundary()); _g1_storage.high_boundary());
st->cr(); st->cr();
st->print(" region size " SIZE_FORMAT "K, ", st->print(" region size " SIZE_FORMAT "K, ", HeapRegion::GrainBytes / K);
HeapRegion::GrainBytes/K);
size_t young_regions = _young_list->length(); size_t young_regions = _young_list->length();
st->print(SIZE_FORMAT " young (" SIZE_FORMAT "K), ", st->print(SIZE_FORMAT " young (" SIZE_FORMAT "K), ",
young_regions, young_regions * HeapRegion::GrainBytes / K); young_regions, young_regions * HeapRegion::GrainBytes / K);
......
...@@ -298,10 +298,10 @@ G1CollectorPolicy::G1CollectorPolicy() : ...@@ -298,10 +298,10 @@ G1CollectorPolicy::G1CollectorPolicy() :
} }
// Verify PLAB sizes // Verify PLAB sizes
const uint region_size = HeapRegion::GrainWords; const size_t region_size = HeapRegion::GrainWords;
if (YoungPLABSize > region_size || OldPLABSize > region_size) { if (YoungPLABSize > region_size || OldPLABSize > region_size) {
char buffer[128]; 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); OldPLABSize > region_size ? "Old" : "Young", region_size);
vm_exit_during_initialization(buffer); vm_exit_during_initialization(buffer);
} }
......
...@@ -33,11 +33,11 @@ ...@@ -33,11 +33,11 @@
#include "memory/iterator.hpp" #include "memory/iterator.hpp"
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
int HeapRegion::LogOfHRGrainBytes = 0; int HeapRegion::LogOfHRGrainBytes = 0;
int HeapRegion::LogOfHRGrainWords = 0; int HeapRegion::LogOfHRGrainWords = 0;
int HeapRegion::GrainBytes = 0; size_t HeapRegion::GrainBytes = 0;
int HeapRegion::GrainWords = 0; size_t HeapRegion::GrainWords = 0;
int HeapRegion::CardsPerRegion = 0; size_t HeapRegion::CardsPerRegion = 0;
HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1, HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1,
HeapRegion* hr, OopClosure* cl, HeapRegion* hr, OopClosure* cl,
...@@ -322,11 +322,11 @@ void HeapRegion::setup_heap_region_size(uintx min_heap_size) { ...@@ -322,11 +322,11 @@ void HeapRegion::setup_heap_region_size(uintx min_heap_size) {
guarantee(GrainBytes == 0, "we should only set it once"); guarantee(GrainBytes == 0, "we should only set it once");
// The cast to int is safe, given that we've bounded region_size by // The cast to int is safe, given that we've bounded region_size by
// MIN_REGION_SIZE and MAX_REGION_SIZE. // 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"); guarantee(GrainWords == 0, "we should only set it once");
GrainWords = GrainBytes >> LogHeapWordSize; GrainWords = GrainBytes >> LogHeapWordSize;
guarantee(1 << LogOfHRGrainWords == GrainWords, "sanity"); guarantee((size_t)(1 << LogOfHRGrainWords) == GrainWords, "sanity");
guarantee(CardsPerRegion == 0, "we should only set it once"); guarantee(CardsPerRegion == 0, "we should only set it once");
CardsPerRegion = GrainBytes >> CardTableModRefBS::card_shift; CardsPerRegion = GrainBytes >> CardTableModRefBS::card_shift;
...@@ -379,8 +379,7 @@ void HeapRegion::hr_clear(bool par, bool clear_space) { ...@@ -379,8 +379,7 @@ void HeapRegion::hr_clear(bool par, bool clear_space) {
void HeapRegion::par_clear() { void HeapRegion::par_clear() {
assert(used() == 0, "the region should have been already cleared"); assert(used() == 0, "the region should have been already cleared");
assert(capacity() == (size_t) HeapRegion::GrainBytes, assert(capacity() == HeapRegion::GrainBytes, "should be back to normal");
"should be back to normal");
HeapRegionRemSet* hrrs = rem_set(); HeapRegionRemSet* hrrs = rem_set();
hrrs->clear(); hrrs->clear();
CardTableModRefBS* ct_bs = CardTableModRefBS* ct_bs =
...@@ -436,7 +435,7 @@ void HeapRegion::set_notHumongous() { ...@@ -436,7 +435,7 @@ void HeapRegion::set_notHumongous() {
assert(end() == _orig_end, "sanity"); assert(end() == _orig_end, "sanity");
} }
assert(capacity() == (size_t) HeapRegion::GrainBytes, "pre-condition"); assert(capacity() == HeapRegion::GrainBytes, "pre-condition");
_humongous_type = NotHumongous; _humongous_type = NotHumongous;
_humongous_start_region = NULL; _humongous_start_region = NULL;
} }
......
...@@ -346,16 +346,12 @@ class HeapRegion: public G1OffsetTableContigSpace { ...@@ -346,16 +346,12 @@ class HeapRegion: public G1OffsetTableContigSpace {
G1BlockOffsetSharedArray* sharedOffsetArray, G1BlockOffsetSharedArray* sharedOffsetArray,
MemRegion mr, bool is_zeroed); MemRegion mr, bool is_zeroed);
static int LogOfHRGrainBytes; static int LogOfHRGrainBytes;
static int LogOfHRGrainWords; 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 static size_t GrainBytes;
// compilers to be ints. To avoid going and fixing all their uses, static size_t GrainWords;
// I'm declaring them as ints. I'm not anticipating heap region static size_t CardsPerRegion;
// sizes to reach anywhere near 2g, so using an int here is safe.
static int GrainBytes;
static int GrainWords;
static int CardsPerRegion;
static size_t align_up_to_region_byte_size(size_t sz) { static size_t align_up_to_region_byte_size(size_t sz) {
return (sz + (size_t) GrainBytes - 1) & return (sz + (size_t) GrainBytes - 1) &
......
...@@ -148,7 +148,7 @@ protected: ...@@ -148,7 +148,7 @@ protected:
CardIdx_t from_card = (CardIdx_t) CardIdx_t from_card = (CardIdx_t)
hw_offset >> (CardTableModRefBS::card_shift - LogHeapWordSize); 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."); "Must be in range.");
add_card_work(from_card, par); add_card_work(from_card, par);
} }
...@@ -639,7 +639,7 @@ void OtherRegionsTable::add_reference(OopOrNarrowOopStar from, int tid) { ...@@ -639,7 +639,7 @@ void OtherRegionsTable::add_reference(OopOrNarrowOopStar from, int tid) {
uintptr_t(from_hr->bottom()) uintptr_t(from_hr->bottom())
>> CardTableModRefBS::card_shift; >> CardTableModRefBS::card_shift;
CardIdx_t card_index = from_card - from_hr_bot_card_index; 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."); "Must be in range.");
if (G1HRRSUseSparseTable && if (G1HRRSUseSparseTable &&
_sparse_table.add_card(from_hrs_ind, card_index)) { _sparse_table.add_card(from_hrs_ind, card_index)) {
...@@ -1066,7 +1066,7 @@ bool OtherRegionsTable::contains_reference_locked(OopOrNarrowOopStar from) const ...@@ -1066,7 +1066,7 @@ bool OtherRegionsTable::contains_reference_locked(OopOrNarrowOopStar from) const
uintptr_t(hr->bottom()) >> CardTableModRefBS::card_shift; uintptr_t(hr->bottom()) >> CardTableModRefBS::card_shift;
assert(from_card >= hr_bot_card_index, "Inv"); assert(from_card >= hr_bot_card_index, "Inv");
CardIdx_t card_index = from_card - hr_bot_card_index; 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."); "Must be in range.");
return _sparse_table.contains_card(hr_ind, card_index); return _sparse_table.contains_card(hr_ind, card_index);
} }
...@@ -1191,7 +1191,7 @@ void HeapRegionRemSetIterator::initialize(const HeapRegionRemSet* hrrs) { ...@@ -1191,7 +1191,7 @@ void HeapRegionRemSetIterator::initialize(const HeapRegionRemSet* hrrs) {
_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;
_coarse_cur_region_cur_card = (HeapRegion::CardsPerRegion-1);; _coarse_cur_region_cur_card = (HeapRegion::CardsPerRegion-1);
_cur_region_cur_card = 0; _cur_region_cur_card = 0;
...@@ -1270,7 +1270,7 @@ bool HeapRegionRemSetIterator::fine_has_next(size_t& card_index) { ...@@ -1270,7 +1270,7 @@ bool HeapRegionRemSetIterator::fine_has_next(size_t& card_index) {
bool HeapRegionRemSetIterator::fine_has_next() { bool HeapRegionRemSetIterator::fine_has_next() {
return return
_fine_cur_prt != NULL && _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) { bool HeapRegionRemSetIterator::has_next(size_t& card_index) {
......
...@@ -395,8 +395,8 @@ class HeapRegionRemSetIterator : public CHeapObj { ...@@ -395,8 +395,8 @@ class HeapRegionRemSetIterator : public CHeapObj {
// Coarse table iteration fields: // Coarse table iteration fields:
// Current region index; // Current region index;
int _coarse_cur_region_index; int _coarse_cur_region_index;
int _coarse_cur_region_cur_card; size_t _coarse_cur_region_cur_card;
bool coarse_has_next(size_t& card_index); bool coarse_has_next(size_t& card_index);
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#define VM_STRUCTS_G1(nonstatic_field, static_field) \ #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, _regions, HeapRegion**) \
nonstatic_field(HeapRegionSeq, _length, size_t) \ nonstatic_field(HeapRegionSeq, _length, size_t) \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册