8264718: Shenandoah: enable string deduplication during root scanning

Reviewed-by: shade
This commit is contained in:
Zhengyu Gu 2021-04-08 12:09:21 +00:00
parent 255afbea92
commit 3aec2d9647
5 changed files with 43 additions and 30 deletions

View File

@ -191,8 +191,13 @@ ShenandoahMarkConcurrentRootsTask::ShenandoahMarkConcurrentRootsTask(ShenandoahO
void ShenandoahMarkConcurrentRootsTask::work(uint worker_id) {
ShenandoahConcurrentWorkerSession worker_session(worker_id);
ShenandoahObjToScanQueue* q = _queue_set->queue(worker_id);
ShenandoahMarkRefsClosure cl(q, _rp);
_root_scanner.roots_do(&cl, worker_id);
if (ShenandoahStringDedup::is_enabled()) {
ShenandoahMarkRefsDedupClosure cl(q, _rp);
_root_scanner.roots_do(&cl, worker_id);
} else {
ShenandoahMarkRefsClosure cl(q, _rp);
_root_scanner.roots_do(&cl, worker_id);
}
}
void ShenandoahConcurrentMark::mark_concurrent_roots() {

View File

@ -41,11 +41,6 @@ ShenandoahMarkRefsSuperClosure::ShenandoahMarkRefsSuperClosure(ShenandoahObjToSc
_weak(false)
{ }
ShenandoahInitMarkRootsClosure::ShenandoahInitMarkRootsClosure(ShenandoahObjToScanQueue* q) :
_queue(q),
_mark_context(ShenandoahHeap::heap()->marking_context()) {
}
ShenandoahMark::ShenandoahMark() :
_task_queues(ShenandoahHeap::heap()->marking_context()->task_queues()) {
}

View File

@ -31,21 +31,6 @@
class ShenandoahCMDrainMarkingStackClosure;
class ShenandoahInitMarkRootsClosure : public OopClosure {
private:
ShenandoahObjToScanQueue* const _queue;
ShenandoahMarkingContext* const _mark_context;
template <class T>
inline void do_oop_work(T* p);
public:
ShenandoahInitMarkRootsClosure(ShenandoahObjToScanQueue* q);
void do_oop(narrowOop* p) { do_oop_work(p); }
void do_oop(oop* p) { do_oop_work(p); }
};
// Base class for mark
// Mark class does not maintain states. Instead, mark states are
// maintained by task queues, mark bitmap and SATB buffers (concurrent mark)

View File

@ -39,11 +39,6 @@
#include "runtime/prefetch.inline.hpp"
#include "utilities/powerOfTwo.hpp"
template <class T>
void ShenandoahInitMarkRootsClosure::do_oop_work(T* p) {
ShenandoahMark::mark_through_ref<T, NO_DEDUP>(p, _queue, _mark_context, false);
}
template <class T>
void ShenandoahMark::do_task(ShenandoahObjToScanQueue* q, T* cl, ShenandoahLiveData* live_data, ShenandoahMarkTask* task) {
oop obj = task->obj();

View File

@ -33,9 +33,38 @@
#include "gc/shenandoah/shenandoahOopClosures.inline.hpp"
#include "gc/shenandoah/shenandoahReferenceProcessor.hpp"
#include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
#include "gc/shenandoah/shenandoahStringDedup.hpp"
#include "gc/shenandoah/shenandoahSTWMark.hpp"
#include "gc/shenandoah/shenandoahVerifier.hpp"
template <StringDedupMode STRING_DEDUP>
class ShenandoahInitMarkRootsClosure : public OopClosure {
private:
ShenandoahObjToScanQueue* const _queue;
ShenandoahMarkingContext* const _mark_context;
template <class T>
inline void do_oop_work(T* p);
public:
ShenandoahInitMarkRootsClosure(ShenandoahObjToScanQueue* q);
void do_oop(narrowOop* p) { do_oop_work(p); }
void do_oop(oop* p) { do_oop_work(p); }
};
template <StringDedupMode STRING_DEDUP>
ShenandoahInitMarkRootsClosure<STRING_DEDUP>::ShenandoahInitMarkRootsClosure(ShenandoahObjToScanQueue* q) :
_queue(q),
_mark_context(ShenandoahHeap::heap()->marking_context()) {
}
template <StringDedupMode STRING_DEDUP>
template <class T>
void ShenandoahInitMarkRootsClosure<STRING_DEDUP>::do_oop_work(T* p) {
ShenandoahMark::mark_through_ref<T, STRING_DEDUP>(p, _queue, _mark_context, false);
}
class ShenandoahSTWMarkTask : public AbstractGangTask {
private:
ShenandoahSTWMark* const _mark;
@ -99,8 +128,13 @@ void ShenandoahSTWMark::mark() {
}
void ShenandoahSTWMark::mark_roots(uint worker_id) {
ShenandoahInitMarkRootsClosure init_mark(task_queues()->queue(worker_id));
_root_scanner.roots_do(&init_mark, worker_id);
if (ShenandoahStringDedup::is_enabled()) {
ShenandoahInitMarkRootsClosure<ENQUEUE_DEDUP> init_mark(task_queues()->queue(worker_id));
_root_scanner.roots_do(&init_mark, worker_id);
} else {
ShenandoahInitMarkRootsClosure<NO_DEDUP> init_mark(task_queues()->queue(worker_id));
_root_scanner.roots_do(&init_mark, worker_id);
}
}
void ShenandoahSTWMark::finish_mark(uint worker_id) {
@ -112,4 +146,3 @@ void ShenandoahSTWMark::finish_mark(uint worker_id) {
false, // not cancellable
ShenandoahStringDedup::is_enabled());
}