8268164: Adopt cast notation for WorkerThread conversions

Reviewed-by: stefank, dholmes
This commit is contained in:
Albert Mingkun Yang 2021-06-07 08:20:39 +00:00
parent 9fc914b963
commit 58bdabcd40
4 changed files with 10 additions and 9 deletions

@ -40,7 +40,6 @@
#include "oops/oop.inline.hpp"
#include "runtime/java.hpp"
#include "runtime/nonJavaThread.hpp"
#include "runtime/thread.inline.hpp"
ReferencePolicy* ReferenceProcessor::_always_clear_soft_ref_policy = NULL;
ReferencePolicy* ReferenceProcessor::_default_soft_ref_policy = NULL;
@ -929,8 +928,7 @@ inline DiscoveredList* ReferenceProcessor::get_discovered_list(ReferenceType rt)
if (_discovery_is_mt) {
// During a multi-threaded discovery phase,
// each thread saves to its "own" list.
Thread* thr = Thread::current();
id = thr->as_Worker_thread()->id();
id = WorkerThread::current()->id();
} else {
// single-threaded discovery, we save in round-robin
// fashion to each of the lists.

@ -103,6 +103,15 @@ class WorkerThread: public NamedThread {
private:
uint _id;
public:
static WorkerThread* current() {
return WorkerThread::cast(Thread::current());
}
static WorkerThread* cast(Thread* t) {
assert(t->is_Worker_thread(), "incorrect cast to WorkerThread");
return static_cast<WorkerThread*>(t);
}
WorkerThread() : _id(0) { }
virtual bool is_Worker_thread() const { return true; }

@ -356,7 +356,6 @@ class Thread: public ThreadShadow {
virtual bool is_active_Java_thread() const { return false; }
// Casts
inline const WorkerThread* as_Worker_thread() const;
inline JavaThread* as_Java_thread();
inline const JavaThread* as_Java_thread() const;

@ -66,11 +66,6 @@ inline void Thread::set_threads_hazard_ptr(ThreadsList* new_list) {
Atomic::release_store_fence(&_threads_hazard_ptr, new_list);
}
inline const WorkerThread* Thread::as_Worker_thread() const {
assert(is_Worker_thread(), "incorrect cast to const WorkerThread");
return static_cast<const WorkerThread*>(this);
}
#if defined(__APPLE__) && defined(AARCH64)
inline void Thread::init_wx() {
assert(this == Thread::current(), "should only be called for current thread");