Skip to content

Commit a52a08d

Browse files
committed
8267916: Adopt cast notation for CompilerThread conversions
Reviewed-by: kbarrett, iklam, dholmes
1 parent 9bf347b commit a52a08d

File tree

6 files changed

+13
-15
lines changed

6 files changed

+13
-15
lines changed

src/hotspot/share/compiler/compileBroker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ JavaThread* CompileBroker::make_thread(ThreadType type, jobject thread_handle, C
939939

940940
new_thread->set_threadObj(JNIHandles::resolve_non_null(thread_handle));
941941
if (type == compiler_t) {
942-
new_thread->as_CompilerThread()->set_compiler(comp);
942+
CompilerThread::cast(new_thread)->set_compiler(comp);
943943
}
944944
Threads::add(new_thread);
945945
Thread::start(new_thread);

src/hotspot/share/compiler/compileBroker.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "compiler/abstractCompiler.hpp"
3030
#include "compiler/compileTask.hpp"
3131
#include "compiler/compilerDirectives.hpp"
32+
#include "compiler/compilerThread.hpp"
3233
#include "runtime/atomic.hpp"
3334
#include "runtime/perfDataTypes.hpp"
3435
#include "utilities/stack.hpp"

src/hotspot/share/compiler/compilerThread.hpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,14 @@ class CompilerThread : public JavaThread {
5656

5757
public:
5858

59-
static CompilerThread* current();
59+
static CompilerThread* current() {
60+
return CompilerThread::cast(JavaThread::current());
61+
}
62+
63+
static CompilerThread* cast(Thread* t) {
64+
assert(t->is_Compiler_thread(), "incorrect cast to CompilerThread");
65+
return static_cast<CompilerThread*>(t);
66+
}
6067

6168
CompilerThread(CompileQueue* queue, CompilerCounters* counters);
6269
~CompilerThread();
@@ -109,15 +116,6 @@ class CompilerThread : public JavaThread {
109116
static void thread_entry(JavaThread* thread, TRAPS);
110117
};
111118

112-
inline CompilerThread* JavaThread::as_CompilerThread() {
113-
assert(is_Compiler_thread(), "just checking");
114-
return (CompilerThread*)this;
115-
}
116-
117-
inline CompilerThread* CompilerThread::current() {
118-
return JavaThread::current()->as_CompilerThread();
119-
}
120-
121119
// Dedicated thread to sweep the code cache
122120
class CodeCacheSweeperThread : public JavaThread {
123121
CompiledMethod* _scanned_compiled_method; // nmethod being scanned by the sweeper

src/hotspot/share/jvmci/jvmci.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void JVMCI::ensure_box_caches_initialized(TRAPS) {
156156

157157
JavaThread* JVMCI::compilation_tick(JavaThread* thread) {
158158
if (thread->is_Compiler_thread()) {
159-
CompileTask *task = thread->as_CompilerThread()->task();
159+
CompileTask *task = CompilerThread::cast(thread)->task();
160160
if (task != NULL) {
161161
JVMCICompileState *state = task->blocking_jvmci_compile_state();
162162
if (state != NULL) {

src/hotspot/share/jvmci/jvmciCodeInstaller.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "classfile/javaClasses.inline.hpp"
2626
#include "code/compiledIC.hpp"
2727
#include "compiler/compileBroker.hpp"
28+
#include "compiler/compilerThread.hpp"
2829
#include "compiler/oopMap.hpp"
2930
#include "jvmci/jvmciCodeInstaller.hpp"
3031
#include "jvmci/jvmciCompilerToVM.hpp"
@@ -436,7 +437,7 @@ MonitorValue* CodeInstaller::get_monitor_value(JVMCIObject value, GrowableArray<
436437

437438
void CodeInstaller::initialize_dependencies(JVMCIObject compiled_code, OopRecorder* oop_recorder, JVMCI_TRAPS) {
438439
JavaThread* thread = JavaThread::current();
439-
CompilerThread* compilerThread = thread->is_Compiler_thread() ? thread->as_CompilerThread() : NULL;
440+
CompilerThread* compilerThread = thread->is_Compiler_thread() ? CompilerThread::cast(thread) : NULL;
440441
_oop_recorder = oop_recorder;
441442
_dependencies = new Dependencies(&_arena, _oop_recorder, compilerThread != NULL ? compilerThread->log() : NULL);
442443
JVMCIObjectArray assumptions = jvmci_env()->get_HotSpotCompiledCode_assumptions(compiled_code);

src/hotspot/share/runtime/thread.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,8 +1429,6 @@ class JavaThread: public Thread {
14291429
// operation. You may not want that either.
14301430
static JavaThread* active();
14311431

1432-
inline CompilerThread* as_CompilerThread();
1433-
14341432
protected:
14351433
virtual void pre_run();
14361434
virtual void run();

0 commit comments

Comments
 (0)