Skip to content

Commit 08ee7ae

Browse files
author
David Holmes
committed
8268855: Cleanup name handling in the Thread class and subclasses
Reviewed-by: lfoltan, coleenp
1 parent c79034e commit 08ee7ae

File tree

16 files changed

+71
-51
lines changed

16 files changed

+71
-51
lines changed

src/hotspot/cpu/aarch64/gc/shared/barrierSetNMethod_aarch64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void BarrierSetNMethod::deoptimize(nmethod* nm, address* return_address_ptr) {
116116
log_trace(nmethod, barrier)("deoptimize(nmethod: %s(%p), return_addr: %p, osr: %d, thread: %p(%s), making rsp: %p) -> %p",
117117
nm->method()->name_and_sig_as_C_string(),
118118
nm, *(address *) return_address_ptr, nm->is_osr_method(), thread,
119-
thread->get_thread_name(), frame.sp(), nm->verified_entry_point());
119+
thread->name(), frame.sp(), nm->verified_entry_point());
120120
}
121121

122122
new_frame->sp = frame.sp();

src/hotspot/cpu/x86/gc/shared/barrierSetNMethod_x86.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -132,7 +132,7 @@ void BarrierSetNMethod::deoptimize(nmethod* nm, address* return_address_ptr) {
132132
ResourceMark mark;
133133
log_trace(nmethod, barrier)("deoptimize(nmethod: %p, return_addr: %p, osr: %d, thread: %p(%s), making rsp: %p) -> %p",
134134
nm, (address *) return_address_ptr, nm->is_osr_method(), jth,
135-
jth->get_thread_name(), callers_rsp, nm->verified_entry_point());
135+
jth->name(), callers_rsp, nm->verified_entry_point());
136136
}
137137

138138
assert(nm->frame_size() >= 3, "invariant");

src/hotspot/share/compiler/compileBroker.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,9 +1008,9 @@ void CompileBroker::init_compiler_sweeper_threads() {
10081008
_compilers[1]->set_num_compiler_threads(i + 1);
10091009
if (TraceCompilerThreads) {
10101010
ResourceMark rm;
1011-
ThreadsListHandle tlh; // get_thread_name() depends on the TLH.
1011+
ThreadsListHandle tlh; // name() depends on the TLH.
10121012
assert(tlh.includes(ct), "ct=" INTPTR_FORMAT " exited unexpectedly.", p2i(ct));
1013-
tty->print_cr("Added initial compiler thread %s", ct->get_thread_name());
1013+
tty->print_cr("Added initial compiler thread %s", ct->name());
10141014
}
10151015
}
10161016
}
@@ -1029,9 +1029,9 @@ void CompileBroker::init_compiler_sweeper_threads() {
10291029
_compilers[0]->set_num_compiler_threads(i + 1);
10301030
if (TraceCompilerThreads) {
10311031
ResourceMark rm;
1032-
ThreadsListHandle tlh; // get_thread_name() depends on the TLH.
1032+
ThreadsListHandle tlh; // name() depends on the TLH.
10331033
assert(tlh.includes(ct), "ct=" INTPTR_FORMAT " exited unexpectedly.", p2i(ct));
1034-
tty->print_cr("Added initial compiler thread %s", ct->get_thread_name());
1034+
tty->print_cr("Added initial compiler thread %s", ct->name());
10351035
}
10361036
}
10371037
}
@@ -1116,10 +1116,10 @@ void CompileBroker::possibly_add_compiler_threads(JavaThread* THREAD) {
11161116
_compilers[1]->set_num_compiler_threads(i + 1);
11171117
if (TraceCompilerThreads) {
11181118
ResourceMark rm;
1119-
ThreadsListHandle tlh; // get_thread_name() depends on the TLH.
1119+
ThreadsListHandle tlh; // name() depends on the TLH.
11201120
assert(tlh.includes(ct), "ct=" INTPTR_FORMAT " exited unexpectedly.", p2i(ct));
11211121
tty->print_cr("Added compiler thread %s (available memory: %dMB, available non-profiled code cache: %dMB)",
1122-
ct->get_thread_name(), (int)(available_memory/M), (int)(available_cc_np/M));
1122+
ct->name(), (int)(available_memory/M), (int)(available_cc_np/M));
11231123
}
11241124
}
11251125
}
@@ -1137,10 +1137,10 @@ void CompileBroker::possibly_add_compiler_threads(JavaThread* THREAD) {
11371137
_compilers[0]->set_num_compiler_threads(i + 1);
11381138
if (TraceCompilerThreads) {
11391139
ResourceMark rm;
1140-
ThreadsListHandle tlh; // get_thread_name() depends on the TLH.
1140+
ThreadsListHandle tlh; // name() depends on the TLH.
11411141
assert(tlh.includes(ct), "ct=" INTPTR_FORMAT " exited unexpectedly.", p2i(ct));
11421142
tty->print_cr("Added compiler thread %s (available memory: %dMB, available profiled code cache: %dMB)",
1143-
ct->get_thread_name(), (int)(available_memory/M), (int)(available_cc_p/M));
1143+
ct->name(), (int)(available_memory/M), (int)(available_cc_p/M));
11441144
}
11451145
}
11461146
}

