8234796: Refactor Handshake::execute to take a more complex type than ThreadClosure

Reviewed-by: dholmes, pliden, coleenp
This commit is contained in:
Robbin Ehn 2019-12-03 15:32:41 +01:00
parent 095d77acf0
commit 21e03e71aa
36 changed files with 95 additions and 50 deletions

View file

@ -55,6 +55,7 @@
#include "include/jvm.h" #include "include/jvm.h"
#include "logging/log.hpp" #include "logging/log.hpp"
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "memory/iterator.hpp"
#include "memory/resourceArea.hpp" #include "memory/resourceArea.hpp"
#include "memory/universe.hpp" #include "memory/universe.hpp"
#include "oops/access.inline.hpp" #include "oops/access.inline.hpp"

View file

@ -45,6 +45,7 @@ class G1ConcurrentMark;
class G1OldTracer; class G1OldTracer;
class G1RegionToSpaceMapper; class G1RegionToSpaceMapper;
class G1SurvivorRegions; class G1SurvivorRegions;
class ThreadClosure;
PRAGMA_DIAG_PUSH PRAGMA_DIAG_PUSH
// warning C4522: multiple assignment operators specified // warning C4522: multiple assignment operators specified

View file

@ -29,6 +29,7 @@
#include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1DirtyCardQueue.hpp"
#include "logging/log.hpp" #include "logging/log.hpp"
#include "memory/allocation.inline.hpp" #include "memory/allocation.inline.hpp"
#include "memory/iterator.hpp"
#include "runtime/java.hpp" #include "runtime/java.hpp"
#include "runtime/thread.hpp" #include "runtime/thread.hpp"
#include "utilities/debug.hpp" #include "utilities/debug.hpp"

View file

@ -34,6 +34,7 @@
#include "gc/g1/heapRegionRemSet.hpp" #include "gc/g1/heapRegionRemSet.hpp"
#include "gc/shared/suspendibleThreadSet.hpp" #include "gc/shared/suspendibleThreadSet.hpp"
#include "gc/shared/workgroup.hpp" #include "gc/shared/workgroup.hpp"
#include "memory/iterator.hpp"
#include "runtime/flags/flagSetting.hpp" #include "runtime/flags/flagSetting.hpp"
#include "runtime/mutexLocker.hpp" #include "runtime/mutexLocker.hpp"
#include "runtime/orderAccess.hpp" #include "runtime/orderAccess.hpp"

View file

