This commit is contained in:
Jon Masamitsu 2014-06-10 20:46:28 -07:00
commit dc694646b7
19 changed files with 227 additions and 249 deletions

View File

@ -1341,13 +1341,14 @@ bool CMSAdaptiveSizePolicy::get_and_clear_first_after_collection() {
bool CMSAdaptiveSizePolicy::print_adaptive_size_policy_on( bool CMSAdaptiveSizePolicy::print_adaptive_size_policy_on(
outputStream* st) const { outputStream* st) const {
if (!UseAdaptiveSizePolicy) return false; if (!UseAdaptiveSizePolicy) {
return false;
}
GenCollectedHeap* gch = GenCollectedHeap::heap(); GenCollectedHeap* gch = GenCollectedHeap::heap();
Generation* gen0 = gch->get_gen(0); Generation* young = gch->get_gen(0);
DefNewGeneration* def_new = gen0->as_DefNewGeneration(); DefNewGeneration* def_new = young->as_DefNewGeneration();
return return AdaptiveSizePolicy::print_adaptive_size_policy_on(
AdaptiveSizePolicy::print_adaptive_size_policy_on(
st, st,
def_new->tenuring_threshold()); def_new->tenuring_threshold());
} }

View File

@ -60,21 +60,21 @@ void ConcurrentMarkSweepPolicy::initialize_generations() {
if (UseParNewGC) { if (UseParNewGC) {
if (UseAdaptiveSizePolicy) { if (UseAdaptiveSizePolicy) {
_generations[0] = new GenerationSpec(Generation::ASParNew, _generations[0] = new GenerationSpec(Generation::ASParNew,
_initial_gen0_size, _max_gen0_size); _initial_young_size, _max_young_size);
} else { } else {
_generations[0] = new GenerationSpec(Generation::ParNew, _generations[0] = new GenerationSpec(Generation::ParNew,
_initial_gen0_size, _max_gen0_size); _initial_young_size, _max_young_size);
} }
} else { } else {
_generations[0] = new GenerationSpec(Generation::DefNew, _generations[0] = new GenerationSpec(Generation::DefNew,
_initial_gen0_size, _max_gen0_size); _initial_young_size, _max_young_size);
} }
if (UseAdaptiveSizePolicy) { if (UseAdaptiveSizePolicy) {
_generations[1] = new GenerationSpec(Generation::ASConcurrentMarkSweep, _generations[1] = new GenerationSpec(Generation::ASConcurrentMarkSweep,
_initial_gen1_size, _max_gen1_size); _initial_old_size, _max_old_size);
} else { } else {
_generations[1] = new GenerationSpec(Generation::ConcurrentMarkSweep, _generations[1] = new GenerationSpec(Generation::ConcurrentMarkSweep,
_initial_gen1_size, _max_gen1_size); _initial_old_size, _max_old_size);
} }
if (_generations[0] == NULL || _generations[1] == NULL) { if (_generations[0] == NULL || _generations[1] == NULL) {

View File

@ -1138,8 +1138,8 @@ static inline size_t percent_of_space(Space* space, HeapWord* addr)
void CMSCollector::icms_update_allocation_limits() void CMSCollector::icms_update_allocation_limits()
{ {
Generation* gen0 = GenCollectedHeap::heap()->get_gen(0); Generation* young = GenCollectedHeap::heap()->get_gen(0);
EdenSpace* eden = gen0->as_DefNewGeneration()->eden(); EdenSpace* eden = young->as_DefNewGeneration()->eden();
const unsigned int duty_cycle = stats().icms_update_duty_cycle(); const unsigned int duty_cycle = stats().icms_update_duty_cycle();
if (CMSTraceIncrementalPacing) { if (CMSTraceIncrementalPacing) {

View File

@ -1193,10 +1193,9 @@ class ConcurrentMarkSweepGeneration: public CardGeneration {
// Does a "full" (forced) collection invoked on this generation collect // Does a "full" (forced) collection invoked on this generation collect
// all younger generations as well? Note that the second conjunct is a // all younger generations as well? Note that the second conjunct is a
// hack to allow the collection of the younger gen first if the flag is // hack to allow the collection of the younger gen first if the flag is
// set. This is better than using th policy's should_collect_gen0_first() // set.
// since that causes us to do an extra unnecessary pair of restart-&-stop-world.
virtual bool full_collects_younger_generations() const { virtual bool full_collects_younger_generations() const {
return UseCMSCompactAtFullCollection && !CollectGen0First; return UseCMSCompactAtFullCollection && !ScavengeBeforeFullGC;
} }
void space_iterate(SpaceClosure* blk, bool usedOnly = false); void space_iterate(SpaceClosure* blk, bool usedOnly = false);

View File

@ -3622,7 +3622,7 @@ void G1CollectedHeap::gc_threads_do(ThreadClosure* tc) const {
void G1CollectedHeap::print_tracing_info() const { void G1CollectedHeap::print_tracing_info() const {
// We'll overload this to mean "trace GC pause statistics." // We'll overload this to mean "trace GC pause statistics."
if (TraceGen0Time || TraceGen1Time) { if (TraceYoungGenTime || TraceOldGenTime) {
// The "G1CollectorPolicy" is keeping track of these stats, so delegate // The "G1CollectorPolicy" is keeping track of these stats, so delegate
// to that. // to that.
g1_policy()->print_tracing_info(); g1_policy()->print_tracing_info();

View File

@ -809,7 +809,7 @@ void G1CollectorPolicy::record_full_collection_end() {
double full_gc_time_sec = end_sec - _full_collection_start_sec; double full_gc_time_sec = end_sec - _full_collection_start_sec;
double full_gc_time_ms = full_gc_time_sec * 1000.0; double full_gc_time_ms = full_gc_time_sec * 1000.0;
_trace_gen1_time_data.record_full_collection(full_gc_time_ms); _trace_old_gen_time_data.record_full_collection(full_gc_time_ms);
update_recent_gc_times(end_sec, full_gc_time_ms); update_recent_gc_times(end_sec, full_gc_time_ms);
@ -851,7 +851,7 @@ void G1CollectorPolicy::record_collection_pause_start(double start_time_sec) {
_g1->used(), _g1->recalculate_used())); _g1->used(), _g1->recalculate_used()));
double s_w_t_ms = (start_time_sec - _stop_world_start) * 1000.0; double s_w_t_ms = (start_time_sec - _stop_world_start) * 1000.0;
_trace_gen0_time_data.record_start_collection(s_w_t_ms); _trace_young_gen_time_data.record_start_collection(s_w_t_ms);
_stop_world_start = 0.0; _stop_world_start = 0.0;
record_heap_size_info_at_start(false /* full */); record_heap_size_info_at_start(false /* full */);
@ -906,7 +906,7 @@ void G1CollectorPolicy::record_concurrent_mark_cleanup_completed() {
void G1CollectorPolicy::record_concurrent_pause() { void G1CollectorPolicy::record_concurrent_pause() {
if (_stop_world_start > 0.0) { if (_stop_world_start > 0.0) {
double yield_ms = (os::elapsedTime() - _stop_world_start) * 1000.0; double yield_ms = (os::elapsedTime() - _stop_world_start) * 1000.0;
_trace_gen0_time_data.record_yield_time(yield_ms); _trace_young_gen_time_data.record_yield_time(yield_ms);
} }
} }
@ -993,7 +993,7 @@ void G1CollectorPolicy::record_collection_pause_end(double pause_time_ms, Evacua
evacuation_info.set_bytes_copied(_bytes_copied_during_gc); evacuation_info.set_bytes_copied(_bytes_copied_during_gc);
if (update_stats) { if (update_stats) {
_trace_gen0_time_data.record_end_collection(pause_time_ms, phase_times()); _trace_young_gen_time_data.record_end_collection(pause_time_ms, phase_times());
// this is where we update the allocation rate of the application // this is where we update the allocation rate of the application
double app_time_ms = double app_time_ms =
(phase_times()->cur_collection_start_sec() * 1000.0 - _prev_collection_pause_end_ms); (phase_times()->cur_collection_start_sec() * 1000.0 - _prev_collection_pause_end_ms);
@ -1415,8 +1415,8 @@ size_t G1CollectorPolicy::expansion_amount() {
} }
void G1CollectorPolicy::print_tracing_info() const { void G1CollectorPolicy::print_tracing_info() const {
_trace_gen0_time_data.print(); _trace_young_gen_time_data.print();
_trace_gen1_time_data.print(); _trace_old_gen_time_data.print();
} }
void G1CollectorPolicy::print_yg_surv_rate_info() const { void G1CollectorPolicy::print_yg_surv_rate_info() const {
@ -1973,9 +1973,9 @@ void G1CollectorPolicy::finalize_cset(double target_pause_time_ms, EvacuationInf
_last_gc_was_young = gcs_are_young() ? true : false; _last_gc_was_young = gcs_are_young() ? true : false;
if (_last_gc_was_young) { if (_last_gc_was_young) {
_trace_gen0_time_data.increment_young_collection_count(); _trace_young_gen_time_data.increment_young_collection_count();
} else { } else {
_trace_gen0_time_data.increment_mixed_collection_count(); _trace_young_gen_time_data.increment_mixed_collection_count();
} }
// The young list is laid with the survivor regions from the previous // The young list is laid with the survivor regions from the previous
@ -2156,20 +2156,20 @@ void G1CollectorPolicy::finalize_cset(double target_pause_time_ms, EvacuationInf
evacuation_info.set_collectionset_regions(cset_region_length()); evacuation_info.set_collectionset_regions(cset_region_length());
} }
void TraceGen0TimeData::record_start_collection(double time_to_stop_the_world_ms) { void TraceYoungGenTimeData::record_start_collection(double time_to_stop_the_world_ms) {
if(TraceGen0Time) { if(TraceYoungGenTime) {
_all_stop_world_times_ms.add(time_to_stop_the_world_ms); _all_stop_world_times_ms.add(time_to_stop_the_world_ms);
} }
} }
void TraceGen0TimeData::record_yield_time(double yield_time_ms) { void TraceYoungGenTimeData::record_yield_time(double yield_time_ms) {
if(TraceGen0Time) { if(TraceYoungGenTime) {
_all_yield_times_ms.add(yield_time_ms); _all_yield_times_ms.add(yield_time_ms);
} }
} }
void TraceGen0TimeData::record_end_collection(double pause_time_ms, G1GCPhaseTimes* phase_times) { void TraceYoungGenTimeData::record_end_collection(double pause_time_ms, G1GCPhaseTimes* phase_times) {
if(TraceGen0Time) { if(TraceYoungGenTime) {
_total.add(pause_time_ms); _total.add(pause_time_ms);
_other.add(pause_time_ms - phase_times->accounted_time_ms()); _other.add(pause_time_ms - phase_times->accounted_time_ms());
_root_region_scan_wait.add(phase_times->root_region_scan_wait_time_ms()); _root_region_scan_wait.add(phase_times->root_region_scan_wait_time_ms());
@ -2194,34 +2194,34 @@ void TraceGen0TimeData::record_end_collection(double pause_time_ms, G1GCPhaseTim
} }
} }
void TraceGen0TimeData::increment_young_collection_count() { void TraceYoungGenTimeData::increment_young_collection_count() {
if(TraceGen0Time) { if(TraceYoungGenTime) {
++_young_pause_num; ++_young_pause_num;
} }
} }
void TraceGen0TimeData::increment_mixed_collection_count() { void TraceYoungGenTimeData::increment_mixed_collection_count() {
if(TraceGen0Time) { if(TraceYoungGenTime) {
++_mixed_pause_num; ++_mixed_pause_num;
} }
} }
void TraceGen0TimeData::print_summary(const char* str, void TraceYoungGenTimeData::print_summary(const char* str,
const NumberSeq* seq) const { const NumberSeq* seq) const {
double sum = seq->sum(); double sum = seq->sum();
gclog_or_tty->print_cr("%-27s = %8.2lf s (avg = %8.2lf ms)", gclog_or_tty->print_cr("%-27s = %8.2lf s (avg = %8.2lf ms)",
str, sum / 1000.0, seq->avg()); str, sum / 1000.0, seq->avg());
} }
void TraceGen0TimeData::print_summary_sd(const char* str, void TraceYoungGenTimeData::print_summary_sd(const char* str,
const NumberSeq* seq) const { const NumberSeq* seq) const {
print_summary(str, seq); print_summary(str, seq);
gclog_or_tty->print_cr("%+45s = %5d, std dev = %8.2lf ms, max = %8.2lf ms)", gclog_or_tty->print_cr("%+45s = %5d, std dev = %8.2lf ms, max = %8.2lf ms)",
"(num", seq->num(), seq->sd(), seq->maximum()); "(num", seq->num(), seq->sd(), seq->maximum());
} }
void TraceGen0TimeData::print() const { void TraceYoungGenTimeData::print() const {
if (!TraceGen0Time) { if (!TraceYoungGenTime) {
return; return;
} }
@ -2258,14 +2258,14 @@ void TraceGen0TimeData::print() const {
print_summary_sd(" Yields", &_all_yield_times_ms); print_summary_sd(" Yields", &_all_yield_times_ms);
} }
void TraceGen1TimeData::record_full_collection(double full_gc_time_ms) { void TraceOldGenTimeData::record_full_collection(double full_gc_time_ms) {
if (TraceGen1Time) { if (TraceOldGenTime) {
_all_full_gc_times.add(full_gc_time_ms); _all_full_gc_times.add(full_gc_time_ms);
} }
} }
void TraceGen1TimeData::print() const { void TraceOldGenTimeData::print() const {
if (!TraceGen1Time) { if (!TraceOldGenTime) {
return; return;
} }

View File

@ -38,10 +38,10 @@ class HeapRegion;
class CollectionSetChooser; class CollectionSetChooser;
class G1GCPhaseTimes; class G1GCPhaseTimes;
// TraceGen0Time collects data on _both_ young and mixed evacuation pauses // TraceYoungGenTime collects data on _both_ young and mixed evacuation pauses
// (the latter may contain non-young regions - i.e. regions that are // (the latter may contain non-young regions - i.e. regions that are
// technically in Gen1) while TraceGen1Time collects data about full GCs. // technically in old) while TraceOldGenTime collects data about full GCs.
class TraceGen0TimeData : public CHeapObj<mtGC> { class TraceYoungGenTimeData : public CHeapObj<mtGC> {
private: private:
unsigned _young_pause_num; unsigned _young_pause_num;
unsigned _mixed_pause_num; unsigned _mixed_pause_num;
@ -66,7 +66,7 @@ class TraceGen0TimeData : public CHeapObj<mtGC> {
void print_summary_sd(const char* str, const NumberSeq* seq) const; void print_summary_sd(const char* str, const NumberSeq* seq) const;
public: public:
TraceGen0TimeData() : _young_pause_num(0), _mixed_pause_num(0) {}; TraceYoungGenTimeData() : _young_pause_num(0), _mixed_pause_num(0) {};
void record_start_collection(double time_to_stop_the_world_ms); void record_start_collection(double time_to_stop_the_world_ms);
void record_yield_time(double yield_time_ms); void record_yield_time(double yield_time_ms);
void record_end_collection(double pause_time_ms, G1GCPhaseTimes* phase_times); void record_end_collection(double pause_time_ms, G1GCPhaseTimes* phase_times);
@ -75,7 +75,7 @@ public:
void print() const; void print() const;
}; };
class TraceGen1TimeData : public CHeapObj<mtGC> { class TraceOldGenTimeData : public CHeapObj<mtGC> {
private: private:
NumberSeq _all_full_gc_times; NumberSeq _all_full_gc_times;
@ -187,8 +187,8 @@ private:
TruncatedSeq* _concurrent_mark_remark_times_ms; TruncatedSeq* _concurrent_mark_remark_times_ms;
TruncatedSeq* _concurrent_mark_cleanup_times_ms; TruncatedSeq* _concurrent_mark_cleanup_times_ms;
TraceGen0TimeData _trace_gen0_time_data; TraceYoungGenTimeData _trace_young_gen_time_data;
TraceGen1TimeData _trace_gen1_time_data; TraceOldGenTimeData _trace_old_gen_time_data;
double _stop_world_start; double _stop_world_start;
@ -202,20 +202,20 @@ private:
// locker is active. This should be >= _young_list_target_length; // locker is active. This should be >= _young_list_target_length;
uint _young_list_max_length; uint _young_list_max_length;
bool _last_gc_was_young; bool _last_gc_was_young;
bool _during_marking; bool _during_marking;
bool _in_marking_window; bool _in_marking_window;
bool _in_marking_window_im; bool _in_marking_window_im;
SurvRateGroup* _short_lived_surv_rate_group; SurvRateGroup* _short_lived_surv_rate_group;
SurvRateGroup* _survivor_surv_rate_group; SurvRateGroup* _survivor_surv_rate_group;
// add here any more surv rate groups // add here any more surv rate groups
double _gc_overhead_perc; double _gc_overhead_perc;
double _reserve_factor; double _reserve_factor;
uint _reserve_regions; uint _reserve_regions;
bool during_marking() { bool during_marking() {
return _during_marking; return _during_marking;

View File

@ -35,14 +35,14 @@
AdjoiningGenerations::AdjoiningGenerations(ReservedSpace old_young_rs, AdjoiningGenerations::AdjoiningGenerations(ReservedSpace old_young_rs,
GenerationSizer* policy, GenerationSizer* policy,
size_t alignment) : size_t alignment) :
_virtual_spaces(old_young_rs, policy->min_gen1_size(), _virtual_spaces(old_young_rs, policy->min_old_size(),
policy->min_gen0_size(), alignment) { policy->min_young_size(), alignment) {
size_t init_low_byte_size = policy->initial_gen1_size(); size_t init_low_byte_size = policy->initial_old_size();
size_t min_low_byte_size = policy->min_gen1_size(); size_t min_low_byte_size = policy->min_old_size();
size_t max_low_byte_size = policy->max_gen1_size(); size_t max_low_byte_size = policy->max_old_size();
size_t init_high_byte_size = policy->initial_gen0_size(); size_t init_high_byte_size = policy->initial_young_size();
size_t min_high_byte_size = policy->min_gen0_size(); size_t min_high_byte_size = policy->min_young_size();
size_t max_high_byte_size = policy->max_gen0_size(); size_t max_high_byte_size = policy->max_young_size();
assert(min_low_byte_size <= init_low_byte_size && assert(min_low_byte_size <= init_low_byte_size &&
init_low_byte_size <= max_low_byte_size, "Parameter check"); init_low_byte_size <= max_low_byte_size, "Parameter check");

View File

@ -32,8 +32,8 @@ void GenerationSizer::trace_gen_sizes(const char* const str) {
SIZE_FORMAT "," SIZE_FORMAT " " SIZE_FORMAT "," SIZE_FORMAT " "
SIZE_FORMAT, SIZE_FORMAT,
str, str,
_min_gen1_size / K, _max_gen1_size / K, _min_old_size / K, _max_old_size / K,
_min_gen0_size / K, _max_gen0_size / K, _min_young_size / K, _max_young_size / K,
_max_heap_byte_size / K); _max_heap_byte_size / K);
} }
} }

View File

@ -623,11 +623,11 @@ void ParallelScavengeHeap::print_gc_threads_on(outputStream* st) const {
} }
void ParallelScavengeHeap::print_tracing_info() const { void ParallelScavengeHeap::print_tracing_info() const {
if (TraceGen0Time) { if (TraceYoungGenTime) {
double time = PSScavenge::accumulated_time()->seconds(); double time = PSScavenge::accumulated_time()->seconds();
tty->print_cr("[Accumulated GC generation 0 time %3.7f secs]", time); tty->print_cr("[Accumulated GC generation 0 time %3.7f secs]", time);
} }
if (TraceGen1Time) { if (TraceOldGenTime) {
double time = UseParallelOldGC ? PSParallelCompact::accumulated_time()->seconds() : PSMarkSweep::accumulated_time()->seconds(); double time = UseParallelOldGC ? PSParallelCompact::accumulated_time()->seconds() : PSMarkSweep::accumulated_time()->seconds();
tty->print_cr("[Accumulated GC generation 1 time %3.7f secs]", time); tty->print_cr("[Accumulated GC generation 1 time %3.7f secs]", time);
} }

View File

@ -174,7 +174,7 @@ bool PSMarkSweep::invoke_no_policy(bool clear_all_softrefs) {
TraceCollectorStats tcs(counters()); TraceCollectorStats tcs(counters());
TraceMemoryManagerStats tms(true /* Full GC */,gc_cause); TraceMemoryManagerStats tms(true /* Full GC */,gc_cause);
if (TraceGen1Time) accumulated_time()->start(); if (TraceOldGenTime) accumulated_time()->start();
// Let the size policy know we're starting // Let the size policy know we're starting
size_policy->major_collection_begin(); size_policy->major_collection_begin();
@ -354,7 +354,7 @@ bool PSMarkSweep::invoke_no_policy(bool clear_all_softrefs) {
// We collected the heap, recalculate the metaspace capacity // We collected the heap, recalculate the metaspace capacity
MetaspaceGC::compute_new_size(); MetaspaceGC::compute_new_size();
if (TraceGen1Time) accumulated_time()->stop(); if (TraceOldGenTime) accumulated_time()->stop();
if (PrintGC) { if (PrintGC) {
if (PrintGCDetails) { if (PrintGCDetails) {

View File

@ -2061,7 +2061,7 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
TraceCollectorStats tcs(counters()); TraceCollectorStats tcs(counters());
TraceMemoryManagerStats tms(true /* Full GC */,gc_cause); TraceMemoryManagerStats tms(true /* Full GC */,gc_cause);
if (TraceGen1Time) accumulated_time()->start(); if (TraceOldGenTime) accumulated_time()->start();
// Let the size policy know we're starting // Let the size policy know we're starting
size_policy->major_collection_begin(); size_policy->major_collection_begin();
@ -2188,7 +2188,7 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
// Resize the metaspace capacity after a collection // Resize the metaspace capacity after a collection
MetaspaceGC::compute_new_size(); MetaspaceGC::compute_new_size();
if (TraceGen1Time) accumulated_time()->stop(); if (TraceOldGenTime) accumulated_time()->stop();
if (PrintGC) { if (PrintGC) {
if (PrintGCDetails) { if (PrintGCDetails) {

View File

@ -336,7 +336,7 @@ bool PSScavenge::invoke_no_policy() {
TraceCollectorStats tcs(counters()); TraceCollectorStats tcs(counters());
TraceMemoryManagerStats tms(false /* not full GC */,gc_cause); TraceMemoryManagerStats tms(false /* not full GC */,gc_cause);
if (TraceGen0Time) accumulated_time()->start(); if (TraceYoungGenTime) accumulated_time()->start();
// Let the size policy know we're starting // Let the size policy know we're starting
size_policy->minor_collection_begin(); size_policy->minor_collection_begin();
@ -660,7 +660,7 @@ bool PSScavenge::invoke_no_policy() {
CardTableExtension::verify_all_young_refs_imprecise(); CardTableExtension::verify_all_young_refs_imprecise();
} }
if (TraceGen0Time) accumulated_time()->stop(); if (TraceYoungGenTime) accumulated_time()->stop();
if (PrintGC) { if (PrintGC) {
if (PrintGCDetails) { if (PrintGCDetails) {

View File

@ -196,13 +196,13 @@ size_t CollectorPolicy::compute_heap_alignment() {
// GenCollectorPolicy methods // GenCollectorPolicy methods
GenCollectorPolicy::GenCollectorPolicy() : GenCollectorPolicy::GenCollectorPolicy() :
_min_gen0_size(0), _min_young_size(0),
_initial_gen0_size(0), _initial_young_size(0),
_max_gen0_size(0), _max_young_size(0),
_gen_alignment(0), _gen_alignment(0),
_min_gen1_size(0), _min_old_size(0),
_initial_gen1_size(0), _initial_old_size(0),
_max_gen1_size(0), _max_old_size(0),
_generations(NULL) _generations(NULL)
{} {}
@ -236,7 +236,7 @@ size_t GenCollectorPolicy::young_gen_size_lower_bound() {
#ifdef ASSERT #ifdef ASSERT
void GenCollectorPolicy::assert_flags() { void GenCollectorPolicy::assert_flags() {
CollectorPolicy::assert_flags(); CollectorPolicy::assert_flags();
assert(NewSize >= _min_gen0_size, "Ergonomics decided on a too small young gen size"); assert(NewSize >= _min_young_size, "Ergonomics decided on a too small young gen size");
assert(NewSize <= MaxNewSize, "Ergonomics decided on incompatible initial and maximum young gen sizes"); assert(NewSize <= MaxNewSize, "Ergonomics decided on incompatible initial and maximum young gen sizes");
assert(FLAG_IS_DEFAULT(MaxNewSize) || MaxNewSize < MaxHeapSize, "Ergonomics decided on incompatible maximum young gen and heap sizes"); assert(FLAG_IS_DEFAULT(MaxNewSize) || MaxNewSize < MaxHeapSize, "Ergonomics decided on incompatible maximum young gen and heap sizes");
assert(NewSize % _gen_alignment == 0, "NewSize alignment"); assert(NewSize % _gen_alignment == 0, "NewSize alignment");
@ -249,28 +249,28 @@ void GenCollectorPolicy::assert_size_info() {
CollectorPolicy::assert_size_info(); CollectorPolicy::assert_size_info();
// GenCollectorPolicy::initialize_size_info may update the MaxNewSize // GenCollectorPolicy::initialize_size_info may update the MaxNewSize
assert(MaxNewSize < MaxHeapSize, "Ergonomics decided on incompatible maximum young and heap sizes"); assert(MaxNewSize < MaxHeapSize, "Ergonomics decided on incompatible maximum young and heap sizes");
assert(NewSize == _initial_gen0_size, "Discrepancy between NewSize flag and local storage"); assert(NewSize == _initial_young_size, "Discrepancy between NewSize flag and local storage");
assert(MaxNewSize == _max_gen0_size, "Discrepancy between MaxNewSize flag and local storage"); assert(MaxNewSize == _max_young_size, "Discrepancy between MaxNewSize flag and local storage");
assert(OldSize == _initial_gen1_size, "Discrepancy between OldSize flag and local storage"); assert(OldSize == _initial_old_size, "Discrepancy between OldSize flag and local storage");
assert(_min_gen0_size <= _initial_gen0_size, "Ergonomics decided on incompatible minimum and initial young gen sizes"); assert(_min_young_size <= _initial_young_size, "Ergonomics decided on incompatible minimum and initial young gen sizes");
assert(_initial_gen0_size <= _max_gen0_size, "Ergonomics decided on incompatible initial and maximum young gen sizes"); assert(_initial_young_size <= _max_young_size, "Ergonomics decided on incompatible initial and maximum young gen sizes");
assert(_min_gen0_size % _gen_alignment == 0, "_min_gen0_size alignment"); assert(_min_young_size % _gen_alignment == 0, "_min_young_size alignment");
assert(_initial_gen0_size % _gen_alignment == 0, "_initial_gen0_size alignment"); assert(_initial_young_size % _gen_alignment == 0, "_initial_young_size alignment");
assert(_max_gen0_size % _gen_alignment == 0, "_max_gen0_size alignment"); assert(_max_young_size % _gen_alignment == 0, "_max_young_size alignment");
assert(_min_gen0_size <= bound_minus_alignment(_min_gen0_size, _min_heap_byte_size), assert(_min_young_size <= bound_minus_alignment(_min_young_size, _min_heap_byte_size),
"Ergonomics made minimum young generation larger than minimum heap"); "Ergonomics made minimum young generation larger than minimum heap");
assert(_initial_gen0_size <= bound_minus_alignment(_initial_gen0_size, _initial_heap_byte_size), assert(_initial_young_size <= bound_minus_alignment(_initial_young_size, _initial_heap_byte_size),
"Ergonomics made initial young generation larger than initial heap"); "Ergonomics made initial young generation larger than initial heap");
assert(_max_gen0_size <= bound_minus_alignment(_max_gen0_size, _max_heap_byte_size), assert(_max_young_size <= bound_minus_alignment(_max_young_size, _max_heap_byte_size),
"Ergonomics made maximum young generation lager than maximum heap"); "Ergonomics made maximum young generation lager than maximum heap");
assert(_min_gen1_size <= _initial_gen1_size, "Ergonomics decided on incompatible minimum and initial old gen sizes"); assert(_min_old_size <= _initial_old_size, "Ergonomics decided on incompatible minimum and initial old gen sizes");
assert(_initial_gen1_size <= _max_gen1_size, "Ergonomics decided on incompatible initial and maximum old gen sizes"); assert(_initial_old_size <= _max_old_size, "Ergonomics decided on incompatible initial and maximum old gen sizes");
assert(_max_gen1_size % _gen_alignment == 0, "_max_gen1_size alignment"); assert(_max_old_size % _gen_alignment == 0, "_max_old_size alignment");
assert(_initial_gen1_size % _gen_alignment == 0, "_initial_gen1_size alignment"); assert(_initial_old_size % _gen_alignment == 0, "_initial_old_size alignment");
assert(_max_heap_byte_size <= (_max_gen0_size + _max_gen1_size), "Total maximum heap sizes must be sum of generation maximum sizes"); assert(_max_heap_byte_size <= (_max_young_size + _max_old_size), "Total maximum heap sizes must be sum of generation maximum sizes");
assert(_min_gen0_size + _min_gen1_size <= _min_heap_byte_size, "Minimum generation sizes exceed minimum heap size"); assert(_min_young_size + _min_old_size <= _min_heap_byte_size, "Minimum generation sizes exceed minimum heap size");
assert(_initial_gen0_size + _initial_gen1_size == _initial_heap_byte_size, "Initial generation sizes should match initial heap size"); assert(_initial_young_size + _initial_old_size == _initial_heap_byte_size, "Initial generation sizes should match initial heap size");
assert(_max_gen0_size + _max_gen1_size == _max_heap_byte_size, "Maximum generation sizes should match maximum heap size"); assert(_max_young_size + _max_old_size == _max_heap_byte_size, "Maximum generation sizes should match maximum heap size");
} }
#endif // ASSERT #endif // ASSERT
@ -323,8 +323,8 @@ void GenCollectorPolicy::initialize_flags() {
// later when setting the initial and minimum young generation size. // later when setting the initial and minimum young generation size.
NewSize = bounded_new_size; NewSize = bounded_new_size;
} }
_min_gen0_size = smallest_new_size; _min_young_size = smallest_new_size;
_initial_gen0_size = NewSize; _initial_young_size = NewSize;
if (!FLAG_IS_DEFAULT(MaxNewSize)) { if (!FLAG_IS_DEFAULT(MaxNewSize)) {
if (MaxNewSize >= MaxHeapSize) { if (MaxNewSize >= MaxHeapSize) {
@ -338,14 +338,14 @@ void GenCollectorPolicy::initialize_flags() {
FLAG_SET_ERGO(uintx, MaxNewSize, smaller_max_new_size); FLAG_SET_ERGO(uintx, MaxNewSize, smaller_max_new_size);
if (NewSize > MaxNewSize) { if (NewSize > MaxNewSize) {
FLAG_SET_ERGO(uintx, NewSize, MaxNewSize); FLAG_SET_ERGO(uintx, NewSize, MaxNewSize);
_initial_gen0_size = NewSize; _initial_young_size = NewSize;
} }
} else if (MaxNewSize < _initial_gen0_size) { } else if (MaxNewSize < _initial_young_size) {
FLAG_SET_ERGO(uintx, MaxNewSize, _initial_gen0_size); FLAG_SET_ERGO(uintx, MaxNewSize, _initial_young_size);
} else if (!is_size_aligned(MaxNewSize, _gen_alignment)) { } else if (!is_size_aligned(MaxNewSize, _gen_alignment)) {
FLAG_SET_ERGO(uintx, MaxNewSize, align_size_down(MaxNewSize, _gen_alignment)); FLAG_SET_ERGO(uintx, MaxNewSize, align_size_down(MaxNewSize, _gen_alignment));
} }
_max_gen0_size = MaxNewSize; _max_young_size = MaxNewSize;
} }
if (NewSize > MaxNewSize) { if (NewSize > MaxNewSize) {
@ -357,7 +357,7 @@ void GenCollectorPolicy::initialize_flags() {
NewSize/K, MaxNewSize/K, NewSize/K); NewSize/K, MaxNewSize/K, NewSize/K);
} }
FLAG_SET_ERGO(uintx, MaxNewSize, NewSize); FLAG_SET_ERGO(uintx, MaxNewSize, NewSize);
_max_gen0_size = MaxNewSize; _max_young_size = MaxNewSize;
} }
if (SurvivorRatio < 1 || NewRatio < 1) { if (SurvivorRatio < 1 || NewRatio < 1) {
@ -393,7 +393,7 @@ void GenCollectorPolicy::initialize_flags() {
double shrink_factor = (double) MaxHeapSize / calculated_size; double shrink_factor = (double) MaxHeapSize / calculated_size;
uintx smaller_new_size = align_size_down((uintx)(NewSize * shrink_factor), _gen_alignment); uintx smaller_new_size = align_size_down((uintx)(NewSize * shrink_factor), _gen_alignment);
FLAG_SET_ERGO(uintx, NewSize, MAX2(young_gen_size_lower_bound(), smaller_new_size)); FLAG_SET_ERGO(uintx, NewSize, MAX2(young_gen_size_lower_bound(), smaller_new_size));
_initial_gen0_size = NewSize; _initial_young_size = NewSize;
// OldSize is already aligned because above we aligned MaxHeapSize to // OldSize is already aligned because above we aligned MaxHeapSize to
// _heap_alignment, and we just made sure that NewSize is aligned to // _heap_alignment, and we just made sure that NewSize is aligned to
@ -406,16 +406,16 @@ void GenCollectorPolicy::initialize_flags() {
} }
} }
// Update NewSize, if possible, to avoid sizing gen0 to small when only // Update NewSize, if possible, to avoid sizing the young gen too small when only
// OldSize is set on the command line. // OldSize is set on the command line.
if (FLAG_IS_CMDLINE(OldSize) && !FLAG_IS_CMDLINE(NewSize)) { if (FLAG_IS_CMDLINE(OldSize) && !FLAG_IS_CMDLINE(NewSize)) {
if (OldSize < _initial_heap_byte_size) { if (OldSize < _initial_heap_byte_size) {
size_t new_size = _initial_heap_byte_size - OldSize; size_t new_size = _initial_heap_byte_size - OldSize;
// Need to compare against the flag value for max since _max_gen0_size // Need to compare against the flag value for max since _max_young_size
// might not have been set yet. // might not have been set yet.
if (new_size >= _min_gen0_size && new_size <= MaxNewSize) { if (new_size >= _min_young_size && new_size <= MaxNewSize) {
FLAG_SET_ERGO(uintx, NewSize, new_size); FLAG_SET_ERGO(uintx, NewSize, new_size);
_initial_gen0_size = NewSize; _initial_young_size = NewSize;
} }
} }
} }
@ -444,97 +444,77 @@ void GenCollectorPolicy::initialize_flags() {
void GenCollectorPolicy::initialize_size_info() { void GenCollectorPolicy::initialize_size_info() {
CollectorPolicy::initialize_size_info(); CollectorPolicy::initialize_size_info();
// _space_alignment is used for alignment within a generation. _initial_young_size = NewSize;
// There is additional alignment done down stream for some _max_young_size = MaxNewSize;
// collectors that sometimes causes unwanted rounding up of _initial_old_size = OldSize;
// generations sizes.
// Determine maximum size of gen0 // Determine maximum size of the young generation.
size_t max_new_size = 0; if (FLAG_IS_DEFAULT(MaxNewSize)) {
if (!FLAG_IS_DEFAULT(MaxNewSize)) { _max_young_size = scale_by_NewRatio_aligned(_max_heap_byte_size);
max_new_size = MaxNewSize;
} else {
max_new_size = scale_by_NewRatio_aligned(_max_heap_byte_size);
// Bound the maximum size by NewSize below (since it historically // Bound the maximum size by NewSize below (since it historically
// would have been NewSize and because the NewRatio calculation could // would have been NewSize and because the NewRatio calculation could
// yield a size that is too small) and bound it by MaxNewSize above. // yield a size that is too small) and bound it by MaxNewSize above.
// Ergonomics plays here by previously calculating the desired // Ergonomics plays here by previously calculating the desired
// NewSize and MaxNewSize. // NewSize and MaxNewSize.
max_new_size = MIN2(MAX2(max_new_size, NewSize), MaxNewSize); _max_young_size = MIN2(MAX2(_max_young_size, _initial_young_size), MaxNewSize);
} }
assert(max_new_size > 0, "All paths should set max_new_size");
// Given the maximum gen0 size, determine the initial and // Given the maximum young size, determine the initial and
// minimum gen0 sizes. // minimum young sizes.
if (_max_heap_byte_size == _initial_heap_byte_size) { if (_max_heap_byte_size == _initial_heap_byte_size) {
// The maxium and initial heap sizes are the same so the generation's // The maximum and initial heap sizes are the same so the generation's
// initial size must be the same as it maximum size. Use NewSize as the // initial size must be the same as it maximum size. Use NewSize as the
// size if set on command line. // size if set on command line.
size_t fixed_young_size = FLAG_IS_CMDLINE(NewSize) ? NewSize : max_new_size; _max_young_size = FLAG_IS_CMDLINE(NewSize) ? NewSize : _max_young_size;
_initial_young_size = _max_young_size;
_initial_gen0_size = fixed_young_size;
_max_gen0_size = fixed_young_size;
// Also update the minimum size if min == initial == max. // Also update the minimum size if min == initial == max.
if (_max_heap_byte_size == _min_heap_byte_size) { if (_max_heap_byte_size == _min_heap_byte_size) {
_min_gen0_size = fixed_young_size; _min_young_size = _max_young_size;
} }
} else { } else {
size_t desired_new_size = 0;
if (FLAG_IS_CMDLINE(NewSize)) { if (FLAG_IS_CMDLINE(NewSize)) {
// If NewSize is set on the command line, we should use it as // If NewSize is set on the command line, we should use it as
// the initial size, but make sure it is within the heap bounds. // the initial size, but make sure it is within the heap bounds.
desired_new_size = _initial_young_size =
MIN2(max_new_size, bound_minus_alignment(NewSize, _initial_heap_byte_size)); MIN2(_max_young_size, bound_minus_alignment(NewSize, _initial_heap_byte_size));
_min_gen0_size = bound_minus_alignment(desired_new_size, _min_heap_byte_size); _min_young_size = bound_minus_alignment(_initial_young_size, _min_heap_byte_size);
} else { } else {
// For the case where NewSize is not set on the command line, use // For the case where NewSize is not set on the command line, use
// NewRatio to size the initial generation size. Use the current // NewRatio to size the initial generation size. Use the current
// NewSize as the floor, because if NewRatio is overly large, the resulting // NewSize as the floor, because if NewRatio is overly large, the resulting
// size can be too small. // size can be too small.
desired_new_size = _initial_young_size =
MIN2(max_new_size, MAX2(scale_by_NewRatio_aligned(_initial_heap_byte_size), NewSize)); MIN2(_max_young_size, MAX2(scale_by_NewRatio_aligned(_initial_heap_byte_size), NewSize));
} }
_initial_gen0_size = desired_new_size;
_max_gen0_size = max_new_size;
}
// Write back to flags if necessary.
if (NewSize != _initial_gen0_size) {
FLAG_SET_ERGO(uintx, NewSize, _initial_gen0_size);
}
if (MaxNewSize != _max_gen0_size) {
FLAG_SET_ERGO(uintx, MaxNewSize, _max_gen0_size);
} }
if (PrintGCDetails && Verbose) { if (PrintGCDetails && Verbose) {
gclog_or_tty->print_cr("1: Minimum gen0 " SIZE_FORMAT " Initial gen0 " gclog_or_tty->print_cr("1: Minimum young " SIZE_FORMAT " Initial young "
SIZE_FORMAT " Maximum gen0 " SIZE_FORMAT, SIZE_FORMAT " Maximum young " SIZE_FORMAT,
_min_gen0_size, _initial_gen0_size, _max_gen0_size); _min_young_size, _initial_young_size, _max_young_size);
} }
// At this point the minimum, initial and maximum sizes // At this point the minimum, initial and maximum sizes
// of the overall heap and of gen0 have been determined. // of the overall heap and of the young generation have been determined.
// The maximum gen1 size can be determined from the maximum gen0 // The maximum old size can be determined from the maximum young
// and maximum heap size since no explicit flags exist // and maximum heap size since no explicit flags exist
// for setting the gen1 maximum. // for setting the old generation maximum.
_max_gen1_size = MAX2(_max_heap_byte_size - _max_gen0_size, _gen_alignment); _max_old_size = MAX2(_max_heap_byte_size - _max_young_size, _gen_alignment);
// If no explicit command line flag has been set for the // If no explicit command line flag has been set for the
// gen1 size, use what is left for gen1 // old generation size, use what is left.
if (!FLAG_IS_CMDLINE(OldSize)) { if (!FLAG_IS_CMDLINE(OldSize)) {
// The user has not specified any value but the ergonomics // The user has not specified any value but the ergonomics
// may have chosen a value (which may or may not be consistent // may have chosen a value (which may or may not be consistent
// with the overall heap size). In either case make // with the overall heap size). In either case make
// the minimum, maximum and initial sizes consistent // the minimum, maximum and initial sizes consistent
// with the gen0 sizes and the overall heap sizes. // with the young sizes and the overall heap sizes.
_min_gen1_size = _gen_alignment; _min_old_size = _gen_alignment;
_initial_gen1_size = MIN2(_max_gen1_size, MAX2(_initial_heap_byte_size - _initial_gen0_size, _min_gen1_size)); _initial_old_size = MIN2(_max_old_size, MAX2(_initial_heap_byte_size - _initial_young_size, _min_old_size));
// _max_gen1_size has already been made consistent above // _max_old_size has already been made consistent above.
FLAG_SET_ERGO(uintx, OldSize, _initial_gen1_size);
} else { } else {
// OldSize has been explicitly set on the command line. Use it // OldSize has been explicitly set on the command line. Use it
// for the initial size but make sure the minimum allow a young // for the initial size but make sure the minimum allow a young
@ -543,69 +523,68 @@ void GenCollectorPolicy::initialize_size_info() {
// with other command line flags, issue a warning. // with other command line flags, issue a warning.
// The generation minimums and the overall heap minimum should // The generation minimums and the overall heap minimum should
// be within one generation alignment. // be within one generation alignment.
if (OldSize > _max_gen1_size) { if (_initial_old_size > _max_old_size) {
warning("Inconsistency between maximum heap size and maximum " warning("Inconsistency between maximum heap size and maximum "
"generation sizes: using maximum heap = " SIZE_FORMAT "generation sizes: using maximum heap = " SIZE_FORMAT
" -XX:OldSize flag is being ignored", " -XX:OldSize flag is being ignored",
_max_heap_byte_size); _max_heap_byte_size);
FLAG_SET_ERGO(uintx, OldSize, _max_gen1_size); _initial_old_size = _max_old_size;
} }
_min_gen1_size = MIN2(OldSize, _min_heap_byte_size - _min_gen0_size); _min_old_size = MIN2(_initial_old_size, _min_heap_byte_size - _min_young_size);
_initial_gen1_size = OldSize;
} }
// The initial generation sizes should match the initial heap size, // The initial generation sizes should match the initial heap size,
// if not issue a warning and resize the generations. This behavior // if not issue a warning and resize the generations. This behavior
// differs from JDK8 where the generation sizes have higher priority // differs from JDK8 where the generation sizes have higher priority
// than the initial heap size. // than the initial heap size.
if ((_initial_gen1_size + _initial_gen0_size) != _initial_heap_byte_size) { if ((_initial_old_size + _initial_young_size) != _initial_heap_byte_size) {
warning("Inconsistency between generation sizes and heap size, resizing " warning("Inconsistency between generation sizes and heap size, resizing "
"the generations to fit the heap."); "the generations to fit the heap.");
size_t desired_gen0_size = _initial_heap_byte_size - _initial_gen1_size; size_t desired_young_size = _initial_heap_byte_size - _initial_old_size;
if (_initial_heap_byte_size < _initial_gen1_size) { if (_initial_heap_byte_size < _initial_old_size) {
// Old want all memory, use minimum for young and rest for old // Old want all memory, use minimum for young and rest for old
_initial_gen0_size = _min_gen0_size; _initial_young_size = _min_young_size;
_initial_gen1_size = _initial_heap_byte_size - _min_gen0_size; _initial_old_size = _initial_heap_byte_size - _min_young_size;
} else if (desired_gen0_size > _max_gen0_size) { } else if (desired_young_size > _max_young_size) {
// Need to increase both young and old generation // Need to increase both young and old generation
_initial_gen0_size = _max_gen0_size; _initial_young_size = _max_young_size;
_initial_gen1_size = _initial_heap_byte_size - _max_gen0_size; _initial_old_size = _initial_heap_byte_size - _max_young_size;
} else if (desired_gen0_size < _min_gen0_size) { } else if (desired_young_size < _min_young_size) {
// Need to decrease both young and old generation // Need to decrease both young and old generation
_initial_gen0_size = _min_gen0_size; _initial_young_size = _min_young_size;
_initial_gen1_size = _initial_heap_byte_size - _min_gen0_size; _initial_old_size = _initial_heap_byte_size - _min_young_size;
} else { } else {
// The young generation boundaries allow us to only update the // The young generation boundaries allow us to only update the
// young generation. // young generation.
_initial_gen0_size = desired_gen0_size; _initial_young_size = desired_young_size;
} }
if (PrintGCDetails && Verbose) { if (PrintGCDetails && Verbose) {
gclog_or_tty->print_cr("2: Minimum gen0 " SIZE_FORMAT " Initial gen0 " gclog_or_tty->print_cr("2: Minimum young " SIZE_FORMAT " Initial young "
SIZE_FORMAT " Maximum gen0 " SIZE_FORMAT, SIZE_FORMAT " Maximum young " SIZE_FORMAT,
_min_gen0_size, _initial_gen0_size, _max_gen0_size); _min_young_size, _initial_young_size, _max_young_size);
} }
} }
// Write back to flags if necessary // Write back to flags if necessary.
if (NewSize != _initial_gen0_size) { if (NewSize != _initial_young_size) {
FLAG_SET_ERGO(uintx, NewSize, _initial_gen0_size); FLAG_SET_ERGO(uintx, NewSize, _initial_young_size);
} }
if (MaxNewSize != _max_gen0_size) { if (MaxNewSize != _max_young_size) {
FLAG_SET_ERGO(uintx, MaxNewSize, _max_gen0_size); FLAG_SET_ERGO(uintx, MaxNewSize, _max_young_size);
} }
if (OldSize != _initial_gen1_size) { if (OldSize != _initial_old_size) {
FLAG_SET_ERGO(uintx, OldSize, _initial_gen1_size); FLAG_SET_ERGO(uintx, OldSize, _initial_old_size);
} }
if (PrintGCDetails && Verbose) { if (PrintGCDetails && Verbose) {
gclog_or_tty->print_cr("Minimum gen1 " SIZE_FORMAT " Initial gen1 " gclog_or_tty->print_cr("Minimum old " SIZE_FORMAT " Initial old "
SIZE_FORMAT " Maximum gen1 " SIZE_FORMAT, SIZE_FORMAT " Maximum old " SIZE_FORMAT,
_min_gen1_size, _initial_gen1_size, _max_gen1_size); _min_old_size, _initial_old_size, _max_old_size);
} }
DEBUG_ONLY(GenCollectorPolicy::assert_size_info();) DEBUG_ONLY(GenCollectorPolicy::assert_size_info();)
@ -631,11 +610,11 @@ HeapWord* GenCollectorPolicy::mem_allocate_work(size_t size,
HandleMark hm; // Discard any handles allocated in each iteration. HandleMark hm; // Discard any handles allocated in each iteration.
// First allocation attempt is lock-free. // First allocation attempt is lock-free.
Generation *gen0 = gch->get_gen(0); Generation *young = gch->get_gen(0);
assert(gen0->supports_inline_contig_alloc(), assert(young->supports_inline_contig_alloc(),
"Otherwise, must do alloc within heap lock"); "Otherwise, must do alloc within heap lock");
if (gen0->should_allocate(size, is_tlab)) { if (young->should_allocate(size, is_tlab)) {
result = gen0->par_allocate(size, is_tlab); result = young->par_allocate(size, is_tlab);
if (result != NULL) { if (result != NULL) {
assert(gch->is_in_reserved(result), "result not in heap"); assert(gch->is_in_reserved(result), "result not in heap");
return result; return result;
@ -917,8 +896,8 @@ MetaWord* CollectorPolicy::satisfy_failed_metadata_allocation(
bool GenCollectorPolicy::should_try_older_generation_allocation( bool GenCollectorPolicy::should_try_older_generation_allocation(
size_t word_size) const { size_t word_size) const {
GenCollectedHeap* gch = GenCollectedHeap::heap(); GenCollectedHeap* gch = GenCollectedHeap::heap();
size_t gen0_capacity = gch->get_gen(0)->capacity_before_gc(); size_t young_capacity = gch->get_gen(0)->capacity_before_gc();
return (word_size > heap_word_size(gen0_capacity)) return (word_size > heap_word_size(young_capacity))
|| GC_locker::is_active_and_needs_gc() || GC_locker::is_active_and_needs_gc()
|| gch->incremental_collection_failed(); || gch->incremental_collection_failed();
} }
@ -940,11 +919,11 @@ void MarkSweepPolicy::initialize_generations() {
} }
if (UseParNewGC) { if (UseParNewGC) {
_generations[0] = new GenerationSpec(Generation::ParNew, _initial_gen0_size, _max_gen0_size); _generations[0] = new GenerationSpec(Generation::ParNew, _initial_young_size, _max_young_size);
} else { } else {
_generations[0] = new GenerationSpec(Generation::DefNew, _initial_gen0_size, _max_gen0_size); _generations[0] = new GenerationSpec(Generation::DefNew, _initial_young_size, _max_young_size);
} }
_generations[1] = new GenerationSpec(Generation::MarkSweepCompact, _initial_gen1_size, _max_gen1_size); _generations[1] = new GenerationSpec(Generation::MarkSweepCompact, _initial_old_size, _max_old_size);
if (_generations[0] == NULL || _generations[1] == NULL) { if (_generations[0] == NULL || _generations[1] == NULL) {
vm_exit_during_initialization("Unable to allocate gen spec"); vm_exit_during_initialization("Unable to allocate gen spec");
@ -978,18 +957,18 @@ public:
flag_value = 20 * M; flag_value = 20 * M;
set_basic_flag_values(); set_basic_flag_values();
FLAG_SET_CMDLINE(uintx, NewSize, flag_value); FLAG_SET_CMDLINE(uintx, NewSize, flag_value);
verify_gen0_min(flag_value); verify_young_min(flag_value);
set_basic_flag_values(); set_basic_flag_values();
FLAG_SET_CMDLINE(uintx, NewSize, flag_value); FLAG_SET_CMDLINE(uintx, NewSize, flag_value);
verify_gen0_initial(flag_value); verify_young_initial(flag_value);
// If NewSize is set on command line, but is larger than the min // If NewSize is set on command line, but is larger than the min
// heap size, it should only be used for initial young size. // heap size, it should only be used for initial young size.
flag_value = 80 * M; flag_value = 80 * M;
set_basic_flag_values(); set_basic_flag_values();
FLAG_SET_CMDLINE(uintx, NewSize, flag_value); FLAG_SET_CMDLINE(uintx, NewSize, flag_value);
verify_gen0_initial(flag_value); verify_young_initial(flag_value);
// If NewSize has been ergonomically set, the collector policy // If NewSize has been ergonomically set, the collector policy
// should use it for min but calculate the initial young size // should use it for min but calculate the initial young size
@ -997,11 +976,11 @@ public:
flag_value = 20 * M; flag_value = 20 * M;
set_basic_flag_values(); set_basic_flag_values();
FLAG_SET_ERGO(uintx, NewSize, flag_value); FLAG_SET_ERGO(uintx, NewSize, flag_value);
verify_gen0_min(flag_value); verify_young_min(flag_value);
set_basic_flag_values(); set_basic_flag_values();
FLAG_SET_ERGO(uintx, NewSize, flag_value); FLAG_SET_ERGO(uintx, NewSize, flag_value);
verify_scaled_gen0_initial(InitialHeapSize); verify_scaled_young_initial(InitialHeapSize);
restore_flags(); restore_flags();
} }
@ -1016,11 +995,11 @@ public:
flag_value = 20 * M; flag_value = 20 * M;
set_basic_flag_values(); set_basic_flag_values();
FLAG_SET_CMDLINE(uintx, OldSize, flag_value); FLAG_SET_CMDLINE(uintx, OldSize, flag_value);
verify_gen1_min(flag_value); verify_old_min(flag_value);
set_basic_flag_values(); set_basic_flag_values();
FLAG_SET_CMDLINE(uintx, OldSize, flag_value); FLAG_SET_CMDLINE(uintx, OldSize, flag_value);
verify_gen1_initial(flag_value); verify_old_initial(flag_value);
// If MaxNewSize is large, the maximum OldSize will be less than // If MaxNewSize is large, the maximum OldSize will be less than
// what's requested on the command line and it should be reset // what's requested on the command line and it should be reset
@ -1031,46 +1010,46 @@ public:
FLAG_SET_CMDLINE(uintx, MaxNewSize, 170*M); FLAG_SET_CMDLINE(uintx, MaxNewSize, 170*M);
// Calculate what we expect the flag to be. // Calculate what we expect the flag to be.
flag_value = MaxHeapSize - MaxNewSize; flag_value = MaxHeapSize - MaxNewSize;
verify_gen1_initial(flag_value); verify_old_initial(flag_value);
} }
static void verify_gen0_min(size_t expected) { static void verify_young_min(size_t expected) {
MarkSweepPolicy msp; MarkSweepPolicy msp;
msp.initialize_all(); msp.initialize_all();
assert(msp.min_gen0_size() <= expected, err_msg("%zu > %zu", msp.min_gen0_size(), expected)); assert(msp.min_young_size() <= expected, err_msg("%zu > %zu", msp.min_young_size(), expected));
} }
static void verify_gen0_initial(size_t expected) { static void verify_young_initial(size_t expected) {
MarkSweepPolicy msp; MarkSweepPolicy msp;
msp.initialize_all(); msp.initialize_all();
assert(msp.initial_gen0_size() == expected, err_msg("%zu != %zu", msp.initial_gen0_size(), expected)); assert(msp.initial_young_size() == expected, err_msg("%zu != %zu", msp.initial_young_size(), expected));
} }
static void verify_scaled_gen0_initial(size_t initial_heap_size) { static void verify_scaled_young_initial(size_t initial_heap_size) {
MarkSweepPolicy msp; MarkSweepPolicy msp;
msp.initialize_all(); msp.initialize_all();
size_t expected = msp.scale_by_NewRatio_aligned(initial_heap_size); size_t expected = msp.scale_by_NewRatio_aligned(initial_heap_size);
assert(msp.initial_gen0_size() == expected, err_msg("%zu != %zu", msp.initial_gen0_size(), expected)); assert(msp.initial_young_size() == expected, err_msg("%zu != %zu", msp.initial_young_size(), expected));
assert(FLAG_IS_ERGO(NewSize) && NewSize == expected, assert(FLAG_IS_ERGO(NewSize) && NewSize == expected,
err_msg("NewSize should have been set ergonomically to %zu, but was %zu", expected, NewSize)); err_msg("NewSize should have been set ergonomically to %zu, but was %zu", expected, NewSize));
} }
static void verify_gen1_min(size_t expected) { static void verify_old_min(size_t expected) {
MarkSweepPolicy msp; MarkSweepPolicy msp;
msp.initialize_all(); msp.initialize_all();
assert(msp.min_gen1_size() <= expected, err_msg("%zu > %zu", msp.min_gen1_size(), expected)); assert(msp.min_old_size() <= expected, err_msg("%zu > %zu", msp.min_old_size(), expected));
} }
static void verify_gen1_initial(size_t expected) { static void verify_old_initial(size_t expected) {
MarkSweepPolicy msp; MarkSweepPolicy msp;
msp.initialize_all(); msp.initialize_all();
assert(msp.initial_gen1_size() == expected, err_msg("%zu != %zu", msp.initial_gen1_size(), expected)); assert(msp.initial_old_size() == expected, err_msg("%zu != %zu", msp.initial_old_size(), expected));
} }

View File

@ -219,12 +219,12 @@ class ClearedAllSoftRefs : public StackObj {
class GenCollectorPolicy : public CollectorPolicy { class GenCollectorPolicy : public CollectorPolicy {
friend class TestGenCollectorPolicy; friend class TestGenCollectorPolicy;
protected: protected:
size_t _min_gen0_size; size_t _min_young_size;
size_t _initial_gen0_size; size_t _initial_young_size;
size_t _max_gen0_size; size_t _max_young_size;
size_t _min_gen1_size; size_t _min_old_size;
size_t _initial_gen1_size; size_t _initial_old_size;
size_t _max_gen1_size; size_t _max_old_size;
// _gen_alignment and _space_alignment will have the same value most of the // _gen_alignment and _space_alignment will have the same value most of the
// time. When using large pages they can differ. // time. When using large pages they can differ.
@ -260,13 +260,13 @@ friend class TestGenCollectorPolicy;
GenCollectorPolicy(); GenCollectorPolicy();
// Accessors // Accessors
size_t min_gen0_size() { return _min_gen0_size; } size_t min_young_size() { return _min_young_size; }
size_t initial_gen0_size() { return _initial_gen0_size; } size_t initial_young_size() { return _initial_young_size; }
size_t max_gen0_size() { return _max_gen0_size; } size_t max_young_size() { return _max_young_size; }
size_t gen_alignment() { return _gen_alignment; } size_t gen_alignment() { return _gen_alignment; }
size_t min_gen1_size() { return _min_gen1_size; } size_t min_old_size() { return _min_old_size; }
size_t initial_gen1_size() { return _initial_gen1_size; } size_t initial_old_size() { return _initial_old_size; }
size_t max_gen1_size() { return _max_gen1_size; } size_t max_old_size() { return _max_old_size; }
int number_of_generations() { return 2; } int number_of_generations() { return 2; }
@ -298,7 +298,7 @@ friend class TestGenCollectorPolicy;
size_t init_survivor_size); size_t init_survivor_size);
virtual void post_heap_initialize() { virtual void post_heap_initialize() {
assert(_max_gen0_size == MaxNewSize, "Should be taken care of by initialize_size_info"); assert(_max_young_size == MaxNewSize, "Should be taken care of by initialize_size_info");
} }
BarrierSet::Name barrier_set_name() { return BarrierSet::CardTableModRef; } BarrierSet::Name barrier_set_name() { return BarrierSet::CardTableModRef; }

View File

@ -1119,10 +1119,10 @@ void GenCollectedHeap::print_on_error(outputStream* st) const {
} }
void GenCollectedHeap::print_tracing_info() const { void GenCollectedHeap::print_tracing_info() const {
if (TraceGen0Time) { if (TraceYoungGenTime) {
get_gen(0)->print_summary_info(); get_gen(0)->print_summary_info();
} }
if (TraceGen1Time) { if (TraceOldGenTime) {
get_gen(1)->print_summary_info(); get_gen(1)->print_summary_info();
} }
} }

View File

@ -67,10 +67,9 @@ class TenuredGeneration: public OneContigSpaceCardGeneration {
// Does a "full" (forced) collection invoked on this generation collect // Does a "full" (forced) collection invoked on this generation collect
// all younger generations as well? Note that this is a // all younger generations as well? Note that this is a
// hack to allow the collection of the younger gen first if the flag is // hack to allow the collection of the younger gen first if the flag is
// set. This is better than using th policy's should_collect_gen0_first() // set.
// since that causes us to do an extra unnecessary pair of restart-&-stop-world.
virtual bool full_collects_younger_generations() const { virtual bool full_collects_younger_generations() const {
return !CollectGen0First; return !ScavengeBeforeFullGC;
} }
virtual void gc_prologue(bool full); virtual void gc_prologue(bool full);

View File

@ -2187,6 +2187,10 @@ bool Arguments::check_vm_args_consistency() {
} }
} }
if (!(UseParallelGC || UseParallelOldGC) && FLAG_IS_DEFAULT(ScavengeBeforeFullGC)) {
FLAG_SET_DEFAULT(ScavengeBeforeFullGC, false);
}
status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit"); status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit");
status = status && verify_percentage(GCTimeLimit, "GCTimeLimit"); status = status && verify_percentage(GCTimeLimit, "GCTimeLimit");
if (GCTimeLimit == 100) { if (GCTimeLimit == 100) {

View File

@ -1450,8 +1450,7 @@ class CommandLineFlags {
"(ParallelGC only)") \ "(ParallelGC only)") \
\ \
product(bool, ScavengeBeforeFullGC, true, \ product(bool, ScavengeBeforeFullGC, true, \
"Scavenge youngest generation before each full GC, " \ "Scavenge youngest generation before each full GC.") \
"used with UseParallelGC") \
\ \
develop(bool, ScavengeWithObjectsInToSpace, false, \ develop(bool, ScavengeWithObjectsInToSpace, false, \
"Allow scavenges to occur when to-space contains objects") \ "Allow scavenges to occur when to-space contains objects") \
@ -2252,9 +2251,6 @@ class CommandLineFlags {
notproduct(bool, CheckMemoryInitialization, false, \ notproduct(bool, CheckMemoryInitialization, false, \
"Check memory initialization") \ "Check memory initialization") \
\ \
product(bool, CollectGen0First, false, \
"Collect youngest generation before each full GC") \
\
diagnostic(bool, BindCMSThreadToCPU, false, \ diagnostic(bool, BindCMSThreadToCPU, false, \
"Bind CMS Thread to CPU if possible") \ "Bind CMS Thread to CPU if possible") \
\ \
@ -2333,11 +2329,11 @@ class CommandLineFlags {
NOT_LP64(2200*K) LP64_ONLY(4*M), \ NOT_LP64(2200*K) LP64_ONLY(4*M), \
"Initial size of the boot class loader data metaspace") \ "Initial size of the boot class loader data metaspace") \
\ \
product(bool, TraceGen0Time, false, \ product(bool, TraceYoungGenTime, false, \
"Trace accumulated time for Gen 0 collection") \ "Trace accumulated time for young collection") \
\ \
product(bool, TraceGen1Time, false, \ product(bool, TraceOldGenTime, false, \
"Trace accumulated time for Gen 1 collection") \ "Trace accumulated time for old collection") \
\ \
product(bool, PrintTenuringDistribution, false, \ product(bool, PrintTenuringDistribution, false, \
"Print tenuring age information") \ "Print tenuring age information") \