src/hotspot/share/gc/shared/concurrentGCThread.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ class ConcurrentGCThread: public NamedThread {
4949

5050
bool should_terminate() const;
5151
bool has_terminated() const;
52+
53+
// Printing
54+
const char* type_name() const { return "ConcurrentGCThread"; }
5255
};
5356

5457
#endif // SHARE_GC_SHARED_CONCURRENTGCTHREAD_HPP

src/hotspot/share/gc/shared/workgroup.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ class GangWorker: public WorkerThread {
219219
// Predicate for Thread
220220
bool is_GC_task_thread() const override { return gang()->are_GC_task_threads(); }
221221
bool is_ConcurrentGC_thread() const override { return gang()->are_ConcurrentGC_threads(); }
222+
223+
// Printing
224+
const char* type_name() const override { return "GCTaskThread"; }
222225
};
223226

224227
// A class that acts as a synchronisation barrier. Workers enter

src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class ShenandoahControlThread: public ConcurrentGCThread {
143143
void prepare_for_graceful_shutdown();
144144
bool in_graceful_shutdown();
145145

146-
char* name() const { return (char*)"ShenandoahControlThread";}
146+
const char* name() const { return "ShenandoahControlThread";}
147147

148148
// Printing
149149
void print_on(outputStream* st) const;

src/hotspot/share/jfr/periodic/sampling/jfrThreadSampler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@ class JfrThreadSampler : public NonJavaThread {
343343
protected:
344344
virtual void post_run();
345345
public:
346-
virtual char* name() const { return (char*)"JFR Thread Sampler"; }
346+
virtual const char* name() const { return "JFR Thread Sampler"; }
347+
virtual const char* type_name() const { return "JfrThreadSampler"; }
347348
bool is_JfrSampler_thread() const { return true; }
348349
void run();
349350
static Monitor* transition_block() { return JfrThreadSampler_lock; }

src/hotspot/share/jvmci/jvmciCompilerToVM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2279,7 +2279,7 @@ C2V_VMENTRY_PREFIX(jboolean, attachCurrentThread, (JNIEnv* env, jobject c2vm, jb
22792279

22802280
JavaVMAttachArgs attach_args;
22812281
attach_args.version = JNI_VERSION_1_2;
2282-
attach_args.name = thread->name();
2282+
attach_args.name = const_cast<char*>(thread->name());
22832283
attach_args.group = NULL;
22842284
JNIEnv* peerJNIEnv;
22852285
if (runtime->GetEnv(thread, (void**) &peerJNIEnv, JNI_VERSION_1_2) == JNI_OK) {

src/hotspot/share/jvmci/jvmciEnv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void JVMCIEnv::init_env_mode_runtime(JavaThread* thread, JNIEnv* parent_env) {
205205
ResourceMark rm; // Thread name is resource allocated
206206
JavaVMAttachArgs attach_args;
207207
attach_args.version = JNI_VERSION_1_2;
208-
attach_args.name = thread->name();
208+
attach_args.name = const_cast<char*>(thread->name());
209209
attach_args.group = NULL;
210210
if (_runtime->AttachCurrentThread(thread, (void**) &_env, &attach_args) != JNI_OK) {
211211
fatal("Error attaching current thread (%s) to JVMCI shared library JNI interface", attach_args.name);

src/hotspot/share/logging/logAsyncWriter.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ class AsyncLogWriter : public NonJavaThread {
160160
NonJavaThread::pre_run();
161161
log_debug(logging, thread)("starting AsyncLog Thread tid = " INTX_FORMAT, os::current_thread_id());
162162
}
163-
char* name() const override { return (char*)"AsyncLog Thread"; }
163+
const char* name() const override { return "AsyncLog Thread"; }
164+
const char* type_name() const override { return "AsyncLogWriter"; }
164165
void print_on(outputStream* st) const override {
165166
st->print("\"%s\" ", name());
166167
Thread::print_on(st);

0 commit comments

Comments
 (0)