RFR: 8241403: JavaThread::get_thread_name() should be ThreadSMR-aware
Coleen Phillimore
coleenp at openjdk.java.net
Fri Feb 12 22:06:40 UTC 2021
On Thu, 11 Feb 2021 22:04:53 GMT, Daniel D. Daugherty <dcubed at openjdk.org> 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.
This looks good, I have a change - could you see if you agree.
It's nice not to have to take Threads_lock to get the name of the thread.
src/hotspot/share/runtime/thread.hpp line 1692:
> 1690: const char* get_thread_name() const;
> 1691: protected:
> 1692: friend class JvmtiTrace; // so get_thread_name_string() can be called
I was trying to think of a way to not have JvmtiTrace not be a friend of JavaThread for this, maybe by adding a default value parameter to return "<NOT FILLED IN\>" rather than Thread::name.
is_JavaThread_protected only seems to be called by JvmtiTrace also, so should be private (with the friend, which also makes the friend unfortunate).
-------------
Changes requested by coleenp (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/2535
More information about the serviceability-dev
mailing list