--- old/src/share/vm/memory/genMarkSweep.cpp 2014-10-17 16:28:44.000000000 +0200 +++ new/src/share/vm/memory/genMarkSweep.cpp 2014-10-17 16:28:44.000000000 +0200 @@ -37,6 +37,7 @@ #include "memory/genCollectedHeap.hpp" #include "memory/genMarkSweep.hpp" #include "memory/genOopClosures.inline.hpp" +#include "memory/generation.hpp" #include "memory/generation.inline.hpp" #include "memory/modRefBarrierSet.hpp" #include "memory/referencePolicy.hpp" @@ -52,8 +53,7 @@ #include "utilities/copy.hpp" #include "utilities/events.hpp" -void GenMarkSweep::invoke_at_safepoint(int level, ReferenceProcessor* rp, bool clear_all_softrefs) { - guarantee(level == 1, "We always collect both old and young."); +void GenMarkSweep::invoke_at_safepoint(ReferenceProcessor* rp, bool clear_all_softrefs) { assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); GenCollectedHeap* gch = GenCollectedHeap::heap(); @@ -86,11 +86,11 @@ // Capture used regions for each generation that will be // subject to collection, so that card table adjustments can // be made intelligently (see clear / invalidate further below). - gch->save_used_regions(level); + gch->save_used_regions(); allocate_stacks(); - mark_sweep_phase1(level, clear_all_softrefs); + mark_sweep_phase1(clear_all_softrefs); mark_sweep_phase2(); @@ -98,7 +98,7 @@ COMPILER2_PRESENT(assert(DerivedPointerTable::is_active(), "Sanity")); COMPILER2_PRESENT(DerivedPointerTable::set_active(false)); - mark_sweep_phase3(level); + mark_sweep_phase3(); mark_sweep_phase4(); @@ -110,19 +110,14 @@ deallocate_stacks(); - // If compaction completely evacuated all generations younger than this - // one, then we can clear the card table. Otherwise, we must invalidate - // it (consider all cards dirty). In the future, we might consider doing - // compaction within generations only, and doing card-table sliding. - bool all_empty = true; - for (int i = 0; all_empty && i < level; i++) { - Generation* g = gch->get_gen(i); - all_empty = all_empty && gch->get_gen(i)->used() == 0; - } + // If compaction completely evacuated the young generation we can clear + // the card table. Otherwise, we must invalidate it (consider all cards dirty). + // In the future, we might consider doing compaction within generations only, + // and doing card-table sliding. GenRemSet* rs = gch->rem_set(); - Generation* old_gen = gch->get_gen(level); + Generation* old_gen = gch->old_gen(); // Clear/invalidate below make use of the "prev_used_regions" saved earlier. - if (all_empty) { + if (gch->young_gen()->used() == 0) { // We've evacuated all generations below us. rs->clear_into_younger(old_gen); } else { @@ -160,7 +155,7 @@ GenCollectedHeap* gch = GenCollectedHeap::heap(); // Scratch request on behalf of oldest generation; will do no // allocation. - ScratchBlock* scratch = gch->gather_scratch(gch->_gens[gch->_n_gens-1], 0); + ScratchBlock* scratch = gch->gather_scratch(gch->old_gen(), 0); // $$$ To cut a corner, we'll only use the first scratch block, and then // revert to malloc. @@ -188,8 +183,7 @@ _objarray_stack.clear(true); } -void GenMarkSweep::mark_sweep_phase1(int level, - bool clear_all_softrefs) { +void GenMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) { // Recursively traverse all live objects and mark them GCTraceTime tm("phase 1", PrintGC && Verbose, true, _gc_timer, _gc_tracer->gc_id()); trace(" 1"); @@ -200,12 +194,12 @@ // use OopsInGenClosure constructor which takes a generation, // as the Universe has not been created when the static constructors // are run. - follow_root_closure.set_orig_generation(gch->get_gen(level)); + follow_root_closure.set_orig_generation(gch->old_gen()); // Need new claim bits before marking starts. ClassLoaderDataGraph::clear_claimed_marks(); - gch->gen_process_roots(level, + gch->gen_process_roots(Generation::Old, false, // Younger gens are not roots. true, // activate StrongRootsScope SharedHeap::SO_None, @@ -274,7 +268,7 @@ } }; -void GenMarkSweep::mark_sweep_phase3(int level) { +void GenMarkSweep::mark_sweep_phase3() { GenCollectedHeap* gch = GenCollectedHeap::heap(); // Adjust the pointers to reflect the new locations @@ -288,9 +282,9 @@ // use OopsInGenClosure constructor which takes a generation, // as the Universe has not been created when the static constructors // are run. - adjust_pointer_closure.set_orig_generation(gch->get_gen(level)); + adjust_pointer_closure.set_orig_generation(gch->old_gen()); - gch->gen_process_roots(level, + gch->gen_process_roots(Generation::Old, false, // Younger gens are not roots. true, // activate StrongRootsScope SharedHeap::SO_AllCodeCache,