8267916: Adopt cast notation for CompilerThread conversions

Reviewed-by: kbarrett, iklam, dholmes
This commit is contained in:
Albert Mingkun Yang 2021-06-03 08:21:39 +00:00
parent 9bf347bc1f
commit a52a08d20b
6 changed files with 13 additions and 15 deletions

View file

@ -939,7 +939,7 @@ JavaThread* CompileBroker::make_thread(ThreadType type, jobject thread_handle, C
new_thread->set_threadObj(JNIHandles::resolve_non_null(thread_handle)); new_thread->set_threadObj(JNIHandles::resolve_non_null(thread_handle));
if (type == compiler_t) { if (type == compiler_t) {
new_thread->as_CompilerThread()->set_compiler(comp); CompilerThread::cast(new_thread)->set_compiler(comp);
} }
Threads::add(new_thread); Threads::add(new_thread);
Thread::start(new_thread); Thread::start(new_thread);

View file

@ -29,6 +29,7 @@
#include "compiler/abstractCompiler.hpp" #include "compiler/abstractCompiler.hpp"
#include "compiler/compileTask.hpp" #include "compiler/compileTask.hpp"
#include "compiler/compilerDirectives.hpp" #include "compiler/compilerDirectives.hpp"
#include "compiler/compilerThread.hpp"
#include "runtime/atomic.hpp" #include "runtime/atomic.hpp"
#include "runtime/perfDataTypes.hpp" #include "runtime/perfDataTypes.hpp"
#include "utilities/stack.hpp" #include "utilities/stack.hpp"

View file

@ -56,7 +56,14 @@ class CompilerThread : public JavaThread {
public: public:
static CompilerThread* current(); static CompilerThread* current() {
return CompilerThread::cast(JavaThread::current());
}
static CompilerThread* cast(Thread* t) {
assert(t->is_Compiler_thread(), "incorrect cast to CompilerThread");
return static_cast<CompilerThread*>(t);
}
CompilerThread(CompileQueue* queue, CompilerCounters* counters); CompilerThread(CompileQueue* queue, CompilerCounters* counters);
~CompilerThread(); ~CompilerThread();
@ -109,15 +116,6 @@ class CompilerThread : public JavaThread {
static void thread_entry(JavaThread* thread, TRAPS); static void thread_entry(JavaThread* thread, TRAPS);
}; };
inline CompilerThread* JavaThread::as_CompilerThread() {
assert(is_Compiler_thread(), "just checking");
return (CompilerThread*)this;
}
inline CompilerThread* CompilerThread::current() {
return JavaThread::current()->as_CompilerThread();
}
// Dedicated thread to sweep the code cache // Dedicated thread to sweep the code cache
class CodeCacheSweeperThread : public JavaThread { class CodeCacheSweeperThread : public JavaThread {
CompiledMethod* _scanned_compiled_method; // nmethod being scanned by the sweeper CompiledMethod* _scanned_compiled_method; // nmethod being scanned by the sweeper

View file

@ -156,7 +156,7 @@ void JVMCI::ensure_box_caches_initialized(TRAPS) {
JavaThread* JVMCI::compilation_tick(JavaThread* thread) { JavaThread* JVMCI::compilation_tick(JavaThread* thread) {
if (thread->is_Compiler_thread()) { if (thread->is_Compiler_thread()) {
CompileTask *task = thread->as_CompilerThread()->task(); CompileTask *task = CompilerThread::cast(thread)->task();
if (task != NULL) { if (task != NULL) {
JVMCICompileState *state = task->blocking_jvmci_compile_state(); JVMCICompileState *state = task->blocking_jvmci_compile_state();
if (state != NULL) { if (state != NULL) {

View file

@ -25,6 +25,7 @@
#include "classfile/javaClasses.inline.hpp" #include "classfile/javaClasses.inline.hpp"
#include "code/compiledIC.hpp" #include "code/compiledIC.hpp"
#include "compiler/compileBroker.hpp" #include "compiler/compileBroker.hpp"
#include "compiler/compilerThread.hpp"
#include "compiler/oopMap.hpp" #include "compiler/oopMap.hpp"
#include "jvmci/jvmciCodeInstaller.hpp" #include "jvmci/jvmciCodeInstaller.hpp"
#include "jvmci/jvmciCompilerToVM.hpp" #include "jvmci/jvmciCompilerToVM.hpp"
@ -436,7 +437,7 @@ MonitorValue* CodeInstaller::get_monitor_value(JVMCIObject value, GrowableArray<
void CodeInstaller::initialize_dependencies(JVMCIObject compiled_code, OopRecorder* oop_recorder, JVMCI_TRAPS) { void CodeInstaller::initialize_dependencies(JVMCIObject compiled_code, OopRecorder* oop_recorder, JVMCI_TRAPS) {
JavaThread* thread = JavaThread::current(); JavaThread* thread = JavaThread::current();
CompilerThread* compilerThread = thread->is_Compiler_thread() ? thread->as_CompilerThread() : NULL; CompilerThread* compilerThread = thread->is_Compiler_thread() ? CompilerThread::cast(thread) : NULL;
_oop_recorder = oop_recorder; _oop_recorder = oop_recorder;
_dependencies = new Dependencies(&_arena, _oop_recorder, compilerThread != NULL ? compilerThread->log() : NULL); _dependencies = new Dependencies(&_arena, _oop_recorder, compilerThread != NULL ? compilerThread->log() : NULL);
JVMCIObjectArray assumptions = jvmci_env()->get_HotSpotCompiledCode_assumptions(compiled_code); JVMCIObjectArray assumptions = jvmci_env()->get_HotSpotCompiledCode_assumptions(compiled_code);

View file

@ -1429,8 +1429,6 @@ class JavaThread: public Thread {
// operation. You may not want that either. // operation. You may not want that either.
static JavaThread* active(); static JavaThread* active();
inline CompilerThread* as_CompilerThread();
protected: protected:
virtual void pre_run(); virtual void pre_run();
virtual void run(); virtual void run();