mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
8221629: Shenandoah: Cleanup class unloading logic
Reviewed-by: rkennke
This commit is contained in:
parent
37c8c96916
commit
3320a7ea1f
6 changed files with 65 additions and 61 deletions
|
@ -36,7 +36,7 @@
|
||||||
#include "gc/shenandoah/shenandoahConcurrentMark.inline.hpp"
|
#include "gc/shenandoah/shenandoahConcurrentMark.inline.hpp"
|
||||||
#include "gc/shenandoah/shenandoahMarkCompact.hpp"
|
#include "gc/shenandoah/shenandoahMarkCompact.hpp"
|
||||||
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
|
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
|
||||||
#include "gc/shenandoah/shenandoahRootProcessor.hpp"
|
#include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
|
||||||
#include "gc/shenandoah/shenandoahOopClosures.inline.hpp"
|
#include "gc/shenandoah/shenandoahOopClosures.inline.hpp"
|
||||||
#include "gc/shenandoah/shenandoahTaskqueue.inline.hpp"
|
#include "gc/shenandoah/shenandoahTaskqueue.inline.hpp"
|
||||||
#include "gc/shenandoah/shenandoahTimingTracker.hpp"
|
#include "gc/shenandoah/shenandoahTimingTracker.hpp"
|
||||||
|
@ -123,7 +123,7 @@ private:
|
||||||
|
|
||||||
ResourceMark m;
|
ResourceMark m;
|
||||||
if (heap->unload_classes()) {
|
if (heap->unload_classes()) {
|
||||||
_rp->process_strong_roots(oops, &clds_cl, NULL, &blobs_cl, NULL, worker_id);
|
_rp->process_strong_roots(oops, &clds_cl, &blobs_cl, NULL, worker_id);
|
||||||
} else {
|
} else {
|
||||||
if (ShenandoahConcurrentScanCodeRoots) {
|
if (ShenandoahConcurrentScanCodeRoots) {
|
||||||
CodeBlobClosure* code_blobs = NULL;
|
CodeBlobClosure* code_blobs = NULL;
|
||||||
|
@ -176,7 +176,7 @@ public:
|
||||||
DEBUG_ONLY(&assert_to_space)
|
DEBUG_ONLY(&assert_to_space)
|
||||||
NOT_DEBUG(NULL);
|
NOT_DEBUG(NULL);
|
||||||
}
|
}
|
||||||
_rp->update_all_roots(&cl, &cldCl, code_blobs, NULL, worker_id);
|
_rp->update_all_roots<AlwaysTrueClosure>(&cl, &cldCl, code_blobs, NULL, worker_id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
|
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
|
||||||
#include "gc/shenandoah/shenandoahHeuristics.hpp"
|
#include "gc/shenandoah/shenandoahHeuristics.hpp"
|
||||||
#include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
|
#include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
|
||||||
#include "gc/shenandoah/shenandoahRootProcessor.hpp"
|
#include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
|
||||||
#include "gc/shenandoah/shenandoahTraversalGC.hpp"
|
#include "gc/shenandoah/shenandoahTraversalGC.hpp"
|
||||||
#include "gc/shenandoah/shenandoahTaskqueue.inline.hpp"
|
#include "gc/shenandoah/shenandoahTaskqueue.inline.hpp"
|
||||||
#include "gc/shenandoah/shenandoahUtils.hpp"
|
#include "gc/shenandoah/shenandoahUtils.hpp"
|
||||||
|
@ -572,9 +572,9 @@ public:
|
||||||
MarkingCodeBlobClosure adjust_code_closure(&cl,
|
MarkingCodeBlobClosure adjust_code_closure(&cl,
|
||||||
CodeBlobToOopClosure::FixRelocations);
|
CodeBlobToOopClosure::FixRelocations);
|
||||||
|
|
||||||
_rp->update_all_roots(&cl,
|
_rp->update_all_roots<AlwaysTrueClosure>(&cl,
|
||||||
&adjust_cld_closure,
|
&adjust_cld_closure,
|
||||||
&adjust_code_closure, NULL, worker_id);
|
&adjust_code_closure, NULL, worker_id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -130,12 +130,11 @@ void ShenandoahRootProcessor::process_all_roots_slow(OopClosure* oops) {
|
||||||
|
|
||||||
void ShenandoahRootProcessor::process_strong_roots(OopClosure* oops,
|
void ShenandoahRootProcessor::process_strong_roots(OopClosure* oops,
|
||||||
CLDClosure* clds,
|
CLDClosure* clds,
|
||||||
CLDClosure* weak_clds,
|
|
||||||
CodeBlobClosure* blobs,
|
CodeBlobClosure* blobs,
|
||||||
ThreadClosure* thread_cl,
|
ThreadClosure* thread_cl,
|
||||||
uint worker_id) {
|
uint worker_id) {
|
||||||
|
|
||||||
process_java_roots(oops, clds, weak_clds, blobs, thread_cl, worker_id);
|
process_java_roots(oops, clds, NULL, blobs, thread_cl, worker_id);
|
||||||
process_vm_roots(oops, worker_id);
|
process_vm_roots(oops, worker_id);
|
||||||
|
|
||||||
_process_strong_tasks->all_tasks_completed(n_workers());
|
_process_strong_tasks->all_tasks_completed(n_workers());
|
||||||
|
@ -160,39 +159,6 @@ void ShenandoahRootProcessor::process_all_roots(OopClosure* oops,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShenandoahRootProcessor::update_all_roots(OopClosure* oops,
|
|
||||||
CLDClosure* clds,
|
|
||||||
CodeBlobClosure* blobs,
|
|
||||||
ThreadClosure* thread_cl,
|
|
||||||
uint worker_id) {
|
|
||||||
process_all_roots(oops, clds, blobs, thread_cl, worker_id);
|
|
||||||
|
|
||||||
AlwaysTrueClosure always_true;
|
|
||||||
_weak_processor_task.work<AlwaysTrueClosure, OopClosure>(worker_id, &always_true, oops);
|
|
||||||
_processed_weak_roots = true;
|
|
||||||
|
|
||||||
if (ShenandoahStringDedup::is_enabled()) {
|
|
||||||
ShenandoahStringDedup::parallel_oops_do(&always_true, oops, worker_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShenandoahRootProcessor::traversal_update_all_roots(OopClosure* oops,
|
|
||||||
CLDClosure* clds,
|
|
||||||
CodeBlobClosure* blobs,
|
|
||||||
ThreadClosure* thread_cl,
|
|
||||||
uint worker_id) {
|
|
||||||
process_all_roots(oops, clds, blobs, thread_cl, worker_id);
|
|
||||||
|
|
||||||
ShenandoahIsAliveSelector is_alive;
|
|
||||||
BoolObjectClosure* is_alive_closure = is_alive.is_alive_closure();
|
|
||||||
_weak_processor_task.work<BoolObjectClosure, OopClosure>(worker_id, is_alive_closure, oops);
|
|
||||||
_processed_weak_roots = true;
|
|
||||||
|
|
||||||
if (ShenandoahStringDedup::is_enabled()) {
|
|
||||||
ShenandoahStringDedup::parallel_oops_do(is_alive_closure, oops, worker_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ShenandoahParallelOopsDoThreadClosure : public ThreadClosure {
|
class ShenandoahParallelOopsDoThreadClosure : public ThreadClosure {
|
||||||
private:
|
private:
|
||||||
OopClosure* _f;
|
OopClosure* _f;
|
||||||
|
|
|
@ -89,7 +89,6 @@ public:
|
||||||
// for the particular GC cycles.
|
// for the particular GC cycles.
|
||||||
void process_strong_roots(OopClosure* oops,
|
void process_strong_roots(OopClosure* oops,
|
||||||
CLDClosure* clds,
|
CLDClosure* clds,
|
||||||
CLDClosure* weak_clds,
|
|
||||||
CodeBlobClosure* blobs,
|
CodeBlobClosure* blobs,
|
||||||
ThreadClosure* thread_cl,
|
ThreadClosure* thread_cl,
|
||||||
uint worker_id);
|
uint worker_id);
|
||||||
|
@ -102,22 +101,13 @@ public:
|
||||||
uint worker_id);
|
uint worker_id);
|
||||||
|
|
||||||
// Apply oops, clds and blobs to strongly and weakly reachable roots in the system
|
// Apply oops, clds and blobs to strongly and weakly reachable roots in the system
|
||||||
|
template <typename IsAlive>
|
||||||
void update_all_roots(OopClosure* oops,
|
void update_all_roots(OopClosure* oops,
|
||||||
CLDClosure* clds,
|
CLDClosure* clds,
|
||||||
CodeBlobClosure* blobs,
|
CodeBlobClosure* blobs,
|
||||||
ThreadClosure* thread_cl,
|
ThreadClosure* thread_cl,
|
||||||
uint worker_id);
|
uint worker_id);
|
||||||
|
|
||||||
|
|
||||||
// Apply oops, clds and blobs to strongly and weakly reachable roots in the system
|
|
||||||
// during traversal GC.
|
|
||||||
// It cleans up and updates weak roots in one iteration.
|
|
||||||
void traversal_update_all_roots(OopClosure* oops,
|
|
||||||
CLDClosure* clds,
|
|
||||||
CodeBlobClosure* blobs,
|
|
||||||
ThreadClosure* thread_cl,
|
|
||||||
uint worker_id);
|
|
||||||
|
|
||||||
// For slow debug/verification code
|
// For slow debug/verification code
|
||||||
void process_all_roots_slow(OopClosure* oops);
|
void process_all_roots_slow(OopClosure* oops);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Red Hat, Inc. All rights reserved.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP
|
||||||
|
#define SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP
|
||||||
|
|
||||||
|
#include "gc/shenandoah/shenandoahRootProcessor.hpp"
|
||||||
|
|
||||||
|
template <typename IsAlive>
|
||||||
|
void ShenandoahRootProcessor::update_all_roots(OopClosure* oops,
|
||||||
|
CLDClosure* clds,
|
||||||
|
CodeBlobClosure* blobs,
|
||||||
|
ThreadClosure* thread_cl,
|
||||||
|
uint worker_id) {
|
||||||
|
process_all_roots(oops, clds, blobs, thread_cl, worker_id);
|
||||||
|
|
||||||
|
IsAlive is_alive;
|
||||||
|
_weak_processor_task.work<IsAlive, OopClosure>(worker_id, &is_alive, oops);
|
||||||
|
_processed_weak_roots = true;
|
||||||
|
|
||||||
|
if (ShenandoahStringDedup::is_enabled()) {
|
||||||
|
ShenandoahStringDedup::parallel_oops_do(&is_alive, oops, worker_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP
|
|
@ -40,7 +40,7 @@
|
||||||
#include "gc/shenandoah/shenandoahHeuristics.hpp"
|
#include "gc/shenandoah/shenandoahHeuristics.hpp"
|
||||||
#include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
|
#include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
|
||||||
#include "gc/shenandoah/shenandoahOopClosures.inline.hpp"
|
#include "gc/shenandoah/shenandoahOopClosures.inline.hpp"
|
||||||
#include "gc/shenandoah/shenandoahRootProcessor.hpp"
|
#include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
|
||||||
#include "gc/shenandoah/shenandoahStringDedup.hpp"
|
#include "gc/shenandoah/shenandoahStringDedup.hpp"
|
||||||
#include "gc/shenandoah/shenandoahTaskqueue.inline.hpp"
|
#include "gc/shenandoah/shenandoahTaskqueue.inline.hpp"
|
||||||
#include "gc/shenandoah/shenandoahTimingTracker.hpp"
|
#include "gc/shenandoah/shenandoahTimingTracker.hpp"
|
||||||
|
@ -188,7 +188,7 @@ public:
|
||||||
ShenandoahMarkCLDClosure cld_cl(&roots_cl);
|
ShenandoahMarkCLDClosure cld_cl(&roots_cl);
|
||||||
MarkingCodeBlobClosure code_cl(&roots_cl, CodeBlobToOopClosure::FixRelocations);
|
MarkingCodeBlobClosure code_cl(&roots_cl, CodeBlobToOopClosure::FixRelocations);
|
||||||
if (unload_classes) {
|
if (unload_classes) {
|
||||||
_rp->process_strong_roots(&roots_cl, &cld_cl, NULL, NULL, NULL, worker_id);
|
_rp->process_strong_roots(&roots_cl, &cld_cl, NULL, NULL, worker_id);
|
||||||
// Need to pre-evac code roots here. Otherwise we might see from-space constants.
|
// Need to pre-evac code roots here. Otherwise we might see from-space constants.
|
||||||
ShenandoahWorkerTimings* worker_times = _heap->phase_timings()->worker_times();
|
ShenandoahWorkerTimings* worker_times = _heap->phase_timings()->worker_times();
|
||||||
ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::CodeCacheRoots, worker_id);
|
ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::CodeCacheRoots, worker_id);
|
||||||
|
@ -269,8 +269,8 @@ public:
|
||||||
CLDToOopClosure cld_cl(&roots_cl, ClassLoaderData::_claim_strong);
|
CLDToOopClosure cld_cl(&roots_cl, ClassLoaderData::_claim_strong);
|
||||||
ShenandoahTraversalSATBThreadsClosure tc(&satb_cl);
|
ShenandoahTraversalSATBThreadsClosure tc(&satb_cl);
|
||||||
if (unload_classes) {
|
if (unload_classes) {
|
||||||
ShenandoahRemarkCLDClosure weak_cld_cl(&roots_cl);
|
ShenandoahRemarkCLDClosure remark_cld_cl(&roots_cl);
|
||||||
_rp->process_strong_roots(&roots_cl, &cld_cl, &weak_cld_cl, NULL, &tc, worker_id);
|
_rp->process_strong_roots(&roots_cl, &remark_cld_cl, NULL, &tc, worker_id);
|
||||||
} else {
|
} else {
|
||||||
_rp->process_all_roots(&roots_cl, &cld_cl, NULL, &tc, worker_id);
|
_rp->process_all_roots(&roots_cl, &cld_cl, NULL, &tc, worker_id);
|
||||||
}
|
}
|
||||||
|
@ -279,8 +279,8 @@ public:
|
||||||
CLDToOopClosure cld_cl(&roots_cl, ClassLoaderData::_claim_strong);
|
CLDToOopClosure cld_cl(&roots_cl, ClassLoaderData::_claim_strong);
|
||||||
ShenandoahTraversalSATBThreadsClosure tc(&satb_cl);
|
ShenandoahTraversalSATBThreadsClosure tc(&satb_cl);
|
||||||
if (unload_classes) {
|
if (unload_classes) {
|
||||||
ShenandoahRemarkCLDClosure weak_cld_cl(&roots_cl);
|
ShenandoahRemarkCLDClosure remark_cld_cl(&roots_cl);
|
||||||
_rp->process_strong_roots(&roots_cl, &cld_cl, &weak_cld_cl, NULL, &tc, worker_id);
|
_rp->process_strong_roots(&roots_cl, &remark_cld_cl, NULL, &tc, worker_id);
|
||||||
} else {
|
} else {
|
||||||
_rp->process_all_roots(&roots_cl, &cld_cl, NULL, &tc, worker_id);
|
_rp->process_all_roots(&roots_cl, &cld_cl, NULL, &tc, worker_id);
|
||||||
}
|
}
|
||||||
|
@ -694,14 +694,16 @@ private:
|
||||||
public:
|
public:
|
||||||
ShenandoahTraversalFixRootsTask(ShenandoahRootProcessor* rp) :
|
ShenandoahTraversalFixRootsTask(ShenandoahRootProcessor* rp) :
|
||||||
AbstractGangTask("Shenandoah traversal fix roots"),
|
AbstractGangTask("Shenandoah traversal fix roots"),
|
||||||
_rp(rp) {}
|
_rp(rp) {
|
||||||
|
assert(ShenandoahHeap::heap()->has_forwarded_objects(), "Must be");
|
||||||
|
}
|
||||||
|
|
||||||
void work(uint worker_id) {
|
void work(uint worker_id) {
|
||||||
ShenandoahParallelWorkerSession worker_session(worker_id);
|
ShenandoahParallelWorkerSession worker_session(worker_id);
|
||||||
ShenandoahTraversalFixRootsClosure cl;
|
ShenandoahTraversalFixRootsClosure cl;
|
||||||
MarkingCodeBlobClosure blobsCl(&cl, CodeBlobToOopClosure::FixRelocations);
|
MarkingCodeBlobClosure blobsCl(&cl, CodeBlobToOopClosure::FixRelocations);
|
||||||
CLDToOopClosure cldCl(&cl, ClassLoaderData::_claim_strong);
|
CLDToOopClosure cldCl(&cl, ClassLoaderData::_claim_strong);
|
||||||
_rp->traversal_update_all_roots(&cl, &cldCl, &blobsCl, NULL, worker_id);
|
_rp->update_all_roots<ShenandoahForwardedIsAliveClosure>(&cl, &cldCl, &blobsCl, NULL, worker_id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue