Skip to content
Permalink
Browse files
8266083: Shenandoah: Consolidate dedup/no dedup oop closures
Reviewed-by: rkennke
  • Loading branch information
zhengyu123 committed May 3, 2021
1 parent 80941f4 commit 1d9ea3ae0ff6e5283781c8e088578c2e8df63aaa
@@ -144,7 +144,7 @@ class ShenandoahFinalMarkingTask : public AbstractGangTask {
while (satb_mq_set.apply_closure_to_completed_buffer(&cl)) {}
assert(!heap->has_forwarded_objects(), "Not expected");

ShenandoahMarkRefsClosure mark_cl(q, rp);
ShenandoahMarkRefsClosure<NO_DEDUP> mark_cl(q, rp);
ShenandoahSATBAndRemarkThreadsClosure tc(satb_mq_set,
ShenandoahIUBarrier ? &mark_cl : NULL);
Threads::threads_do(&tc);
@@ -191,7 +191,9 @@ 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);
// Cannot enable string deduplication during root scanning. Otherwise,
// may result lock inversion between stack watermark and string dedup queue lock.
ShenandoahMarkRefsClosure<NO_DEDUP> cl(q, _rp);
_root_scanner.roots_do(&cl, worker_id);
}

@@ -67,37 +67,45 @@ void ShenandoahMark::mark_loop_prework(uint w, TaskTerminator *t, ShenandoahRefe
if (heap->unload_classes()) {
if (heap->has_forwarded_objects()) {
if (strdedup) {
ShenandoahMarkUpdateRefsMetadataDedupClosure cl(q, rp);
mark_loop_work<ShenandoahMarkUpdateRefsMetadataDedupClosure, CANCELLABLE>(&cl, ld, w, t);
using Closure = ShenandoahMarkUpdateRefsMetadataClosure<ENQUEUE_DEDUP>;
Closure cl(q, rp);
mark_loop_work<Closure, CANCELLABLE>(&cl, ld, w, t);
} else {
ShenandoahMarkUpdateRefsMetadataClosure cl(q, rp);
mark_loop_work<ShenandoahMarkUpdateRefsMetadataClosure, CANCELLABLE>(&cl, ld, w, t);
using Closure = ShenandoahMarkUpdateRefsMetadataClosure<NO_DEDUP>;
Closure cl(q, rp);
mark_loop_work<Closure, CANCELLABLE>(&cl, ld, w, t);
}
} else {
if (strdedup) {
ShenandoahMarkRefsMetadataDedupClosure cl(q, rp);
mark_loop_work<ShenandoahMarkRefsMetadataDedupClosure, CANCELLABLE>(&cl, ld, w, t);
using Closure = ShenandoahMarkRefsMetadataClosure<ENQUEUE_DEDUP>;
Closure cl(q, rp);
mark_loop_work<Closure, CANCELLABLE>(&cl, ld, w, t);
} else {
ShenandoahMarkRefsMetadataClosure cl(q, rp);
mark_loop_work<ShenandoahMarkRefsMetadataClosure, CANCELLABLE>(&cl, ld, w, t);
using Closure = ShenandoahMarkRefsMetadataClosure<NO_DEDUP>;
Closure cl(q, rp);
mark_loop_work<Closure, CANCELLABLE>(&cl, ld, w, t);
}
}
} else {
if (heap->has_forwarded_objects()) {
if (strdedup) {
ShenandoahMarkUpdateRefsDedupClosure cl(q, rp);
mark_loop_work<ShenandoahMarkUpdateRefsDedupClosure, CANCELLABLE>(&cl, ld, w, t);
using Closure = ShenandoahMarkUpdateRefsClosure<ENQUEUE_DEDUP>;
Closure cl(q, rp);
mark_loop_work<Closure, CANCELLABLE>(&cl, ld, w, t);
} else {
ShenandoahMarkUpdateRefsClosure cl(q, rp);
mark_loop_work<ShenandoahMarkUpdateRefsClosure, CANCELLABLE>(&cl, ld, w, t);
using Closure = ShenandoahMarkUpdateRefsClosure<NO_DEDUP>;
Closure cl(q, rp);
mark_loop_work<Closure, CANCELLABLE>(&cl, ld, w, t);
}
} else {
if (strdedup) {
ShenandoahMarkRefsDedupClosure cl(q, rp);
mark_loop_work<ShenandoahMarkRefsDedupClosure, CANCELLABLE>(&cl, ld, w, t);
using Closure = ShenandoahMarkRefsClosure<ENQUEUE_DEDUP>;
Closure cl(q, rp);
mark_loop_work<Closure, CANCELLABLE>(&cl, ld, w, t);
} else {
ShenandoahMarkRefsClosure cl(q, rp);
mark_loop_work<ShenandoahMarkRefsClosure, CANCELLABLE>(&cl, ld, w, t);
using Closure = ShenandoahMarkRefsClosure<NO_DEDUP>;
Closure cl(q, rp);
mark_loop_work<Closure, CANCELLABLE>(&cl, ld, w, t);
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Red Hat, Inc. All rights reserved.
* Copyright (c) 2015, 2021, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -75,10 +75,11 @@ class ShenandoahMarkUpdateRefsSuperClosure : public ShenandoahMarkRefsSuperClosu
};
};

template <StringDedupMode STRING_DEDUP>
class ShenandoahMarkUpdateRefsClosure : public ShenandoahMarkUpdateRefsSuperClosure {
private:
template <class T>
inline void do_oop_work(T* p) { work<T, NO_DEDUP>(p); }
inline void do_oop_work(T* p) { work<T, STRING_DEDUP>(p); }

public:
ShenandoahMarkUpdateRefsClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp) :
@@ -89,24 +90,11 @@ class ShenandoahMarkUpdateRefsClosure : public ShenandoahMarkUpdateRefsSuperClos
virtual bool do_metadata() { return false; }
};

class ShenandoahMarkUpdateRefsDedupClosure : public ShenandoahMarkUpdateRefsSuperClosure {
private:
template <class T>
inline void do_oop_work(T* p) { work<T, ENQUEUE_DEDUP>(p); }

public:
ShenandoahMarkUpdateRefsDedupClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp) :
ShenandoahMarkUpdateRefsSuperClosure(q, rp) {}

virtual void do_oop(narrowOop* p) { do_oop_work(p); }
virtual void do_oop(oop* p) { do_oop_work(p); }
virtual bool do_metadata() { return false; }
};

