Skip to content

Commit 58bdabc

Browse files
committedJun 7, 2021
8268164: Adopt cast notation for WorkerThread conversions
Reviewed-by: stefank, dholmes
1 parent 9fc914b commit 58bdabc

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed
 

‎src/hotspot/share/gc/shared/referenceProcessor.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#include "oops/oop.inline.hpp"
4141
#include "runtime/java.hpp"
4242
#include "runtime/nonJavaThread.hpp"
43-
#include "runtime/thread.inline.hpp"
4443

4544
ReferencePolicy* ReferenceProcessor::_always_clear_soft_ref_policy = NULL;
4645
ReferencePolicy* ReferenceProcessor::_default_soft_ref_policy = NULL;
@@ -929,8 +928,7 @@ inline DiscoveredList* ReferenceProcessor::get_discovered_list(ReferenceType rt)
929928
if (_discovery_is_mt) {
930929
// During a multi-threaded discovery phase,
931930
// each thread saves to its "own" list.
932-
Thread* thr = Thread::current();
933-
id = thr->as_Worker_thread()->id();
931+
id = WorkerThread::current()->id();
934932
} else {
935933
// single-threaded discovery, we save in round-robin
936934
// fashion to each of the lists.

‎src/hotspot/share/runtime/nonJavaThread.hpp

+9
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ class WorkerThread: public NamedThread {
103103
private:
104104
uint _id;
105105
public:
106+
static WorkerThread* current() {
107+
return WorkerThread::cast(Thread::current());
108+
}
109+
110+
static WorkerThread* cast(Thread* t) {
111+
assert(t->is_Worker_thread(), "incorrect cast to WorkerThread");
112+
return static_cast<WorkerThread*>(t);
113+
}
114+
106115
WorkerThread() : _id(0) { }
107116
virtual bool is_Worker_thread() const { return true; }
108117

‎src/hotspot/share/runtime/thread.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ class Thread: public ThreadShadow {
356356
virtual bool is_active_Java_thread() const { return false; }
357357

358358
// Casts
359-
inline const WorkerThread* as_Worker_thread() const;
360359
inline JavaThread* as_Java_thread();
361360
inline const JavaThread* as_Java_thread() const;
362361

‎src/hotspot/share/runtime/thread.inline.hpp

-5
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ inline void Thread::set_threads_hazard_ptr(ThreadsList* new_list) {
6666
Atomic::release_store_fence(&_threads_hazard_ptr, new_list);
6767
}
6868

69-
inline const WorkerThread* Thread::as_Worker_thread() const {
70-
assert(is_Worker_thread(), "incorrect cast to const WorkerThread");
71-
return static_cast<const WorkerThread*>(this);
72-
}
73-
7469
#if defined(__APPLE__) && defined(AARCH64)
7570
inline void Thread::init_wx() {
7671
assert(this == Thread::current(), "should only be called for current thread");

0 commit comments

Comments
 (0)
Please sign in to comment.