@ -34,6 +34,7 @@
#include "gc/g1/heapRegion.hpp" #include "gc/g1/heapRegion.hpp"
#include "gc/g1/heapRegionRemSet.hpp" #include "gc/g1/heapRegionRemSet.hpp"
#include "memory/allocation.inline.hpp" #include "memory/allocation.inline.hpp"
#include "memory/iterator.hpp"
#include "runtime/thread.inline.hpp" #include "runtime/thread.inline.hpp"
void G1RemSetSummary::update() { void G1RemSetSummary::update() {

View file

@ -44,6 +44,7 @@
#include "gc/shared/locationPrinter.inline.hpp" #include "gc/shared/locationPrinter.inline.hpp"
#include "gc/shared/scavengableNMethods.hpp" #include "gc/shared/scavengableNMethods.hpp"
#include "logging/log.hpp" #include "logging/log.hpp"
#include "memory/iterator.hpp"
#include "memory/metaspaceCounters.hpp" #include "memory/metaspaceCounters.hpp"
#include "memory/universe.hpp" #include "memory/universe.hpp"
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"

View file

@ -52,6 +52,7 @@
#include "gc/shared/weakProcessor.hpp" #include "gc/shared/weakProcessor.hpp"
#include "gc/shared/workerPolicy.hpp" #include "gc/shared/workerPolicy.hpp"
#include "gc/shared/workgroup.hpp" #include "gc/shared/workgroup.hpp"
#include "memory/iterator.hpp"
#include "memory/resourceArea.hpp" #include "memory/resourceArea.hpp"
#include "memory/universe.hpp" #include "memory/universe.hpp"
#include "logging/log.hpp" #include "logging/log.hpp"

View file

@ -55,6 +55,7 @@
#include "gc/shared/weakProcessor.hpp" #include "gc/shared/weakProcessor.hpp"
#include "gc/shared/workgroup.hpp" #include "gc/shared/workgroup.hpp"
#include "memory/filemap.hpp" #include "memory/filemap.hpp"
#include "memory/iterator.hpp"
#include "memory/metaspaceCounters.hpp" #include "memory/metaspaceCounters.hpp"
#include "memory/resourceArea.hpp" #include "memory/resourceArea.hpp"
#include "memory/universe.hpp" #include "memory/universe.hpp"

View file

@ -27,6 +27,7 @@
#include "gc/shared/stringdedup/stringDedupQueue.hpp" #include "gc/shared/stringdedup/stringDedupQueue.hpp"
#include "gc/shared/stringdedup/stringDedupTable.hpp" #include "gc/shared/stringdedup/stringDedupTable.hpp"
#include "gc/shared/stringdedup/stringDedupThread.hpp" #include "gc/shared/stringdedup/stringDedupThread.hpp"
#include "memory/iterator.hpp"
bool StringDedup::_enabled = false; bool StringDedup::_enabled = false;

View file

@ -69,6 +69,8 @@
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "runtime/thread.hpp" #include "runtime/thread.hpp"
class ThreadClosure;
// //
// Main interface for interacting with string deduplication. // Main interface for interacting with string deduplication.
// //

View file

@ -28,6 +28,7 @@
#include "gc/shared/workerManager.hpp" #include "gc/shared/workerManager.hpp"
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "memory/allocation.inline.hpp" #include "memory/allocation.inline.hpp"
#include "memory/iterator.hpp"
#include "runtime/atomic.hpp" #include "runtime/atomic.hpp"
#include "runtime/os.hpp" #include "runtime/os.hpp"
#include "runtime/semaphore.hpp" #include "runtime/semaphore.hpp"

View file

@ -50,6 +50,7 @@
class AbstractGangWorker; class AbstractGangWorker;
class Semaphore; class Semaphore;
class ThreadClosure;
class WorkGang; class WorkGang;
// An abstract task to be worked on by a gang. // An abstract task to be worked on by a gang.

View file

@ -158,8 +158,9 @@ void ShenandoahUnload::purge() {
CodeCache::purge_exception_caches(); CodeCache::purge_exception_caches();
} }
class ShenandoahUnloadRendezvousClosure : public ThreadClosure { class ShenandoahUnloadRendezvousClosure : public HandshakeClosure {
public: public:
ShenandoahUnloadRendezvousClosure() : HandshakeClosure("ShenandoahUnloadRendezvous") {}
void do_thread(Thread* thread) {} void do_thread(Thread* thread) {}
}; };

View file

@ -33,6 +33,7 @@
#include "gc/z/zServiceability.hpp" #include "gc/z/zServiceability.hpp"
#include "gc/z/zStat.hpp" #include "gc/z/zStat.hpp"
#include "gc/z/zUtils.inline.hpp" #include "gc/z/zUtils.inline.hpp"
#include "memory/iterator.hpp"
#include "memory/universe.hpp" #include "memory/universe.hpp"
#include "runtime/mutexLocker.hpp" #include "runtime/mutexLocker.hpp"
#include "utilities/align.hpp" #include "utilities/align.hpp"

View file

@ -326,9 +326,12 @@ void ZHeap::set_soft_reference_policy(bool clear) {
_reference_processor.set_soft_reference_policy(clear); _reference_processor.set_soft_reference_policy(clear);
} }
class ZRendezvousClosure : public ThreadClosure { class ZRendezvousClosure : public HandshakeClosure {
public: public:
virtual void do_thread(Thread* thread) {} ZRendezvousClosure() :
HandshakeClosure("ZRendezvous") {}
void do_thread(Thread* thread) {}
}; };
void ZHeap::process_non_strong_references() { void ZHeap::process_non_strong_references() {

View file

@ -39,6 +39,8 @@
#include "gc/z/zUnload.hpp" #include "gc/z/zUnload.hpp"
#include "gc/z/zWorkers.hpp" #include "gc/z/zWorkers.hpp"
class ThreadClosure;
class ZHeap { class ZHeap {
friend class VMStructs; friend class VMStructs;

View file

@ -413,13 +413,14 @@ void ZMark::idle() const {
os::naked_short_sleep(1); os::naked_short_sleep(1);
} }
class ZMarkFlushAndFreeStacksClosure : public ThreadClosure { class ZMarkFlushAndFreeStacksClosure : public HandshakeClosure {
private: private:
ZMark* const _mark; ZMark* const _mark;
bool _flushed; bool _flushed;
public: public:
ZMarkFlushAndFreeStacksClosure(ZMark* mark) : ZMarkFlushAndFreeStacksClosure(ZMark* mark) :
HandshakeClosure("ZMarkFlushAndFreeStacks"),
_mark(mark), _mark(mark),
_flushed(false) {} _flushed(false) {}

View file

@ -39,6 +39,7 @@
#include "gc/z/zRootsIterator.hpp" #include "gc/z/zRootsIterator.hpp"
#include "gc/z/zStat.hpp" #include "gc/z/zStat.hpp"
#include "gc/z/zThreadLocalData.hpp" #include "gc/z/zThreadLocalData.hpp"
#include "memory/iterator.hpp"
#include "memory/resourceArea.hpp" #include "memory/resourceArea.hpp"
#include "memory/universe.hpp" #include "memory/universe.hpp"
#include "prims/jvmtiExport.hpp" #include "prims/jvmtiExport.hpp"

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,8 @@
#include "gc/shared/workgroup.hpp" #include "gc/shared/workgroup.hpp"
class ThreadClosure;
class ZRuntimeWorkers { class ZRuntimeWorkers {
private: private:
WorkGang _workers; WorkGang _workers;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -27,6 +27,7 @@
#include "gc/shared/workgroup.hpp" #include "gc/shared/workgroup.hpp"
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
class ThreadClosure;
class ZTask; class ZTask;
class ZWorkers { class ZWorkers {

View file

@ -42,6 +42,7 @@
#include "jfr/utilities/jfrTypes.hpp" #include "jfr/utilities/jfrTypes.hpp"
#include "jfr/writers/jfrJavaEventWriter.hpp" #include "jfr/writers/jfrJavaEventWriter.hpp"
#include "logging/log.hpp" #include "logging/log.hpp"
#include "memory/iterator.hpp"
#include "memory/resourceArea.hpp" #include "memory/resourceArea.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
#include "runtime/mutex.hpp" #include "runtime/mutex.hpp"

View file

@ -40,6 +40,7 @@
#include "jfr/support/jfrThreadLocal.hpp" #include "jfr/support/jfrThreadLocal.hpp"
#include "jfr/writers/jfrJavaEventWriter.hpp" #include "jfr/writers/jfrJavaEventWriter.hpp"
#include "jfr/utilities/jfrThreadIterator.hpp" #include "jfr/utilities/jfrThreadIterator.hpp"
#include "memory/iterator.hpp"
#include "memory/metaspaceGCThresholdUpdater.hpp" #include "memory/metaspaceGCThresholdUpdater.hpp"
#include "memory/referenceType.hpp" #include "memory/referenceType.hpp"
#include "memory/universe.hpp" #include "memory/universe.hpp"

View file

@ -32,6 +32,7 @@
#include "jfr/support/jfrThreadId.hpp" #include "jfr/support/jfrThreadId.hpp"
#include "jfr/utilities/jfrTypes.hpp" #include "jfr/utilities/jfrTypes.hpp"
#include "jfr/writers/jfrJavaEventWriter.hpp" #include "jfr/writers/jfrJavaEventWriter.hpp"
#include "memory/iterator.hpp"
#include "oops/instanceKlass.hpp" #include "oops/instanceKlass.hpp"
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
#include "runtime/fieldDescriptor.inline.hpp" #include "runtime/fieldDescriptor.inline.hpp"

View file

@ -37,11 +37,18 @@ class KlassClosure;
class ClassLoaderData; class ClassLoaderData;
class Symbol; class Symbol;
class Metadata; class Metadata;
class Thread;
// The following classes are C++ `closures` for iterating over objects, roots and spaces // The following classes are C++ `closures` for iterating over objects, roots and spaces
class Closure : public StackObj { }; class Closure : public StackObj { };
// Thread iterator
class ThreadClosure: public Closure {
public:
virtual void do_thread(Thread* thread) = 0;
};
// OopClosure is used for iterating through references to Java objects. // OopClosure is used for iterating through references to Java objects.
class OopClosure : public Closure { class OopClosure : public Closure {
public: public:

View file

@ -27,6 +27,7 @@
#include "classfile/moduleEntry.hpp" #include "classfile/moduleEntry.hpp"
#include "classfile/systemDictionary.hpp" #include "classfile/systemDictionary.hpp"
#include "jvmtifiles/jvmtiEnv.hpp" #include "jvmtifiles/jvmtiEnv.hpp"
#include "memory/iterator.hpp"
#include "memory/resourceArea.hpp" #include "memory/resourceArea.hpp"
#include "oops/objArrayKlass.hpp" #include "oops/objArrayKlass.hpp"
#include "oops/objArrayOop.hpp" #include "oops/objArrayOop.hpp"

View file

@ -2011,7 +2011,7 @@ WB_END
#endif // INCLUDE_CDS #endif // INCLUDE_CDS
WB_ENTRY(jint, WB_HandshakeWalkStack(JNIEnv* env, jobject wb, jobject thread_handle, jboolean all_threads)) WB_ENTRY(jint, WB_HandshakeWalkStack(JNIEnv* env, jobject wb, jobject thread_handle, jboolean all_threads))
class TraceSelfClosure : public ThreadClosure { class TraceSelfClosure : public HandshakeClosure {
jint _num_threads_completed; jint _num_threads_completed;
void do_thread(Thread* th) { void do_thread(Thread* th) {
@ -2026,7 +2026,7 @@ WB_ENTRY(jint, WB_HandshakeWalkStack(JNIEnv* env, jobject wb, jobject thread_han
} }
public: public:
TraceSelfClosure() : _num_threads_completed(0) {} TraceSelfClosure() : HandshakeClosure("WB_TraceSelf"), _num_threads_completed(0) {}
jint num_threads_completed() const { return _num_threads_completed; } jint num_threads_completed() const { return _num_threads_completed; }
}; };

View file

@ -35,6 +35,7 @@
#include "runtime/basicLock.hpp" #include "runtime/basicLock.hpp"
#include "runtime/biasedLocking.hpp" #include "runtime/biasedLocking.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
#include "runtime/handshake.hpp"
#include "runtime/task.hpp" #include "runtime/task.hpp"
#include "runtime/threadSMR.hpp" #include "runtime/threadSMR.hpp"
#include "runtime/vframe.hpp" #include "runtime/vframe.hpp"
@ -500,7 +501,7 @@ public:
}; };
class RevokeOneBias : public ThreadClosure { class RevokeOneBias : public HandshakeClosure {
protected: protected:
Handle _obj; Handle _obj;
JavaThread* _requesting_thread; JavaThread* _requesting_thread;
@ -510,7 +511,8 @@ protected:
public: public:
RevokeOneBias(Handle obj, JavaThread* requesting_thread, JavaThread* biased_locker) RevokeOneBias(Handle obj, JavaThread* requesting_thread, JavaThread* biased_locker)
: _obj(obj) : HandshakeClosure("RevokeOneBias")
, _obj(obj)
, _requesting_thread(requesting_thread) , _requesting_thread(requesting_thread)
, _biased_locker(biased_locker) , _biased_locker(biased_locker)
, _status_code(BiasedLocking::NOT_BIASED) , _status_code(BiasedLocking::NOT_BIASED)

View file

@ -805,10 +805,10 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m
return bt; return bt;
JRT_END JRT_END
class DeoptimizeMarkedTC : public ThreadClosure { class DeoptimizeMarkedClosure : public HandshakeClosure {
public: public:
virtual void do_thread(Thread* thread) { DeoptimizeMarkedClosure() : HandshakeClosure("Deoptimize") {}
assert(thread->is_Java_thread(), "must be"); void do_thread(Thread* thread) {
JavaThread* jt = (JavaThread*)thread; JavaThread* jt = (JavaThread*)thread;
jt->deoptimize_marked_methods(); jt->deoptimize_marked_methods();
} }
@ -819,7 +819,7 @@ void Deoptimization::deoptimize_all_marked() {
DeoptimizationMarker dm; DeoptimizationMarker dm;
if (SafepointSynchronize::is_at_safepoint()) { if (SafepointSynchronize::is_at_safepoint()) {
DeoptimizeMarkedTC deopt; DeoptimizeMarkedClosure deopt;
// Make the dependent methods not entrant // Make the dependent methods not entrant
CodeCache::make_marked_nmethods_not_entrant(); CodeCache::make_marked_nmethods_not_entrant();
Threads::java_threads_do(&deopt); Threads::java_threads_do(&deopt);
@ -829,7 +829,7 @@ void Deoptimization::deoptimize_all_marked() {
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
CodeCache::make_marked_nmethods_not_entrant(); CodeCache::make_marked_nmethods_not_entrant();
} }
DeoptimizeMarkedTC deopt; DeoptimizeMarkedClosure deopt;
Handshake::execute(&deopt); Handshake::execute(&deopt);
} }
} }

View file

@ -45,10 +45,10 @@ public:
class HandshakeThreadsOperation: public HandshakeOperation { class HandshakeThreadsOperation: public HandshakeOperation {
static Semaphore _done; static Semaphore _done;
ThreadClosure* _thread_cl; HandshakeClosure* _handshake_cl;
bool _executed; bool _executed;
public: public:
HandshakeThreadsOperation(ThreadClosure* cl) : _thread_cl(cl), _executed(false) {} HandshakeThreadsOperation(HandshakeClosure* cl) : _handshake_cl(cl), _executed(false) {}
void do_handshake(JavaThread* thread); void do_handshake(JavaThread* thread);
bool thread_has_completed() { return _done.trywait(); } bool thread_has_completed() { return _done.trywait(); }
bool executed() const { return _executed; } bool executed() const { return _executed; }
@ -206,15 +206,15 @@ class VM_HandshakeAllThreads: public VM_Handshake {
}; };
class VM_HandshakeFallbackOperation : public VM_Operation { class VM_HandshakeFallbackOperation : public VM_Operation {
ThreadClosure* _thread_cl; HandshakeClosure* _handshake_cl;
Thread* _target_thread; Thread* _target_thread;
bool _all_threads; bool _all_threads;
bool _executed; bool _executed;
public: public:
VM_HandshakeFallbackOperation(ThreadClosure* cl) : VM_HandshakeFallbackOperation(HandshakeClosure* cl) :
_thread_cl(cl), _target_thread(NULL), _all_threads(true), _executed(false) {} _handshake_cl(cl), _target_thread(NULL), _all_threads(true), _executed(false) {}
VM_HandshakeFallbackOperation(ThreadClosure* cl, Thread* target) : VM_HandshakeFallbackOperation(HandshakeClosure* cl, Thread* target) :
_thread_cl(cl), _target_thread(target), _all_threads(false), _executed(false) {} _handshake_cl(cl), _target_thread(target), _all_threads(false), _executed(false) {}
void doit() { void doit() {
log_trace(handshake)("VMThread executing VM_HandshakeFallbackOperation"); log_trace(handshake)("VMThread executing VM_HandshakeFallbackOperation");
@ -223,7 +223,7 @@ public:
if (t == _target_thread) { if (t == _target_thread) {
_executed = true; _executed = true;
} }
_thread_cl->do_thread(t); _handshake_cl->do_thread(t);
} }
} }
} }
@ -240,7 +240,7 @@ void HandshakeThreadsOperation::do_handshake(JavaThread* thread) {
// Only actually execute the operation for non terminated threads. // Only actually execute the operation for non terminated threads.
if (!thread->is_terminated()) { if (!thread->is_terminated()) {
_thread_cl->do_thread(thread); _handshake_cl->do_thread(thread);
_executed = true; _executed = true;
} }
@ -248,7 +248,7 @@ void HandshakeThreadsOperation::do_handshake(JavaThread* thread) {
_done.signal(); _done.signal();
} }
void Handshake::execute(ThreadClosure* thread_cl) { void Handshake::execute(HandshakeClosure* thread_cl) {
if (ThreadLocalHandshakes) { if (ThreadLocalHandshakes) {
HandshakeThreadsOperation cto(thread_cl); HandshakeThreadsOperation cto(thread_cl);
VM_HandshakeAllThreads handshake(&cto); VM_HandshakeAllThreads handshake(&cto);
@ -259,7 +259,7 @@ void Handshake::execute(ThreadClosure* thread_cl) {
} }
} }
bool Handshake::execute(ThreadClosure* thread_cl, JavaThread* target) { bool Handshake::execute(HandshakeClosure* thread_cl, JavaThread* target) {
if (ThreadLocalHandshakes) { if (ThreadLocalHandshakes) {
HandshakeThreadsOperation cto(thread_cl); HandshakeThreadsOperation cto(thread_cl);
VM_HandshakeOneThread handshake(&cto, target); VM_HandshakeOneThread handshake(&cto, target);

View file

@ -26,22 +26,32 @@
#define SHARE_RUNTIME_HANDSHAKE_HPP #define SHARE_RUNTIME_HANDSHAKE_HPP
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "memory/iterator.hpp"
#include "runtime/flags/flagSetting.hpp" #include "runtime/flags/flagSetting.hpp"
#include "runtime/semaphore.hpp" #include "runtime/semaphore.hpp"
class ThreadClosure;
class JavaThread; class JavaThread;
// A handshake operation is a callback that is executed for each JavaThread // A handshake closure is a callback that is executed for each JavaThread
// while that thread is in a safepoint safe state. The callback is executed // while that thread is in a safepoint safe state. The callback is executed
// either by the thread itself or by the VM thread while keeping the thread // either by the thread itself or by the VM thread while keeping the thread
// in a blocked state. A handshake can be performed with a single // in a blocked state. A handshake can be performed with a single
// JavaThread as well. // JavaThread as well.
class HandshakeClosure : public ThreadClosure {
const char* const _name;
public:
HandshakeClosure(const char* name) : _name(name) {}
const char* name() const {
return _name;
}
virtual void do_thread(Thread* thread) = 0;
};
class Handshake : public AllStatic { class Handshake : public AllStatic {
public: public:
// Execution of handshake operation // Execution of handshake operation
static void execute(ThreadClosure* thread_cl); static void execute(HandshakeClosure* hs_cl);
static bool execute(ThreadClosure* thread_cl, JavaThread* target); static bool execute(HandshakeClosure* hs_cl, JavaThread* target);
}; };
class HandshakeOperation; class HandshakeOperation;

View file

@ -197,11 +197,11 @@ bool NMethodSweeper::wait_for_stack_scanning() {
return _current.end(); return _current.end();
} }
class NMethodMarkingThreadClosure : public ThreadClosure { class NMethodMarkingClosure : public HandshakeClosure {
private: private:
CodeBlobClosure* _cl; CodeBlobClosure* _cl;
public: public:
NMethodMarkingThreadClosure(CodeBlobClosure* cl) : _cl(cl) {} NMethodMarkingClosure(CodeBlobClosure* cl) : HandshakeClosure("NMethodMarking"), _cl(cl) {}
void do_thread(Thread* thread) { void do_thread(Thread* thread) {
if (thread->is_Java_thread() && ! thread->is_Code_cache_sweeper_thread()) { if (thread->is_Java_thread() && ! thread->is_Code_cache_sweeper_thread()) {
JavaThread* jt = (JavaThread*) thread; JavaThread* jt = (JavaThread*) thread;
@ -212,9 +212,9 @@ public:
class NMethodMarkingTask : public AbstractGangTask { class NMethodMarkingTask : public AbstractGangTask {
private: private:
NMethodMarkingThreadClosure* _cl; NMethodMarkingClosure* _cl;
public: public:
NMethodMarkingTask(NMethodMarkingThreadClosure* cl) : NMethodMarkingTask(NMethodMarkingClosure* cl) :
AbstractGangTask("Parallel NMethod Marking"), AbstractGangTask("Parallel NMethod Marking"),
_cl(cl) { _cl(cl) {
Threads::change_thread_claim_token(); Threads::change_thread_claim_token();
@ -239,7 +239,7 @@ void NMethodSweeper::mark_active_nmethods() {
if (cl != NULL) { if (cl != NULL) {
WorkGang* workers = Universe::heap()->get_safepoint_workers(); WorkGang* workers = Universe::heap()->get_safepoint_workers();
if (workers != NULL) { if (workers != NULL) {
NMethodMarkingThreadClosure tcl(cl); NMethodMarkingClosure tcl(cl);
NMethodMarkingTask task(&tcl); NMethodMarkingTask task(&tcl);
workers->run_task(&task); workers->run_task(&task);
} else { } else {
@ -324,8 +324,8 @@ void NMethodSweeper::do_stack_scanning() {
code_cl = prepare_mark_active_nmethods(); code_cl = prepare_mark_active_nmethods();
} }
if (code_cl != NULL) { if (code_cl != NULL) {
NMethodMarkingThreadClosure tcl(code_cl); NMethodMarkingClosure nm_cl(code_cl);
Handshake::execute(&tcl); Handshake::execute(&nm_cl);
} }
} else { } else {
VM_MarkActiveNMethods op; VM_MarkActiveNMethods op;

View file

@ -47,6 +47,7 @@
#include "logging/logConfiguration.hpp" #include "logging/logConfiguration.hpp"
#include "logging/logStream.hpp" #include "logging/logStream.hpp"
#include "memory/allocation.inline.hpp" #include "memory/allocation.inline.hpp"
#include "memory/iterator.hpp"
#include "memory/metaspaceShared.hpp" #include "memory/metaspaceShared.hpp"
#include "memory/oopFactory.hpp" #include "memory/oopFactory.hpp"
#include "memory/resourceArea.hpp" #include "memory/resourceArea.hpp"

View file

@ -2286,13 +2286,6 @@ class Threads: AllStatic {
struct Test; // For private gtest access. struct Test; // For private gtest access.
}; };
// Thread iterator
class ThreadClosure: public StackObj {
public:
virtual void do_thread(Thread* thread) = 0;
};
class SignalHandlerMark: public StackObj { class SignalHandlerMark: public StackObj {
private: private:
Thread* _thread; Thread* _thread;

View file

@ -26,6 +26,7 @@
#define SHARE_RUNTIME_THREADSMR_INLINE_HPP #define SHARE_RUNTIME_THREADSMR_INLINE_HPP
#include "runtime/atomic.hpp" #include "runtime/atomic.hpp"
#include "memory/iterator.hpp"
#include "runtime/prefetch.inline.hpp" #include "runtime/prefetch.inline.hpp"
#include "runtime/thread.inline.hpp" #include "runtime/thread.inline.hpp"
#include "runtime/threadSMR.hpp" #include "runtime/threadSMR.hpp"

View file

@ -413,9 +413,10 @@ void VMThread::evaluate_operation(VM_Operation* op) {
static VM_None safepointALot_op("SafepointALot"); static VM_None safepointALot_op("SafepointALot");
static VM_Cleanup cleanup_op; static VM_Cleanup cleanup_op;
class HandshakeALotTC : public ThreadClosure { class HandshakeALotClosure : public HandshakeClosure {
public: public:
virtual void do_thread(Thread* thread) { HandshakeALotClosure() : HandshakeClosure("HandshakeALot") {}
void do_thread(Thread* thread) {
#ifdef ASSERT #ifdef ASSERT
assert(thread->is_Java_thread(), "must be"); assert(thread->is_Java_thread(), "must be");
JavaThread* jt = (JavaThread*)thread; JavaThread* jt = (JavaThread*)thread;
@ -432,8 +433,8 @@ void VMThread::check_for_forced_cleanup() {
VM_Operation* VMThread::no_op_safepoint() { VM_Operation* VMThread::no_op_safepoint() {
// Check for handshakes first since we may need to return a VMop. // Check for handshakes first since we may need to return a VMop.
if (HandshakeALot) { if (HandshakeALot) {
HandshakeALotTC haltc; HandshakeALotClosure hal_cl;
Handshake::execute(&haltc); Handshake::execute(&hal_cl);
} }
// Check for a cleanup before SafepointALot to keep stats correct. // Check for a cleanup before SafepointALot to keep stats correct.
long interval_ms = SafepointTracing::time_since_last_safepoint_ms(); long interval_ms = SafepointTracing::time_since_last_safepoint_ms();

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,11 +23,12 @@
*/ */
#include "precompiled.hpp" #include "precompiled.hpp"
#include "utilities/globalCounter.hpp" #include "memory/iterator.hpp"
#include "runtime/atomic.hpp" #include "runtime/atomic.hpp"
#include "runtime/thread.hpp" #include "runtime/thread.hpp"
#include "runtime/threadSMR.inline.hpp" #include "runtime/threadSMR.inline.hpp"
#include "runtime/vmThread.hpp" #include "runtime/vmThread.hpp"
#include "utilities/globalCounter.hpp"
#include "utilities/spinYield.hpp" #include "utilities/spinYield.hpp"
GlobalCounter::PaddedCounter GlobalCounter::_global_counter; GlobalCounter::PaddedCounter GlobalCounter::_global_counter;