Re: RFR: 8241403: JavaThread::get_thread_name() should be ThreadSMR-aware

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8241403: JavaThread::get_thread_name() should be ThreadSMR-aware

Daniel D.Daugherty
On Fri, 12 Feb 2021 07:36:06 GMT, Robbin Ehn <[hidden email]> wrote:

>> A minor fix to add a new function:
>>
>>     bool Thread::is_JavaThread_protected(const JavaThread* p)
>>
>> that returns true when the target JavaThread* is protected and false
>> otherwise. Update JavaThread::get_thread_name() to create a
>> ThreadsListHandle and use the new is_JavaThread_protected(). Also
>> update JvmtiTrace::safe_get_thread_name() to use the new
>> is_JavaThread_protected().
>>
>> This fix is tested via a Mach5 Tier[1-8] run.
>
> Seems alright.

@robehn - Thanks for the review!

-------------

PR: https://git.openjdk.java.net/jdk/pull/2535
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8241403: JavaThread::get_thread_name() should be ThreadSMR-aware

Daniel D.Daugherty
On Sat, 13 Feb 2021 15:24:33 GMT, Coleen Phillimore <[hidden email]> wrote:

>> The name "default" is reserved so I went with "def_name".
>> You can't call Thread::name() from the declaration:
>> ./open/src/hotspot/share/runtime/thread.hpp:1690:62: error: call to non-static member function without an object argument
>>   const char* get_thread_name(const char* def_name = Thread::name()) const;
>>                                                      ~~~~~~~~^~~~
>> so I went with setting `def_name = NULL` in the declaration and decoding that state in get_thread_name():
>> ` return (def_name != NULL) ? def_name : Thread::name();`
>
> default_name, it's not long enough to abbreviate...  but yes. thanks!

And it looks like making is_JavaThread_protected() a protected function doesn't work either since `JavaThread::get_thread_name()` can't call it:

./open/src/hotspot/share/runtime/thread.cpp:2857:15: error: 'is_JavaThread_protected' is a protected member of 'Thread'
  if (thread->is_JavaThread_protected(this)) {
              ^
./open/src/hotspot/share/runtime/thread.cpp:488:14: note: can only access this member on an object of type 'JavaThread'
bool Thread::is_JavaThread_protected(const JavaThread* p) {
             ^
1 error generated.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2535