On Fri, 15 Oct 2021 21:58:38 GMT, Daniel D. Daugherty <dcu...@openjdk.org> 
wrote:

>> src/hotspot/share/runtime/handshake.cpp line 358:
>> 
>>> 356:   bool target_is_dead = false;
>>> 357:   if (target == nullptr) {
>>> 358:     target_is_dead = true;
>> 
>> Why would you pass a NULL target thread to Handshake::execute? Why would the 
>> caller not check if the target is dead?
>
> The `NULL` target thread being passed in is actually handled by the baseline 
> code:
> 
> 
>   ThreadsListHandle tlh;
>   if (tlh.includes(target)) {
> 
> 
> `tlh.includes(target)` returns `false` when `target` is `NULL/nullptr`.
> I just made the already handled situation more explicit.
> 
>> Why would the caller not check if the target is dead?
> 
> Hmmm...  It's hard for me to answer that question since I didn't write
> the original code. The test code that calls `WB_HandshakeWalkStack()`
> or `WB_AsyncHandshakeWalkStack()` can call those functions with
> a `thread_handle` that translates into a `thread_oop` that returns a
> `NULL` `JavaThread*`.
> 
> See the comment that I added to `WB_AsyncHandshakeWalkStack()` above.

Update: I've added comments to WB_HandshakeReadMonitors() and
WB_HandshakeWalkStack() to clarify their expectations.

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

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

Reply via email to