template <StringDedupMode STRING_DEDUP>
class ShenandoahMarkUpdateRefsMetadataClosure : public ShenandoahMarkUpdateRefsSuperClosure {
private:
template <class T>
inline void do_oop_work(T* p) { work<T, NO_DEDUP>(p); }
inline void do_oop_work(T* p) { work<T, STRING_DEDUP>(p); }

public:
ShenandoahMarkUpdateRefsMetadataClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp) :
@@ -117,24 +105,12 @@ class ShenandoahMarkUpdateRefsMetadataClosure : public ShenandoahMarkUpdateRefsS
virtual bool do_metadata() { return true; }
};

class ShenandoahMarkUpdateRefsMetadataDedupClosure : public ShenandoahMarkUpdateRefsSuperClosure {
private:
template <class T>
inline void do_oop_work(T* p) { work<T, ENQUEUE_DEDUP>(p); }

public:
ShenandoahMarkUpdateRefsMetadataDedupClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp) :
ShenandoahMarkUpdateRefsSuperClosure(q, rp) {}

virtual void do_oop(narrowOop* p) { do_oop_work(p); }
virtual void do_oop(oop* p) { do_oop_work(p); }
virtual bool do_metadata() { return true; }
};

template <StringDedupMode STRING_DEDUP>
class ShenandoahMarkRefsClosure : public ShenandoahMarkRefsSuperClosure {
private:
template <class T>
inline void do_oop_work(T* p) { work<T, NO_DEDUP>(p); }
inline void do_oop_work(T* p) { work<T, STRING_DEDUP>(p); }

public:
ShenandoahMarkRefsClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp) :
@@ -145,24 +121,12 @@ class ShenandoahMarkRefsClosure : public ShenandoahMarkRefsSuperClosure {
virtual bool do_metadata() { return false; }
};

class ShenandoahMarkRefsDedupClosure : public ShenandoahMarkRefsSuperClosure {
private:
template <class T>
inline void do_oop_work(T* p) { work<T, ENQUEUE_DEDUP>(p); }

public:
ShenandoahMarkRefsDedupClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp) :
ShenandoahMarkRefsSuperClosure(q, rp) {};

virtual void do_oop(narrowOop* p) { do_oop_work(p); }
virtual void do_oop(oop* p) { do_oop_work(p); }
virtual bool do_metadata() { return false; }
};

template <StringDedupMode STRING_DEDUP>
class ShenandoahMarkRefsMetadataClosure : public ShenandoahMarkRefsSuperClosure {
private:
template <class T>
inline void do_oop_work(T* p) { work<T, NO_DEDUP>(p); }
inline void do_oop_work(T* p) { work<T, STRING_DEDUP>(p); }

public:
ShenandoahMarkRefsMetadataClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp) :
@@ -173,20 +137,6 @@ class ShenandoahMarkRefsMetadataClosure : public ShenandoahMarkRefsSuperClosure
virtual bool do_metadata() { return true; }
};

class ShenandoahMarkRefsMetadataDedupClosure : public ShenandoahMarkRefsSuperClosure {
private:
template <class T>
inline void do_oop_work(T* p) { work<T, ENQUEUE_DEDUP>(p); }

public:
ShenandoahMarkRefsMetadataDedupClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp) :
ShenandoahMarkRefsSuperClosure(q, rp) {};

virtual void do_oop(narrowOop* p) { do_oop_work(p); }
virtual void do_oop(oop* p) { do_oop_work(p); }
virtual bool do_metadata() { return true; }
};

class ShenandoahUpdateRefsSuperClosure : public BasicOopIterateClosure {
protected:
ShenandoahHeap* _heap;

0 comments on commit 1d9ea3a

Please sign in to comment.