2008-06-05 15:57:56 -07:00
|
|
|
/*
|
2013-06-10 11:30:51 +02:00
|
|
|
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
2008-06-05 15:57:56 -07:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2008-06-05 15:57:56 -07:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
|
|
|
#include "classfile/javaClasses.hpp"
|
|
|
|
#include "classfile/symbolTable.hpp"
|
|
|
|
#include "classfile/systemDictionary.hpp"
|
|
|
|
#include "classfile/vmSymbols.hpp"
|
|
|
|
#include "code/codeCache.hpp"
|
|
|
|
#include "code/icBuffer.hpp"
|
2012-04-13 01:59:38 +02:00
|
|
|
#include "gc_implementation/g1/g1Log.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "gc_implementation/g1/g1MarkSweep.hpp"
|
2013-06-10 11:30:51 +02:00
|
|
|
#include "gc_implementation/shared/gcHeapSummary.hpp"
|
|
|
|
#include "gc_implementation/shared/gcTimer.hpp"
|
|
|
|
#include "gc_implementation/shared/gcTrace.hpp"
|
|
|
|
#include "gc_implementation/shared/gcTraceTime.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "memory/gcLocker.hpp"
|
|
|
|
#include "memory/genCollectedHeap.hpp"
|
|
|
|
#include "memory/modRefBarrierSet.hpp"
|
|
|
|
#include "memory/referencePolicy.hpp"
|
|
|
|
#include "memory/space.hpp"
|
|
|
|
#include "oops/instanceRefKlass.hpp"
|
|
|
|
#include "oops/oop.inline.hpp"
|
|
|
|
#include "prims/jvmtiExport.hpp"
|
|
|
|
#include "runtime/biasedLocking.hpp"
|
|
|
|
#include "runtime/fprofiler.hpp"
|
|
|
|
#include "runtime/synchronizer.hpp"
|
|
|
|
#include "runtime/thread.hpp"
|
|
|
|
#include "runtime/vmThread.hpp"
|
|
|
|
#include "utilities/copy.hpp"
|
|
|
|
#include "utilities/events.hpp"
|
2008-06-05 15:57:56 -07:00
|
|
|
|
|
|
|
class HeapRegion;
|
|
|
|
|
|
|
|
void G1MarkSweep::invoke_at_safepoint(ReferenceProcessor* rp,
|
|
|
|
bool clear_all_softrefs) {
|
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
|
|
|
|
|
2010-04-13 13:52:10 -07:00
|
|
|
SharedHeap* sh = SharedHeap::heap();
|
|
|
|
#ifdef ASSERT
|
|
|
|
if (sh->collector_policy()->should_clear_all_soft_refs()) {
|
|
|
|
assert(clear_all_softrefs, "Policy should have been checked earler");
|
|
|
|
}
|
|
|
|
#endif
|
2008-06-05 15:57:56 -07:00
|
|
|
// hook up weak ref data so it can be used during Mark-Sweep
|
|
|
|
assert(GenMarkSweep::ref_processor() == NULL, "no stomping");
|
|
|
|
assert(rp != NULL, "should be non-NULL");
|
2011-09-22 10:57:37 -07:00
|
|
|
assert(rp == G1CollectedHeap::heap()->ref_processor_stw(), "Precondition");
|
|
|
|
|
2008-11-20 16:56:09 -08:00
|
|
|
GenMarkSweep::_ref_processor = rp;
|
2008-12-01 23:25:24 -08:00
|
|
|
rp->setup_policy(clear_all_softrefs);
|
2008-06-05 15:57:56 -07:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// When collecting the permanent generation Method*s may be moving,
|
2008-06-05 15:57:56 -07:00
|
|
|
// so we either have to flush all bcp data or convert it into bci.
|
|
|
|
CodeCache::gc_prologue();
|
|
|
|
Threads::gc_prologue();
|
|
|
|
|
|
|
|
bool marked_for_unloading = false;
|
|
|
|
|
|
|
|
allocate_stacks();
|
|
|
|
|
2008-08-22 11:48:25 -07:00
|
|
|
// We should save the marks of the currently locked biased monitors.
|
|
|
|
// The marking doesn't preserve the marks of biased objects.
|
|
|
|
BiasedLocking::preserve_marks();
|
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
mark_sweep_phase1(marked_for_unloading, clear_all_softrefs);
|
|
|
|
|
|
|
|
mark_sweep_phase2();
|
|
|
|
|
|
|
|
// Don't add any more derived pointers during phase3
|
|
|
|
COMPILER2_PRESENT(DerivedPointerTable::set_active(false));
|
|
|
|
|
|
|
|
mark_sweep_phase3();
|
|
|
|
|
|
|
|
mark_sweep_phase4();
|
|
|
|
|
|
|
|
GenMarkSweep::restore_marks();
|
2008-08-22 11:48:25 -07:00
|
|
|
BiasedLocking::restore_marks();
|
2008-06-05 15:57:56 -07:00
|
|
|
GenMarkSweep::deallocate_stacks();
|
|
|
|
|
|
|
|
// "free at last gc" is calculated from these.
|
|
|
|
// CHF: cheating for now!!!
|
|
|
|
// Universe::set_heap_capacity_at_last_gc(Universe::heap()->capacity());
|
|
|
|
// Universe::set_heap_used_at_last_gc(Universe::heap()->used());
|
|
|
|
|
|
|
|
Threads::gc_epilogue();
|
|
|
|
CodeCache::gc_epilogue();
|
2011-01-19 13:51:53 -08:00
|
|
|
JvmtiExport::gc_epilogue();
|
2008-06-05 15:57:56 -07:00
|
|
|
|
|
|
|
// refs processing: clean slate
|
|
|
|
GenMarkSweep::_ref_processor = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void G1MarkSweep::allocate_stacks() {
|
|
|
|
GenMarkSweep::_preserved_count_max = 0;
|
|
|
|
GenMarkSweep::_preserved_marks = NULL;
|
|
|
|
GenMarkSweep::_preserved_count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading,
|
|
|
|
bool clear_all_softrefs) {
|
|
|
|
// Recursively traverse all live objects and mark them
|
2013-06-10 11:30:51 +02:00
|
|
|
GCTraceTime tm("phase 1", G1Log::fine() && Verbose, true, gc_timer());
|
2008-06-05 15:57:56 -07:00
|
|
|
GenMarkSweep::trace(" 1");
|
|
|
|
|
|
|
|
SharedHeap* sh = SharedHeap::heap();
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Need cleared claim bits for the strong roots processing
|
|
|
|
ClassLoaderDataGraph::clear_claimed_marks();
|
|
|
|
|
|
|
|
sh->process_strong_roots(true, // activate StrongRootsScope
|
2008-06-05 15:57:56 -07:00
|
|
|
SharedHeap::SO_SystemClasses,
|
|
|
|
&GenMarkSweep::follow_root_closure,
|
2009-09-15 21:53:47 -07:00
|
|
|
&GenMarkSweep::follow_code_root_closure,
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
&GenMarkSweep::follow_klass_closure);
|
2008-06-05 15:57:56 -07:00
|
|
|
|
|
|
|
// Process reference objects found during marking
|
2008-11-20 16:56:09 -08:00
|
|
|
ReferenceProcessor* rp = GenMarkSweep::ref_processor();
|
2011-09-22 10:57:37 -07:00
|
|
|
assert(rp == G1CollectedHeap::heap()->ref_processor_stw(), "Sanity");
|
|
|
|
|
2008-12-01 23:25:24 -08:00
|
|
|
rp->setup_policy(clear_all_softrefs);
|
2013-06-10 11:30:51 +02:00
|
|
|
const ReferenceProcessorStats& stats =
|
|
|
|
rp->process_discovered_references(&GenMarkSweep::is_alive,
|
|
|
|
&GenMarkSweep::keep_alive,
|
|
|
|
&GenMarkSweep::follow_stack_closure,
|
|
|
|
NULL,
|
|
|
|
gc_timer());
|
|
|
|
gc_tracer()->report_gc_reference_stats(stats);
|
2008-06-05 15:57:56 -07:00
|
|
|
|
2013-04-26 10:40:36 +02:00
|
|
|
|
|
|
|
// This is the point where the entire marking should have completed.
|
|
|
|
assert(GenMarkSweep::_marking_stack.is_empty(), "Marking should have completed");
|
|
|
|
|
|
|
|
// Unload classes and purge the SystemDictionary.
|
2008-06-05 15:57:56 -07:00
|
|
|
bool purged_class = SystemDictionary::do_unloading(&GenMarkSweep::is_alive);
|
|
|
|
|
2013-04-26 10:40:36 +02:00
|
|
|
// Unload nmethods.
|
2012-09-25 14:58:12 +02:00
|
|
|
CodeCache::do_unloading(&GenMarkSweep::is_alive, purged_class);
|
2008-06-05 15:57:56 -07:00
|
|
|
|
2013-04-26 10:40:36 +02:00
|
|
|
// Prune dead klasses from subklass/sibling/implementor lists.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass::clean_weak_klass_links(&GenMarkSweep::is_alive);
|
2008-06-05 15:57:56 -07:00
|
|
|
|
2014-01-20 11:47:07 +01:00
|
|
|
// Delete entries for dead interned string and clean up unreferenced symbols in symbol table.
|
|
|
|
G1CollectedHeap::heap()->unlink_string_and_symbol_table(&GenMarkSweep::is_alive);
|
2008-06-05 15:57:56 -07:00
|
|
|
|
2011-06-14 11:01:10 -07:00
|
|
|
if (VerifyDuringGC) {
|
|
|
|
HandleMark hm; // handle scope
|
|
|
|
COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact);
|
|
|
|
Universe::heap()->prepare_for_verify();
|
|
|
|
// Note: we can verify only the heap here. When an object is
|
|
|
|
// marked, the previous value of the mark word (including
|
|
|
|
// identity hash values, ages, etc) is preserved, and the mark
|
|
|
|
// word is set to markOop::marked_value - effectively removing
|
|
|
|
// any hash values from the mark word. These hash values are
|
|
|
|
// used when verifying the dictionaries and so removing them
|
|
|
|
// from the mark word can make verification of the dictionaries
|
|
|
|
// fail. At the end of the GC, the orginal mark word values
|
|
|
|
// (including hash values) are restored to the appropriate
|
|
|
|
// objects.
|
2013-04-24 20:13:37 +02:00
|
|
|
if (!VerifySilently) {
|
|
|
|
gclog_or_tty->print(" VerifyDuringGC:(full)[Verifying ");
|
|
|
|
}
|
|
|
|
Universe::heap()->verify(VerifySilently, VerifyOption_G1UseMarkWord);
|
|
|
|
if (!VerifySilently) {
|
|
|
|
gclog_or_tty->print_cr("]");
|
|
|
|
}
|
2011-06-14 11:01:10 -07:00
|
|
|
}
|
2013-06-10 11:30:51 +02:00
|
|
|
|
|
|
|
gc_tracer()->report_object_count_after_gc(&GenMarkSweep::is_alive);
|
2008-06-05 15:57:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
class G1PrepareCompactClosure: public HeapRegionClosure {
|
2011-01-19 19:30:42 -05:00
|
|
|
G1CollectedHeap* _g1h;
|
2008-06-05 15:57:56 -07:00
|
|
|
ModRefBarrierSet* _mrbs;
|
|
|
|
CompactPoint _cp;
|
2011-01-19 19:30:42 -05:00
|
|
|
HumongousRegionSet _humongous_proxy_set;
|
2008-06-05 15:57:56 -07:00
|
|
|
|
|
|
|
void free_humongous_region(HeapRegion* hr) {
|
|
|
|
HeapWord* end = hr->end();
|
2011-03-04 17:13:19 -05:00
|
|
|
size_t dummy_pre_used;
|
|
|
|
FreeRegionList dummy_free_list("Dummy Free List for G1MarkSweep");
|
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
assert(hr->startsHumongous(),
|
|
|
|
"Only the start of a humongous region should be freed.");
|
2011-03-04 17:13:19 -05:00
|
|
|
_g1h->free_humongous_region(hr, &dummy_pre_used, &dummy_free_list,
|
2011-01-19 19:30:42 -05:00
|
|
|
&_humongous_proxy_set, false /* par */);
|
2008-06-05 15:57:56 -07:00
|
|
|
hr->prepare_for_compaction(&_cp);
|
|
|
|
// Also clear the part of the card table that will be unused after
|
|
|
|
// compaction.
|
2011-01-19 19:30:42 -05:00
|
|
|
_mrbs->clear(MemRegion(hr->compaction_top(), end));
|
2011-03-04 17:13:19 -05:00
|
|
|
dummy_free_list.remove_all();
|
2008-06-05 15:57:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2011-01-19 19:30:42 -05:00
|
|
|
G1PrepareCompactClosure(CompactibleSpace* cs)
|
|
|
|
: _g1h(G1CollectedHeap::heap()),
|
2013-09-24 14:46:29 +02:00
|
|
|
_mrbs(_g1h->g1_barrier_set()),
|
2008-06-05 15:57:56 -07:00
|
|
|
_cp(NULL, cs, cs->initialize_threshold()),
|
2011-01-19 19:30:42 -05:00
|
|
|
_humongous_proxy_set("G1MarkSweep Humongous Proxy Set") { }
|
|
|
|
|
|
|
|
void update_sets() {
|
|
|
|
// We'll recalculate total used bytes and recreate the free list
|
|
|
|
// at the end of the GC, so no point in updating those values here.
|
|
|
|
_g1h->update_sets_after_freeing_regions(0, /* pre_used */
|
|
|
|
NULL, /* free_list */
|
2011-11-07 22:11:12 -05:00
|
|
|
NULL, /* old_proxy_set */
|
2011-01-19 19:30:42 -05:00
|
|
|
&_humongous_proxy_set,
|
|
|
|
false /* par */);
|
|
|
|
}
|
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
bool doHeapRegion(HeapRegion* hr) {
|
|
|
|
if (hr->isHumongous()) {
|
|
|
|
if (hr->startsHumongous()) {
|
|
|
|
oop obj = oop(hr->bottom());
|
|
|
|
if (obj->is_gc_marked()) {
|
|
|
|
obj->forward_to(obj);
|
|
|
|
} else {
|
|
|
|
free_humongous_region(hr);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
assert(hr->continuesHumongous(), "Invalid humongous.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
hr->prepare_for_compaction(&_cp);
|
|
|
|
// Also clear the part of the card table that will be unused after
|
|
|
|
// compaction.
|
|
|
|
_mrbs->clear(MemRegion(hr->compaction_top(), hr->end()));
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
2009-03-25 13:10:54 -07:00
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
void G1MarkSweep::mark_sweep_phase2() {
|
|
|
|
// Now all live objects are marked, compute the new object addresses.
|
|
|
|
|
|
|
|
// It is not required that we traverse spaces in the same order in
|
|
|
|
// phase2, phase3 and phase4, but the ValidateMarkSweep live oops
|
|
|
|
// tracking expects us to do so. See comment under phase4.
|
|
|
|
|
|
|
|
G1CollectedHeap* g1h = G1CollectedHeap::heap();
|
|
|
|
|
2013-06-10 11:30:51 +02:00
|
|
|
GCTraceTime tm("phase 2", G1Log::fine() && Verbose, true, gc_timer());
|
2008-06-05 15:57:56 -07:00
|
|
|
GenMarkSweep::trace("2");
|
|
|
|
|
2012-07-19 15:15:54 -07:00
|
|
|
// find the first region
|
|
|
|
HeapRegion* r = g1h->region_at(0);
|
2008-06-05 15:57:56 -07:00
|
|
|
CompactibleSpace* sp = r;
|
|
|
|
if (r->isHumongous() && oop(r->bottom())->is_gc_marked()) {
|
|
|
|
sp = r->next_compaction_space();
|
|
|
|
}
|
|
|
|
|
2009-03-25 13:10:54 -07:00
|
|
|
G1PrepareCompactClosure blk(sp);
|
2008-06-05 15:57:56 -07:00
|
|
|
g1h->heap_region_iterate(&blk);
|
2011-01-19 19:30:42 -05:00
|
|
|
blk.update_sets();
|
2008-06-05 15:57:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
class G1AdjustPointersClosure: public HeapRegionClosure {
|
|
|
|
public:
|
|
|
|
bool doHeapRegion(HeapRegion* r) {
|
|
|
|
if (r->isHumongous()) {
|
|
|
|
if (r->startsHumongous()) {
|
|
|
|
// We must adjust the pointers on the single H object.
|
|
|
|
oop obj = oop(r->bottom());
|
|
|
|
// point all the oops to the new location
|
|
|
|
obj->adjust_pointers();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// This really ought to be "as_CompactibleSpace"...
|
|
|
|
r->adjust_pointers();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void G1MarkSweep::mark_sweep_phase3() {
|
|
|
|
G1CollectedHeap* g1h = G1CollectedHeap::heap();
|
|
|
|
|
|
|
|
// Adjust the pointers to reflect the new locations
|
2013-06-10 11:30:51 +02:00
|
|
|
GCTraceTime tm("phase 3", G1Log::fine() && Verbose, true, gc_timer());
|
2008-06-05 15:57:56 -07:00
|
|
|
GenMarkSweep::trace("3");
|
|
|
|
|
|
|
|
SharedHeap* sh = SharedHeap::heap();
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Need cleared claim bits for the strong roots processing
|
|
|
|
ClassLoaderDataGraph::clear_claimed_marks();
|
|
|
|
|
2009-09-15 21:53:47 -07:00
|
|
|
sh->process_strong_roots(true, // activate StrongRootsScope
|
2008-06-05 15:57:56 -07:00
|
|
|
SharedHeap::SO_AllClasses,
|
2013-04-22 20:27:36 +02:00
|
|
|
&GenMarkSweep::adjust_pointer_closure,
|
2009-09-15 21:53:47 -07:00
|
|
|
NULL, // do not touch code cache here
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
&GenMarkSweep::adjust_klass_closure);
|
2008-06-05 15:57:56 -07:00
|
|
|
|
2011-09-22 10:57:37 -07:00
|
|
|
assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity");
|
2013-04-22 20:27:36 +02:00
|
|
|
g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
|
2008-06-05 15:57:56 -07:00
|
|
|
|
|
|
|
// Now adjust pointers in remaining weak roots. (All of which should
|
|
|
|
// have been cleared if they pointed to non-surviving objects.)
|
2013-04-22 20:27:36 +02:00
|
|
|
g1h->g1_process_weak_roots(&GenMarkSweep::adjust_pointer_closure);
|
2008-06-05 15:57:56 -07:00
|
|
|
|
|
|
|
GenMarkSweep::adjust_marks();
|
|
|
|
|
|
|
|
G1AdjustPointersClosure blk;
|
|
|
|
g1h->heap_region_iterate(&blk);
|
|
|
|
}
|
|
|
|
|
|
|
|
class G1SpaceCompactClosure: public HeapRegionClosure {
|
|
|
|
public:
|
|
|
|
G1SpaceCompactClosure() {}
|
|
|
|
|
|
|
|
bool doHeapRegion(HeapRegion* hr) {
|
|
|
|
if (hr->isHumongous()) {
|
|
|
|
if (hr->startsHumongous()) {
|
|
|
|
oop obj = oop(hr->bottom());
|
|
|
|
if (obj->is_gc_marked()) {
|
|
|
|
obj->init_mark();
|
|
|
|
} else {
|
|
|
|
assert(hr->is_empty(), "Should have been cleared in phase 2.");
|
|
|
|
}
|
|
|
|
hr->reset_during_compaction();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
hr->compact();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void G1MarkSweep::mark_sweep_phase4() {
|
|
|
|
// All pointers are now adjusted, move objects accordingly
|
|
|
|
|
|
|
|
// The ValidateMarkSweep live oops tracking expects us to traverse spaces
|
|
|
|
// in the same order in phase2, phase3 and phase4. We don't quite do that
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// here (code and comment not fixed for perm removal), so we tell the validate code
|
2008-06-05 15:57:56 -07:00
|
|
|
// to use a higher index (saved from phase2) when verifying perm_gen.
|
|
|
|
G1CollectedHeap* g1h = G1CollectedHeap::heap();
|
|
|
|
|
2013-06-10 11:30:51 +02:00
|
|
|
GCTraceTime tm("phase 4", G1Log::fine() && Verbose, true, gc_timer());
|
2008-06-05 15:57:56 -07:00
|
|
|
GenMarkSweep::trace("4");
|
|
|
|
|
|
|
|
G1SpaceCompactClosure blk;
|
|
|
|
g1h->heap_region_iterate(&blk);
|
|
|
|
|
|
|
|
}
|