RFR: 8238649: Call new Win32 API SetThreadDescription in os::set_native_thread_name

Thomas Stuefe stuefe at openjdk.java.net
Fri Jun 11 17:16:55 UTC 2021


On Fri, 11 Jun 2021 06:26:26 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> src/hotspot/os/windows/os_windows.cpp line 890:
>> 
>>> 888: // For dynamic lookup of SetThreadDescription API
>>> 889: typedef HRESULT (WINAPI *SetThreadDescriptionFnPtr)(HANDLE, PCWSTR);
>>> 890: typedef HRESULT (WINAPI *GetThreadDescriptionFnPtr)(HANDLE, PWSTR*);
>> 
>> DEBUG_ONLY?
>
> As it is only a typedef I didn't think the DEBUG_ONLY ugliness was warranted.

Hmm, I find it inconsistent, but its also not important. Okay.

>> src/hotspot/os/windows/os_windows.cpp line 930:
>> 
>>> 928:                                    thread_name,
>>> 929:                                    -1  // null-terminated
>>> 930:                                    );
>> 
>> Why not just use wcscmp? (WCHAR == wchar_t, and also you use %ls below which implies wchar_t, so you may use wcscmp here too).
>
> Simply because I wasn't aware of it. I'm not at all familiar with Unicode/string API's on Windows and just looked around for something that would seem to do the job. All these types seem to be wchar_t in some form under the covers.

Yes, its not that well documented. But we fall back to wcs... APIs in a couple of places. But if your code works there is no need to change it.

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

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


More information about the hotspot-runtime-dev mailing list