Skip to content

Commit

Permalink
8268164: Adopt cast notation for WorkerThread conversions
Browse files Browse the repository at this point in the history
Reviewed-by: stefank, dholmes
  • Loading branch information
albertnetymk committed Jun 7, 2021
1 parent 9fc914b commit 58bdabc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/hotspot/share/gc/shared/referenceProcessor.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions src/hotspot/share/runtime/nonJavaThread.hpp
Expand Up @@ -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; }

Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/runtime/thread.hpp
Expand Up @@ -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;

Expand Down
5 changes: 0 additions & 5 deletions src/hotspot/share/runtime/thread.inline.hpp
Expand Up @@ -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");
Expand Down

1 comment on commit 58bdabc

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.