8139772: Cleanups in Generation related code

Reviewed-by: tbenson, mgerdin
This commit is contained in:
Jesper Wilhelmsson 2015-10-19 15:03:58 +02:00
parent 686fb800c8
commit f21d1afd70
8 changed files with 25 additions and 51 deletions

View file

@ -1121,12 +1121,6 @@ class ConcurrentMarkSweepGeneration: public CardGeneration {
// over-rides // over-rides
MemRegion used_region_at_save_marks() const; MemRegion used_region_at_save_marks() const;
// Does a "full" (forced) collection invoked on this generation collect
// the young generation as well?
virtual bool full_collects_young_generation() const {
return !ScavengeBeforeFullGC;
}
// Adjust quantities in the generation affected by // Adjust quantities in the generation affected by
// the compaction. // the compaction.
void reset_after_compaction(); void reset_after_compaction();

View file

@ -383,7 +383,7 @@ void DefNewGeneration::compute_new_size() {
size_t old_size = gch->old_gen()->capacity(); size_t old_size = gch->old_gen()->capacity();
size_t new_size_before = _virtual_space.committed_size(); size_t new_size_before = _virtual_space.committed_size();
size_t min_new_size = spec()->init_size(); size_t min_new_size = initial_size();
size_t max_new_size = reserved().byte_size(); size_t max_new_size = reserved().byte_size();
assert(min_new_size <= new_size_before && assert(min_new_size <= new_size_before &&
new_size_before <= max_new_size, new_size_before <= max_new_size,

View file

@ -66,13 +66,6 @@ class TenuredGeneration: public CardGeneration {
const char* name() const { return "tenured generation"; } const char* name() const { return "tenured generation"; }
const char* short_name() const { return "Tenured"; } const char* short_name() const { return "Tenured"; }
// Does a "full" (forced) collection invoked on this generation collect
// the young generation as well? Note that this is a hack to allow the
// collection of the young gen first if the flag is set.
virtual bool full_collects_young_generation() const {
return !ScavengeBeforeFullGC;
}
size_t unsafe_max_alloc_nogc() const; size_t unsafe_max_alloc_nogc() const;
size_t contiguous_available() const; size_t contiguous_available() const;

View file

@ -208,8 +208,7 @@ void CardGeneration::compute_new_size() {
const double min_tmp = used_after_gc / maximum_used_percentage; const double min_tmp = used_after_gc / maximum_used_percentage;
size_t minimum_desired_capacity = (size_t)MIN2(min_tmp, double(max_uintx)); size_t minimum_desired_capacity = (size_t)MIN2(min_tmp, double(max_uintx));
// Don't shrink less than the initial generation size // Don't shrink less than the initial generation size
minimum_desired_capacity = MAX2(minimum_desired_capacity, minimum_desired_capacity = MAX2(minimum_desired_capacity, initial_size());
spec()->init_size());
assert(used_after_gc <= minimum_desired_capacity, "sanity check"); assert(used_after_gc <= minimum_desired_capacity, "sanity check");
if (PrintGC && Verbose) { if (PrintGC && Verbose) {
@ -262,8 +261,7 @@ void CardGeneration::compute_new_size() {
const double minimum_used_percentage = 1.0 - maximum_free_percentage; const double minimum_used_percentage = 1.0 - maximum_free_percentage;
const double max_tmp = used_after_gc / minimum_used_percentage; const double max_tmp = used_after_gc / minimum_used_percentage;
size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx)); size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx));
maximum_desired_capacity = MAX2(maximum_desired_capacity, maximum_desired_capacity = MAX2(maximum_desired_capacity, initial_size());
spec()->init_size());
if (PrintGC && Verbose) { if (PrintGC && Verbose) {
gclog_or_tty->print_cr(" " gclog_or_tty->print_cr(" "
" maximum_free_percentage: %6.2f" " maximum_free_percentage: %6.2f"
@ -302,7 +300,7 @@ void CardGeneration::compute_new_size() {
" shrinking:" " shrinking:"
" initSize: %.1fK" " initSize: %.1fK"
" maximum_desired_capacity: %.1fK", " maximum_desired_capacity: %.1fK",
spec()->init_size() / (double) K, initial_size() / (double) K,
maximum_desired_capacity / (double) K); maximum_desired_capacity / (double) K);
gclog_or_tty->print_cr(" " gclog_or_tty->print_cr(" "
" shrink_bytes: %.1fK" " shrink_bytes: %.1fK"

View file

@ -460,10 +460,9 @@ void GenCollectedHeap::do_collection(bool full,
bool prepared_for_verification = false; bool prepared_for_verification = false;
bool collected_old = false; bool collected_old = false;
bool old_collects_young = complete && bool old_collects_young = complete && !ScavengeBeforeFullGC;
_old_gen->full_collects_young_generation();
if (!old_collects_young && if (!old_collects_young && _young_gen->should_collect(full, size, is_tlab)) {
_young_gen->should_collect(full, size, is_tlab)) {
if (run_verification && VerifyGCLevel <= 0 && VerifyBeforeGC) { if (run_verification && VerifyGCLevel <= 0 && VerifyBeforeGC) {
prepare_for_verify(); prepare_for_verify();
prepared_for_verification = true; prepared_for_verification = true;
@ -1107,10 +1106,6 @@ void GenCollectedHeap::prepare_for_compaction() {
_young_gen->prepare_for_compaction(&cp); _young_gen->prepare_for_compaction(&cp);
} }
GCStats* GenCollectedHeap::gc_stats(Generation* gen) const {
return gen->gc_stats();
}
void GenCollectedHeap::verify(bool silent, VerifyOption option /* ignored */) { void GenCollectedHeap::verify(bool silent, VerifyOption option /* ignored */) {
if (!silent) { if (!silent) {
gclog_or_tty->print("%s", _old_gen->name()); gclog_or_tty->print("%s", _old_gen->name());

View file

@ -126,8 +126,6 @@ public:
WorkGang* workers() const { return _workers; } WorkGang* workers() const { return _workers; }
GCStats* gc_stats(Generation* generation) const;
// Returns JNI_OK on success // Returns JNI_OK on success
virtual jint initialize(); virtual jint initialize();

View file

@ -58,12 +58,12 @@ Generation::Generation(ReservedSpace rs, size_t initial_size) :
(HeapWord*)_virtual_space.high_boundary()); (HeapWord*)_virtual_space.high_boundary());
} }
GenerationSpec* Generation::spec() { size_t Generation::initial_size() {
GenCollectedHeap* gch = GenCollectedHeap::heap(); GenCollectedHeap* gch = GenCollectedHeap::heap();
if (gch->is_young_gen(this)) { if (gch->is_young_gen(this)) {
return gch->gen_policy()->young_gen_spec(); return gch->gen_policy()->young_gen_spec()->init_size();
} }
return gch->gen_policy()->old_gen_spec(); return gch->gen_policy()->old_gen_spec()->init_size();
} }
size_t Generation::max_capacity() const { size_t Generation::max_capacity() const {

View file

@ -141,14 +141,14 @@ class Generation: public CHeapObj<mtGC> {
} }
virtual Generation::Name kind() { return Generation::Other; } virtual Generation::Name kind() { return Generation::Other; }
GenerationSpec* spec();
// This properly belongs in the collector, but for now this // This properly belongs in the collector, but for now this
// will do. // will do.
virtual bool refs_discovery_is_atomic() const { return true; } virtual bool refs_discovery_is_atomic() const { return true; }
virtual bool refs_discovery_is_mt() const { return false; } virtual bool refs_discovery_is_mt() const { return false; }
// Space enquiries (results in bytes) // Space inquiries (results in bytes)
size_t initial_size();
virtual size_t capacity() const = 0; // The maximum number of object bytes the virtual size_t capacity() const = 0; // The maximum number of object bytes the
// generation can currently hold. // generation can currently hold.
virtual size_t used() const = 0; // The number of used bytes in the gen. virtual size_t used() const = 0; // The number of used bytes in the gen.
@ -309,10 +309,6 @@ class Generation: public CHeapObj<mtGC> {
// do nothing. // do nothing.
virtual void par_oop_since_save_marks_iterate_done(int thread_num) {} virtual void par_oop_since_save_marks_iterate_done(int thread_num) {}
// This generation will collect all younger generations
// during a full collection.
virtual bool full_collects_young_generation() const { return false; }
// This generation does in-place marking, meaning that mark words // This generation does in-place marking, meaning that mark words
// are mutated during the marking phase and presumably reinitialized // are mutated during the marking phase and presumably reinitialized
// to a canonical value after the GC. This is currently used by the // to a canonical value after the GC. This is currently used by the
@ -403,7 +399,7 @@ class Generation: public CHeapObj<mtGC> {
// that was most recently collected. This allows the generation to // that was most recently collected. This allows the generation to
// decide what statistics are valid to collect. For example, the // decide what statistics are valid to collect. For example, the
// generation can decide to gather the amount of promoted data if // generation can decide to gather the amount of promoted data if
// the collection of the younger generations has completed. // the collection of the young generation has completed.
GCStats* gc_stats() const { return _gc_stats; } GCStats* gc_stats() const { return _gc_stats; }
virtual void update_gc_stats(Generation* current_generation, bool full) {} virtual void update_gc_stats(Generation* current_generation, bool full) {}