--- old/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp 2015-09-09 13:49:11.000000000 +0200 +++ new/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp 2015-09-09 13:49:11.000000000 +0200 @@ -2415,13 +2415,11 @@ { StrongRootsScope srs(1); - gch->gen_process_roots(&srs, - GenCollectedHeap::OldGen, + gch->old_process_roots(&srs, true, // young gen as roots GenCollectedHeap::ScanningOption(roots_scanning_options()), should_unload_classes(), ¬Older, - NULL, NULL); } @@ -2487,13 +2485,11 @@ { StrongRootsScope srs(1); - gch->gen_process_roots(&srs, - GenCollectedHeap::OldGen, + gch->old_process_roots(&srs, true, // young gen as roots GenCollectedHeap::ScanningOption(roots_scanning_options()), should_unload_classes(), ¬Older, - NULL, &cld_closure); } @@ -3011,13 +3007,11 @@ StrongRootsScope srs(1); - gch->gen_process_roots(&srs, - GenCollectedHeap::OldGen, + gch->old_process_roots(&srs, true, // young gen as roots GenCollectedHeap::ScanningOption(roots_scanning_options()), should_unload_classes(), ¬Older, - NULL, &cld_closure); } } @@ -4441,13 +4435,11 @@ CLDToOopClosure cld_closure(&par_mri_cl, true); - gch->gen_process_roots(_strong_roots_scope, - GenCollectedHeap::OldGen, + gch->old_process_roots(_strong_roots_scope, false, // yg was scanned above GenCollectedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), _collector->should_unload_classes(), &par_mri_cl, - NULL, &cld_closure); assert(_collector->should_unload_classes() || (_collector->CMSCollector::roots_scanning_options() & GenCollectedHeap::SO_AllCodeCache), @@ -4580,13 +4572,11 @@ // ---------- remaining roots -------------- _timer.reset(); _timer.start(); - gch->gen_process_roots(_strong_roots_scope, - GenCollectedHeap::OldGen, + gch->old_process_roots(_strong_roots_scope, false, // yg was scanned above GenCollectedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), _collector->should_unload_classes(), &par_mrias_cl, - NULL, NULL); // The dirty klasses will be handled below assert(_collector->should_unload_classes() @@ -5161,13 +5151,11 @@ gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel. StrongRootsScope srs(1); - gch->gen_process_roots(&srs, - GenCollectedHeap::OldGen, + gch->old_process_roots(&srs, true, // young gen as roots GenCollectedHeap::ScanningOption(roots_scanning_options()), should_unload_classes(), &mrias_cl, - NULL, NULL); // The dirty klasses will be handled below assert(should_unload_classes() --- old/src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp 2015-09-09 13:49:12.000000000 +0200 +++ new/src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp 2015-09-09 13:49:12.000000000 +0200 @@ -1119,12 +1119,6 @@ // over-rides 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 // the compaction. void reset_after_compaction(); --- old/src/share/vm/gc/cms/parNewGeneration.cpp 2015-09-09 13:49:13.000000000 +0200 +++ new/src/share/vm/gc/cms/parNewGeneration.cpp 2015-09-09 13:49:13.000000000 +0200 @@ -582,14 +582,10 @@ false); par_scan_state.start_strong_roots(); - gch->gen_process_roots(_strong_roots_scope, - GenCollectedHeap::YoungGen, - true, // Process younger gens, if any, as strong roots. - GenCollectedHeap::SO_ScavengeCodeCache, - GenCollectedHeap::StrongAndWeakRoots, - &par_scan_state.to_space_root_closure(), - &par_scan_state.older_gen_closure(), - &cld_scan_closure); + gch->young_process_roots(_strong_roots_scope, + &par_scan_state.to_space_root_closure(), + &par_scan_state.older_gen_closure(), + &cld_scan_closure); par_scan_state.end_strong_roots(); --- old/src/share/vm/gc/serial/defNewGeneration.cpp 2015-09-09 13:49:13.000000000 +0200 +++ new/src/share/vm/gc/serial/defNewGeneration.cpp 2015-09-09 13:49:13.000000000 +0200 @@ -384,7 +384,7 @@ size_t old_size = gch->old_gen()->capacity(); 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(); assert(min_new_size <= new_size_before && new_size_before <= max_new_size, @@ -627,15 +627,10 @@ // See: CardTableModRefBSForCTRS::non_clean_card_iterate_possibly_parallel. StrongRootsScope srs(0); - gch->gen_process_roots(&srs, - GenCollectedHeap::YoungGen, - true, // Process younger gens, if any, - // as strong roots. - GenCollectedHeap::SO_ScavengeCodeCache, - GenCollectedHeap::StrongAndWeakRoots, - &fsc_with_no_gc_barrier, - &fsc_with_gc_barrier, - &cld_scan_closure); + gch->young_process_roots(&srs, + &fsc_with_no_gc_barrier, + &fsc_with_gc_barrier, + &cld_scan_closure); } // "evacuate followers". --- old/src/share/vm/gc/serial/genMarkSweep.cpp 2015-09-09 13:49:13.000000000 +0200 +++ new/src/share/vm/gc/serial/genMarkSweep.cpp 2015-09-09 13:49:13.000000000 +0200 @@ -202,13 +202,11 @@ { StrongRootsScope srs(1); - gch->gen_process_roots(&srs, - GenCollectedHeap::OldGen, + gch->old_process_roots(&srs, false, // Younger gens are not roots. GenCollectedHeap::SO_None, ClassUnloading, &follow_root_closure, - &follow_root_closure, &follow_cld_closure); } @@ -289,12 +287,10 @@ { StrongRootsScope srs(1); - gch->gen_process_roots(&srs, - GenCollectedHeap::OldGen, + gch->old_process_roots(&srs, false, // Younger gens are not roots. GenCollectedHeap::SO_AllCodeCache, - GenCollectedHeap::StrongAndWeakRoots, - &adjust_pointer_closure, + false, // Strong and weak roots. &adjust_pointer_closure, &adjust_cld_closure); } --- old/src/share/vm/gc/serial/tenuredGeneration.hpp 2015-09-09 13:49:14.000000000 +0200 +++ new/src/share/vm/gc/serial/tenuredGeneration.hpp 2015-09-09 13:49:14.000000000 +0200 @@ -66,13 +66,6 @@ const char* name() const { return "tenured generation"; } 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 contiguous_available() const; --- old/src/share/vm/gc/shared/cardGeneration.cpp 2015-09-09 13:49:14.000000000 +0200 +++ new/src/share/vm/gc/shared/cardGeneration.cpp 2015-09-09 13:49:14.000000000 +0200 @@ -208,8 +208,7 @@ const double min_tmp = used_after_gc / maximum_used_percentage; size_t minimum_desired_capacity = (size_t)MIN2(min_tmp, double(max_uintx)); // Don't shrink less than the initial generation size - minimum_desired_capacity = MAX2(minimum_desired_capacity, - spec()->init_size()); + minimum_desired_capacity = MAX2(minimum_desired_capacity, initial_size()); assert(used_after_gc <= minimum_desired_capacity, "sanity check"); if (PrintGC && Verbose) { @@ -262,8 +261,7 @@ const double minimum_used_percentage = 1.0 - maximum_free_percentage; const double max_tmp = used_after_gc / minimum_used_percentage; size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx)); - maximum_desired_capacity = MAX2(maximum_desired_capacity, - spec()->init_size()); + maximum_desired_capacity = MAX2(maximum_desired_capacity, initial_size()); if (PrintGC && Verbose) { gclog_or_tty->print_cr(" " " maximum_free_percentage: %6.2f" @@ -299,20 +297,20 @@ } if (PrintGC && Verbose) { gclog_or_tty->print_cr(" " - " shrinking:" - " initSize: %.1fK" - " maximum_desired_capacity: %.1fK", - spec()->init_size() / (double) K, - maximum_desired_capacity / (double) K); + " shrinking:" + " initSize: %.1fK" + " maximum_desired_capacity: %.1fK", + initial_size() / (double) K, + maximum_desired_capacity / (double) K); gclog_or_tty->print_cr(" " - " shrink_bytes: %.1fK" - " current_shrink_factor: " SIZE_FORMAT - " new shrink factor: " SIZE_FORMAT - " _min_heap_delta_bytes: %.1fK", - shrink_bytes / (double) K, - current_shrink_factor, - _shrink_factor, - _min_heap_delta_bytes / (double) K); + " shrink_bytes: %.1fK" + " current_shrink_factor: " SIZE_FORMAT + " new shrink factor: " SIZE_FORMAT + " _min_heap_delta_bytes: %.1fK", + shrink_bytes / (double) K, + current_shrink_factor, + _shrink_factor, + _min_heap_delta_bytes / (double) K); } } } --- old/src/share/vm/gc/shared/genCollectedHeap.cpp 2015-09-09 13:49:15.000000000 +0200 +++ new/src/share/vm/gc/shared/genCollectedHeap.cpp 2015-09-09 13:49:14.000000000 +0200 @@ -463,10 +463,9 @@ bool prepared_for_verification = false; bool collected_old = false; - bool old_collects_young = complete && - _old_gen->full_collects_young_generation(); - if (!old_collects_young && - _young_gen->should_collect(full, size, is_tlab)) { + bool old_collects_young = complete && !ScavengeBeforeFullGC; + + if (!old_collects_young && _young_gen->should_collect(full, size, is_tlab)) { if (run_verification && VerifyGCLevel <= 0 && VerifyBeforeGC) { prepare_for_verify(); prepared_for_verification = true; @@ -666,52 +665,57 @@ } } -void GenCollectedHeap::gen_process_roots(StrongRootsScope* scope, - GenerationType type, +void GenCollectedHeap::young_process_roots(StrongRootsScope* scope, + OopsInGenClosure* young_gen_closure, + OopsInGenClosure* old_gen_closure, + CLDClosure* cld_closure) { + MarkingCodeBlobClosure mark_code_closure(young_gen_closure, true /* young collections are always moving */); + + process_roots(scope, SO_ScavengeCodeCache, young_gen_closure, young_gen_closure, + cld_closure, cld_closure, &mark_code_closure); + + if (!_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) { + young_gen_closure->reset_generation(); + } + + // When collection is parallel, all threads get to cooperate to do + // old generation scanning. + old_gen_closure->set_generation(_old_gen); + rem_set()->younger_refs_iterate(_old_gen, old_gen_closure, scope->n_threads()); + old_gen_closure->reset_generation(); + + _process_strong_tasks->all_tasks_completed(scope->n_threads()); +} + +void GenCollectedHeap::old_process_roots(StrongRootsScope* scope, bool young_gen_as_roots, ScanningOption so, bool only_strong_roots, - OopsInGenClosure* not_older_gens, - OopsInGenClosure* older_gens, + OopsInGenClosure* young_gen_closure, CLDClosure* cld_closure) { const bool is_adjust_phase = !only_strong_roots && !young_gen_as_roots; bool is_moving_collection = false; - if (type == YoungGen || is_adjust_phase) { - // young collections are always moving + if (is_adjust_phase) { is_moving_collection = true; } - MarkingCodeBlobClosure mark_code_closure(not_older_gens, is_moving_collection); - OopsInGenClosure* weak_roots = only_strong_roots ? NULL : not_older_gens; + MarkingCodeBlobClosure mark_code_closure(young_gen_closure, is_moving_collection); + OopsInGenClosure* weak_roots = only_strong_roots ? NULL : young_gen_closure; CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure; - process_roots(scope, so, - not_older_gens, weak_roots, - cld_closure, weak_cld_closure, - &mark_code_closure); - - if (young_gen_as_roots) { - if (!_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) { - if (type == OldGen) { - not_older_gens->set_generation(_young_gen); - _young_gen->oop_iterate(not_older_gens); - } - not_older_gens->reset_generation(); - } - } - // When collection is parallel, all threads get to cooperate to do - // old generation scanning. - if (type == YoungGen) { - older_gens->set_generation(_old_gen); - rem_set()->younger_refs_iterate(_old_gen, older_gens, scope->n_threads()); - older_gens->reset_generation(); + process_roots(scope, so, young_gen_closure, weak_roots, cld_closure, weak_cld_closure, &mark_code_closure); + + if (young_gen_as_roots && + !_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) { + young_gen_closure->set_generation(_young_gen); + _young_gen->oop_iterate(young_gen_closure); + young_gen_closure->reset_generation(); } _process_strong_tasks->all_tasks_completed(scope->n_threads()); } - class AlwaysTrueClosure: public BoolObjectClosure { public: bool do_object_b(oop p) { return true; } @@ -1108,10 +1112,6 @@ _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 */) { if (!silent) { gclog_or_tty->print("%s", _old_gen->name()); --- old/src/share/vm/gc/shared/genCollectedHeap.hpp 2015-09-09 13:49:15.000000000 +0200 +++ new/src/share/vm/gc/shared/genCollectedHeap.hpp 2015-09-09 13:49:15.000000000 +0200 @@ -126,8 +126,6 @@ WorkGang* workers() const { return _workers; } - GCStats* gc_stats(Generation* generation) const; - // Returns JNI_OK on success virtual jint initialize(); @@ -382,9 +380,9 @@ // the closure is applied to: // "SO_None" does none; enum ScanningOption { - SO_None = 0x0, - SO_AllCodeCache = 0x8, - SO_ScavengeCodeCache = 0x10 + SO_None = 0x00, + SO_AllCodeCache = 0x08, + SO_ScavengeCodeCache = 0x10 }; private: @@ -397,16 +395,16 @@ CodeBlobClosure* code_roots); public: - static const bool StrongAndWeakRoots = false; - static const bool StrongRootsOnly = true; + void young_process_roots(StrongRootsScope* scope, + OopsInGenClosure* not_older_gens, + OopsInGenClosure* older_gens, + CLDClosure* cld_closure); - void gen_process_roots(StrongRootsScope* scope, - GenerationType type, + void old_process_roots(StrongRootsScope* scope, bool young_gen_as_roots, ScanningOption so, bool only_strong_roots, OopsInGenClosure* not_older_gens, - OopsInGenClosure* older_gens, CLDClosure* cld_closure); // Apply "root_closure" to all the weak roots of the system. --- old/src/share/vm/gc/shared/generation.cpp 2015-09-09 13:49:15.000000000 +0200 +++ new/src/share/vm/gc/shared/generation.cpp 2015-09-09 13:49:15.000000000 +0200 @@ -58,12 +58,12 @@ (HeapWord*)_virtual_space.high_boundary()); } -GenerationSpec* Generation::spec() { +size_t Generation::initial_size() { GenCollectedHeap* gch = GenCollectedHeap::heap(); 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 { --- old/src/share/vm/gc/shared/generation.hpp 2015-09-09 13:49:15.000000000 +0200 +++ new/src/share/vm/gc/shared/generation.hpp 2015-09-09 13:49:15.000000000 +0200 @@ -143,7 +143,7 @@ } virtual Generation::Name kind() { return Generation::Other; } - GenerationSpec* spec(); + size_t initial_size(); // This properly belongs in the collector, but for now this // will do. @@ -311,10 +311,6 @@ // do nothing. 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 // are mutated during the marking phase and presumably reinitialized // to a canonical value after the GC. This is currently used by the @@ -405,7 +401,7 @@ // that was most recently collected. This allows the generation to // decide what statistics are valid to collect. For example, the // 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; } virtual void update_gc_stats(Generation* current_generation, bool full) {}