2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2019-01-29 11:30:17 +01:00
|
|
|
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00: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.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
2018-09-28 16:07:39 -04:00
|
|
|
#include "classfile/classLoaderDataGraph.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "classfile/javaClasses.hpp"
|
2014-05-07 14:16:45 -05:00
|
|
|
#include "classfile/stringTable.hpp"
|
2015-12-08 20:04:03 +01:00
|
|
|
#include "classfile/symbolTable.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "classfile/systemDictionary.hpp"
|
|
|
|
#include "classfile/vmSymbols.hpp"
|
|
|
|
#include "code/codeCache.hpp"
|
|
|
|
#include "code/icBuffer.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/serial/genMarkSweep.hpp"
|
|
|
|
#include "gc/shared/collectedHeap.inline.hpp"
|
|
|
|
#include "gc/shared/gcHeapSummary.hpp"
|
|
|
|
#include "gc/shared/gcTimer.hpp"
|
|
|
|
#include "gc/shared/gcTrace.hpp"
|
2015-12-10 14:57:55 +01:00
|
|
|
#include "gc/shared/gcTraceTime.inline.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/shared/genCollectedHeap.hpp"
|
2015-06-17 14:44:54 +02:00
|
|
|
#include "gc/shared/generation.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/shared/genOopClosures.inline.hpp"
|
|
|
|
#include "gc/shared/modRefBarrierSet.hpp"
|
|
|
|
#include "gc/shared/referencePolicy.hpp"
|
2018-05-29 09:26:00 +02:00
|
|
|
#include "gc/shared/referenceProcessorPhaseTimes.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/shared/space.hpp"
|
2015-05-21 09:23:00 +02:00
|
|
|
#include "gc/shared/strongRootsScope.hpp"
|
2017-10-18 21:13:35 +02:00
|
|
|
#include "gc/shared/weakProcessor.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/instanceRefKlass.hpp"
|
|
|
|
#include "oops/oop.inline.hpp"
|
|
|
|
#include "prims/jvmtiExport.hpp"
|
|
|
|
#include "runtime/handles.inline.hpp"
|
|
|
|
#include "runtime/synchronizer.hpp"
|
2012-11-27 14:20:21 +01:00
|
|
|
#include "runtime/thread.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/vmThread.hpp"
|
|
|
|
#include "utilities/copy.hpp"
|
|
|
|
#include "utilities/events.hpp"
|
2015-03-25 10:08:09 +01:00
|
|
|
#include "utilities/stack.inline.hpp"
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-06-17 14:44:54 +02:00
|
|
|
void GenMarkSweep::invoke_at_safepoint(ReferenceProcessor* rp, bool clear_all_softrefs) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
|
|
|
|
|
2010-04-13 13:52:10 -07:00
|
|
|
GenCollectedHeap* gch = GenCollectedHeap::heap();
|
|
|
|
#ifdef ASSERT
|
2018-02-22 18:36:07 +01:00
|
|
|
if (gch->soft_ref_policy()->should_clear_all_soft_refs()) {
|
2010-04-13 13:52:10 -07:00
|
|
|
assert(clear_all_softrefs, "Policy should have been checked earlier");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// hook up weak ref data so it can be used during Mark-Sweep
|
|
|
|
assert(ref_processor() == NULL, "no stomping");
|
|
|
|
assert(rp != NULL, "should be non-NULL");
|
2015-09-02 09:14:04 +02:00
|
|
|
set_ref_processor(rp);
|
2008-12-01 23:25:24 -08:00
|
|
|
rp->setup_policy(clear_all_softrefs);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2013-06-10 11:30:51 +02:00
|
|
|
gch->trace_heap_before_gc(_gc_tracer);
|
2007-12-01 00:00:00 +00: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
|
|
|
// Increment the invocation count
|
|
|
|
_total_invocations++;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// 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).
|
2015-06-17 14:44:54 +02:00
|
|
|
gch->save_used_regions();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
allocate_stacks();
|
|
|
|
|
2015-06-17 14:44:54 +02:00
|
|
|
mark_sweep_phase1(clear_all_softrefs);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
mark_sweep_phase2();
|
|
|
|
|
|
|
|
// Don't add any more derived pointers during phase3
|
2017-11-06 21:28:03 -08:00
|
|
|
#if COMPILER2_OR_JVMCI
|
2015-10-08 12:49:30 -10:00
|
|
|
assert(DerivedPointerTable::is_active(), "Sanity");
|
|
|
|
DerivedPointerTable::set_active(false);
|
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-06-17 14:44:54 +02:00
|
|
|
mark_sweep_phase3();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
mark_sweep_phase4();
|
|
|
|
|
|
|
|
restore_marks();
|
|
|
|
|
|
|
|
// Set saved marks for allocation profiler (and other things? -- dld)
|
|
|
|
// (Should this be in general part?)
|
|
|
|
gch->save_marks();
|
|
|
|
|
|
|
|
deallocate_stacks();
|
|
|
|
|
2015-03-05 23:47:26 +01:00
|
|
|
// If compaction completely evacuated the young generation then we
|
|
|
|
// can clear the card table. Otherwise, we must invalidate
|
2007-12-01 00:00:00 +00:00
|
|
|
// it (consider all cards dirty). In the future, we might consider doing
|
|
|
|
// compaction within generations only, and doing card-table sliding.
|
2015-10-14 09:33:45 +02:00
|
|
|
CardTableRS* rs = gch->rem_set();
|
2015-03-05 23:47:26 +01:00
|
|
|
Generation* old_gen = gch->old_gen();
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Clear/invalidate below make use of the "prev_used_regions" saved earlier.
|
2015-03-05 23:47:26 +01:00
|
|
|
if (gch->young_gen()->used() == 0) {
|
|
|
|
// We've evacuated the young generation.
|
2013-08-15 10:05:50 +02:00
|
|
|
rs->clear_into_younger(old_gen);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
|
|
|
// Invalidate the cards corresponding to the currently used
|
2013-08-15 10:05:50 +02:00
|
|
|
// region and clear those corresponding to the evacuated region.
|
|
|
|
rs->invalidate_or_clear(old_gen);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2019-03-18 15:21:33 +01:00
|
|
|
gch->prune_scavengable_nmethods();
|
2011-01-19 13:51:53 -08:00
|
|
|
JvmtiExport::gc_epilogue();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// refs processing: clean slate
|
2015-09-02 09:14:04 +02:00
|
|
|
set_ref_processor(NULL);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Update heap occupancy information which is used as
|
|
|
|
// input to soft ref clearing policy at the next gc.
|
|
|
|
Universe::update_heap_info_at_gc();
|
|
|
|
|
|
|
|
// Update time of last gc for all generations we collected
|
2014-01-23 14:47:23 +01:00
|
|
|
// (which currently is all the generations in the heap).
|
|
|
|
// We need to use a monotonically non-decreasing time in ms
|
2012-01-18 09:50:16 -08:00
|
|
|
// or we will see time-warp warnings and os::javaTimeMillis()
|
|
|
|
// does not guarantee monotonicity.
|
|
|
|
jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
|
|
|
|
gch->update_time_of_last_gc(now);
|
2013-06-10 11:30:51 +02:00
|
|
|
|
|
|
|
gch->trace_heap_after_gc(_gc_tracer);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GenMarkSweep::allocate_stacks() {
|
|
|
|
GenCollectedHeap* gch = GenCollectedHeap::heap();
|
2015-03-05 23:47:26 +01:00
|
|
|
// Scratch request on behalf of old generation; will do no allocation.
|
|
|
|
ScratchBlock* scratch = gch->gather_scratch(gch->old_gen(), 0);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// $$$ To cut a corner, we'll only use the first scratch block, and then
|
|
|
|
// revert to malloc.
|
|
|
|
if (scratch != NULL) {
|
|
|
|
_preserved_count_max =
|
|
|
|
scratch->num_words * HeapWordSize / sizeof(PreservedMark);
|
|
|
|
} else {
|
|
|
|
_preserved_count_max = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_preserved_marks = (PreservedMark*)scratch;
|
|
|
|
_preserved_count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GenMarkSweep::deallocate_stacks() {
|
2017-11-15 17:05:28 +01:00
|
|
|
GenCollectedHeap* gch = GenCollectedHeap::heap();
|
|
|
|
gch->release_scratch();
|
2008-07-09 15:08:55 -07:00
|
|
|
|
2010-09-28 15:56:15 -07:00
|
|
|
_preserved_mark_stack.clear(true);
|
|
|
|
_preserved_oop_stack.clear(true);
|
|
|
|
_marking_stack.clear();
|
|
|
|
_objarray_stack.clear(true);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2015-06-17 14:44:54 +02:00
|
|
|
void GenMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Recursively traverse all live objects and mark them
|
2016-03-18 08:59:07 +01:00
|
|
|
GCTraceTime(Info, gc, phases) tm("Phase 1: Mark live objects", _gc_timer);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
GenCollectedHeap* gch = GenCollectedHeap::heap();
|
|
|
|
|
|
|
|
// Because follow_root_closure is created statically, cannot
|
|
|
|
// use OopsInGenClosure constructor which takes a generation,
|
|
|
|
// as the Universe has not been created when the static constructors
|
|
|
|
// are run.
|
2015-03-05 23:47:26 +01:00
|
|
|
follow_root_closure.set_orig_generation(gch->old_gen());
|
2007-12-01 00:00:00 +00: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
|
|
|
// Need new claim bits before marking starts.
|
|
|
|
ClassLoaderDataGraph::clear_claimed_marks();
|
|
|
|
|
2015-05-21 09:23:00 +02:00
|
|
|
{
|
|
|
|
StrongRootsScope srs(1);
|
|
|
|
|
2016-10-05 13:35:57 +02:00
|
|
|
gch->full_process_roots(&srs,
|
|
|
|
false, // not the adjust phase
|
|
|
|
GenCollectedHeap::SO_None,
|
|
|
|
ClassUnloading, // only strong roots if ClassUnloading
|
|
|
|
// is enabled
|
|
|
|
&follow_root_closure,
|
|
|
|
&follow_cld_closure);
|
2015-05-21 09:23:00 +02:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Process reference objects found during marking
|
|
|
|
{
|
2016-03-18 08:59:07 +01:00
|
|
|
GCTraceTime(Debug, gc, phases) tm_m("Reference Processing", gc_timer());
|
|
|
|
|
2008-12-01 23:25:24 -08:00
|
|
|
ref_processor()->setup_policy(clear_all_softrefs);
|
2018-06-04 21:20:16 -07:00
|
|
|
ReferenceProcessorPhaseTimes pt(_gc_timer, ref_processor()->max_num_queues());
|
2013-06-10 11:30:51 +02:00
|
|
|
const ReferenceProcessorStats& stats =
|
|
|
|
ref_processor()->process_discovered_references(
|
2017-08-10 18:09:19 -07:00
|
|
|
&is_alive, &keep_alive, &follow_stack_closure, NULL, &pt);
|
|
|
|
pt.print_all_references();
|
2013-06-10 11:30:51 +02:00
|
|
|
gc_tracer()->report_gc_reference_stats(stats);
|
2017-10-18 21:13:35 +02:00
|
|
|
}
|
|
|
|
|
2017-10-23 11:20:53 +02:00
|
|
|
// This is the point where the entire marking should have completed.
|
|
|
|
assert(_marking_stack.is_empty(), "Marking should have completed");
|
|
|
|
|
2017-10-18 21:13:35 +02:00
|
|
|
{
|
|
|
|
GCTraceTime(Debug, gc, phases) tm_m("Weak Processing", gc_timer());
|
2017-10-23 11:20:53 +02:00
|
|
|
WeakProcessor::weak_oops_do(&is_alive, &do_nothing_cl);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2016-03-17 21:01:59 +01:00
|
|
|
{
|
2016-03-18 08:59:07 +01:00
|
|
|
GCTraceTime(Debug, gc, phases) tm_m("Class Unloading", gc_timer());
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-03-17 21:01:59 +01:00
|
|
|
// Unload classes and purge the SystemDictionary.
|
2018-05-29 15:50:27 -04:00
|
|
|
bool purged_class = SystemDictionary::do_unloading(gc_timer());
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-03-17 21:01:59 +01:00
|
|
|
// Unload nmethods.
|
|
|
|
CodeCache::do_unloading(&is_alive, purged_class);
|
2009-09-02 00:04:29 -07:00
|
|
|
|
2016-03-17 21:01:59 +01:00
|
|
|
// Prune dead klasses from subklass/sibling/implementor lists.
|
2018-04-27 15:00:04 -04:00
|
|
|
Klass::clean_weak_klass_links(purged_class);
|
2016-03-17 21:01:59 +01:00
|
|
|
}
|
2013-04-26 10:40:36 +02:00
|
|
|
|
2013-06-10 11:30:51 +02:00
|
|
|
gc_tracer()->report_object_count_after_gc(&is_alive);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GenMarkSweep::mark_sweep_phase2() {
|
|
|
|
// Now all live objects are marked, compute the new object addresses.
|
|
|
|
|
|
|
|
// It is imperative that we traverse perm_gen LAST. If dead space is
|
|
|
|
// allowed a range of dead object may get overwritten by a dead int
|
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
|
|
|
// array. If perm_gen is not traversed last a Klass* may get
|
2007-12-01 00:00:00 +00:00
|
|
|
// overwritten. This is fine since it is dead, but if the class has dead
|
|
|
|
// instances we have to skip them, and in order to find their size we
|
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 the Klass*!
|
2007-12-01 00:00:00 +00:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
GenCollectedHeap* gch = GenCollectedHeap::heap();
|
|
|
|
|
2016-03-18 08:59:07 +01:00
|
|
|
GCTraceTime(Info, gc, phases) tm("Phase 2: Compute new object addresses", _gc_timer);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
gch->prepare_for_compaction();
|
|
|
|
}
|
|
|
|
|
|
|
|
class GenAdjustPointersClosure: public GenCollectedHeap::GenClosure {
|
|
|
|
public:
|
|
|
|
void do_generation(Generation* gen) {
|
|
|
|
gen->adjust_pointers();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-06-17 14:44:54 +02:00
|
|
|
void GenMarkSweep::mark_sweep_phase3() {
|
2007-12-01 00:00:00 +00:00
|
|
|
GenCollectedHeap* gch = GenCollectedHeap::heap();
|
|
|
|
|
|
|
|
// Adjust the pointers to reflect the new locations
|
2016-03-18 08:59:07 +01:00
|
|
|
GCTraceTime(Info, gc, phases) tm("Phase 3: Adjust pointers", gc_timer());
|
2007-12-01 00:00:00 +00: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
|
|
|
// Need new claim bits for the pointer adjustment tracing.
|
|
|
|
ClassLoaderDataGraph::clear_claimed_marks();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2013-04-22 20:27:36 +02:00
|
|
|
// Because the closure below is created statically, we cannot
|
2007-12-01 00:00:00 +00:00
|
|
|
// use OopsInGenClosure constructor which takes a generation,
|
|
|
|
// as the Universe has not been created when the static constructors
|
|
|
|
// are run.
|
2015-03-05 23:47:26 +01:00
|
|
|
adjust_pointer_closure.set_orig_generation(gch->old_gen());
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-05-21 09:23:00 +02:00
|
|
|
{
|
|
|
|
StrongRootsScope srs(1);
|
|
|
|
|
2016-10-05 13:35:57 +02:00
|
|
|
gch->full_process_roots(&srs,
|
|
|
|
true, // this is the adjust phase
|
|
|
|
GenCollectedHeap::SO_AllCodeCache,
|
|
|
|
false, // all roots
|
|
|
|
&adjust_pointer_closure,
|
|
|
|
&adjust_cld_closure);
|
2015-05-21 09:23:00 +02:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2014-02-13 17:44:39 +01:00
|
|
|
gch->gen_process_weak_roots(&adjust_pointer_closure);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
adjust_marks();
|
|
|
|
GenAdjustPointersClosure blk;
|
|
|
|
gch->generation_iterate(&blk, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
class GenCompactClosure: public GenCollectedHeap::GenClosure {
|
|
|
|
public:
|
|
|
|
void do_generation(Generation* gen) {
|
|
|
|
gen->compact();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void GenMarkSweep::mark_sweep_phase4() {
|
|
|
|
// All pointers are now adjusted, move objects accordingly
|
|
|
|
|
|
|
|
// It is imperative that we traverse perm_gen first in phase4. All
|
|
|
|
// classes must be allocated earlier than their instances, and traversing
|
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
|
|
|
// perm_gen first makes sure that all Klass*s have moved to their new
|
2007-12-01 00:00:00 +00:00
|
|
|
// location before any instance does a dispatch through it's klass!
|
|
|
|
|
|
|
|
// 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
|
|
|
|
// here (perm_gen first rather than last), so we tell the validate code
|
|
|
|
// to use a higher index (saved from phase2) when verifying perm_gen.
|
|
|
|
GenCollectedHeap* gch = GenCollectedHeap::heap();
|
|
|
|
|
2016-03-18 08:59:07 +01:00
|
|
|
GCTraceTime(Info, gc, phases) tm("Phase 4: Move objects", _gc_timer);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
GenCompactClosure blk;
|
|
|
|
gch->generation_iterate(&blk, true);
|
|
|
|
}
|