mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-12 14:39:49 +00:00
8202649: Move the Parallel GC specific task creation functions out of Threads
Reviewed-by: ehelin, pliden
This commit is contained in:
parent
99072b90d7
commit
c590979683
@ -60,15 +60,7 @@ void ThreadRootsMarkingTask::do_it(GCTaskManager* manager, uint which) {
|
||||
ParCompactionManager::MarkAndPushClosure mark_and_push_closure(cm);
|
||||
MarkingCodeBlobClosure mark_and_push_in_blobs(&mark_and_push_closure, !CodeBlobToOopClosure::FixRelocations);
|
||||
|
||||
if (_java_thread != NULL)
|
||||
_java_thread->oops_do(
|
||||
&mark_and_push_closure,
|
||||
&mark_and_push_in_blobs);
|
||||
|
||||
if (_vm_thread != NULL)
|
||||
_vm_thread->oops_do(
|
||||
&mark_and_push_closure,
|
||||
&mark_and_push_in_blobs);
|
||||
_thread->oops_do(&mark_and_push_closure, &mark_and_push_in_blobs);
|
||||
|
||||
// Do the real work
|
||||
cm->follow_marking_stacks();
|
||||
|
||||
@ -67,11 +67,10 @@ class ParallelTaskTerminator;
|
||||
|
||||
class ThreadRootsMarkingTask : public GCTask {
|
||||
private:
|
||||
JavaThread* _java_thread;
|
||||
VMThread* _vm_thread;
|
||||
Thread* _thread;
|
||||
|
||||
public:
|
||||
ThreadRootsMarkingTask(JavaThread* root) : _java_thread(root), _vm_thread(NULL) {}
|
||||
ThreadRootsMarkingTask(VMThread* root) : _java_thread(NULL), _vm_thread(root) {}
|
||||
ThreadRootsMarkingTask(Thread* root) : _thread(root) {}
|
||||
|
||||
char* name() { return (char *)"thread-roots-marking-task"; }
|
||||
|
||||
|
||||
@ -2049,6 +2049,17 @@ GCTaskManager* const PSParallelCompact::gc_task_manager() {
|
||||
return ParallelScavengeHeap::gc_task_manager();
|
||||
}
|
||||
|
||||
class PCAddThreadRootsMarkingTaskClosure : public ThreadClosure {
|
||||
private:
|
||||
GCTaskQueue* _q;
|
||||
|
||||
public:
|
||||
PCAddThreadRootsMarkingTaskClosure(GCTaskQueue* q) : _q(q) { }
|
||||
void do_thread(Thread* t) {
|
||||
_q->enqueue(new ThreadRootsMarkingTask(t));
|
||||
}
|
||||
};
|
||||
|
||||
void PSParallelCompact::marking_phase(ParCompactionManager* cm,
|
||||
bool maximum_heap_compaction,
|
||||
ParallelOldTracer *gc_tracer) {
|
||||
@ -2077,7 +2088,8 @@ void PSParallelCompact::marking_phase(ParCompactionManager* cm,
|
||||
q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::universe));
|
||||
q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::jni_handles));
|
||||
// We scan the thread roots in parallel
|
||||
Threads::create_thread_roots_marking_tasks(q);
|
||||
PCAddThreadRootsMarkingTaskClosure cl(q);
|
||||
Threads::java_threads_and_vm_thread_do(&cl);
|
||||
q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::object_synchronizer));
|
||||
q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::management));
|
||||
q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::system_dictionary));
|
||||
|
||||
@ -242,6 +242,17 @@ bool PSScavenge::invoke() {
|
||||
return full_gc_done;
|
||||
}
|
||||
|
||||
class PSAddThreadRootsTaskClosure : public ThreadClosure {
|
||||
private:
|
||||
GCTaskQueue* _q;
|
||||
|
||||
public:
|
||||
PSAddThreadRootsTaskClosure(GCTaskQueue* q) : _q(q) { }
|
||||
void do_thread(Thread* t) {
|
||||
_q->enqueue(new ThreadRootsTask(t));
|
||||
}
|
||||
};
|
||||
|
||||
// This method contains no policy. You should probably
|
||||
// be calling invoke() instead.
|
||||
bool PSScavenge::invoke_no_policy() {
|
||||
@ -382,7 +393,8 @@ bool PSScavenge::invoke_no_policy() {
|
||||
q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::universe));
|
||||
q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::jni_handles));
|
||||
// We scan the thread roots in parallel
|
||||
Threads::create_thread_roots_tasks(q);
|
||||
PSAddThreadRootsTaskClosure cl(q);
|
||||
Threads::java_threads_and_vm_thread_do(&cl);
|
||||
q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::object_synchronizer));
|
||||
q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::management));
|
||||
q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::system_dictionary));
|
||||
|
||||
@ -119,11 +119,7 @@ void ThreadRootsTask::do_it(GCTaskManager* manager, uint which) {
|
||||
PSScavengeRootsClosure roots_closure(pm);
|
||||
MarkingCodeBlobClosure roots_in_blobs(&roots_closure, CodeBlobToOopClosure::FixRelocations);
|
||||
|
||||
if (_java_thread != NULL)
|
||||
_java_thread->oops_do(&roots_closure, &roots_in_blobs);
|
||||
|
||||
if (_vm_thread != NULL)
|
||||
_vm_thread->oops_do(&roots_closure, &roots_in_blobs);
|
||||
_thread->oops_do(&roots_closure, &roots_in_blobs);
|
||||
|
||||
// Do the real work
|
||||
pm->drain_stacks(false);
|
||||
|
||||
@ -81,11 +81,10 @@ class ScavengeRootsTask : public GCTask {
|
||||
|
||||
class ThreadRootsTask : public GCTask {
|
||||
private:
|
||||
JavaThread* _java_thread;
|
||||
VMThread* _vm_thread;
|
||||
Thread* _thread;
|
||||
|
||||
public:
|
||||
ThreadRootsTask(JavaThread* root) : _java_thread(root), _vm_thread(NULL) {}
|
||||
ThreadRootsTask(VMThread* root) : _java_thread(NULL), _vm_thread(root) {}
|
||||
ThreadRootsTask(Thread* root) : _thread(root) {}
|
||||
|
||||
char* name() { return (char *)"thread-roots-task"; }
|
||||
|
||||
|
||||
@ -114,9 +114,6 @@
|
||||
#include "utilities/macros.hpp"
|
||||
#include "utilities/preserveException.hpp"
|
||||
#include "utilities/vmError.hpp"
|
||||
#if INCLUDE_PARALLELGC
|
||||
#include "gc/parallel/pcTasks.hpp"
|
||||
#endif
|
||||
#if INCLUDE_JVMCI
|
||||
#include "jvmci/jvmciCompiler.hpp"
|
||||
#include "jvmci/jvmciRuntime.hpp"
|
||||
@ -3436,13 +3433,25 @@ void Threads::non_java_threads_do(ThreadClosure* tc) {
|
||||
// If CompilerThreads ever become non-JavaThreads, add them here
|
||||
}
|
||||
|
||||
// All JavaThreads + all non-JavaThreads (i.e., every thread in the system).
|
||||
void Threads::threads_do(ThreadClosure* tc) {
|
||||
// All JavaThreads
|
||||
void Threads::java_threads_do(ThreadClosure* tc) {
|
||||
assert_locked_or_safepoint(Threads_lock);
|
||||
// ALL_JAVA_THREADS iterates through all JavaThreads.
|
||||
ALL_JAVA_THREADS(p) {
|
||||
tc->do_thread(p);
|
||||
}
|
||||
}
|
||||
|
||||
void Threads::java_threads_and_vm_thread_do(ThreadClosure* tc) {
|
||||
assert_locked_or_safepoint(Threads_lock);
|
||||
java_threads_do(tc);
|
||||
tc->do_thread(VMThread::vm_thread());
|
||||
}
|
||||
|
||||
// All JavaThreads + all non-JavaThreads (i.e., every thread in the system).
|
||||
void Threads::threads_do(ThreadClosure* tc) {
|
||||
assert_locked_or_safepoint(Threads_lock);
|
||||
java_threads_do(tc);
|
||||
non_java_threads_do(tc);
|
||||
}
|
||||
|
||||
@ -4465,24 +4474,6 @@ void Threads::possibly_parallel_oops_do(bool is_par, OopClosure* f, CodeBlobClos
|
||||
possibly_parallel_threads_do(is_par, &tc);
|
||||
}
|
||||
|
||||
#if INCLUDE_PARALLELGC
|
||||
// Used by ParallelScavenge
|
||||
void Threads::create_thread_roots_tasks(GCTaskQueue* q) {
|
||||
ALL_JAVA_THREADS(p) {
|
||||
q->enqueue(new ThreadRootsTask(p));
|
||||
}
|
||||
q->enqueue(new ThreadRootsTask(VMThread::vm_thread()));
|
||||
}
|
||||
|
||||
// Used by Parallel Old
|
||||
void Threads::create_thread_roots_marking_tasks(GCTaskQueue* q) {
|
||||
ALL_JAVA_THREADS(p) {
|
||||
q->enqueue(new ThreadRootsMarkingTask(p));
|
||||
}
|
||||
q->enqueue(new ThreadRootsMarkingTask(VMThread::vm_thread()));
|
||||
}
|
||||
#endif // INCLUDE_PARALLELGC
|
||||
|
||||
void Threads::nmethods_do(CodeBlobClosure* cf) {
|
||||
ALL_JAVA_THREADS(p) {
|
||||
// This is used by the code cache sweeper to mark nmethods that are active
|
||||
|
||||
@ -2104,6 +2104,8 @@ class Threads: AllStatic {
|
||||
static void add(JavaThread* p, bool force_daemon = false);
|
||||
static void remove(JavaThread* p);
|
||||
static void non_java_threads_do(ThreadClosure* tc);
|
||||
static void java_threads_do(ThreadClosure* tc);
|
||||
static void java_threads_and_vm_thread_do(ThreadClosure* tc);
|
||||
static void threads_do(ThreadClosure* tc);
|
||||
static void possibly_parallel_threads_do(bool is_par, ThreadClosure* tc);
|
||||
|
||||
@ -2142,10 +2144,6 @@ class Threads: AllStatic {
|
||||
static void oops_do(OopClosure* f, CodeBlobClosure* cf);
|
||||
// This version may be called by sequential or parallel code.
|
||||
static void possibly_parallel_oops_do(bool is_par, OopClosure* f, CodeBlobClosure* cf);
|
||||
// This creates a list of GCTasks, one per thread.
|
||||
static void create_thread_roots_tasks(GCTaskQueue* q);
|
||||
// This creates a list of GCTasks, one per thread, for marking objects.
|
||||
static void create_thread_roots_marking_tasks(GCTaskQueue* q);
|
||||
|
||||
// Apply "f->do_oop" to roots in all threads that
|
||||
// are part of compiled frames
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user