RFR: 8305425: Thread.isAlive0 doesn't need to call into the VM [v7]

Aleksey Shipilev shade at openjdk.org
Wed Apr 5 08:23:19 UTC 2023


On Wed, 5 Apr 2023 07:23:03 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> We have the strange situation where calling `t.isAlive()` on a `java.lang.Thread` `t`, will call into the VM (via `alive()` then `isAlive0()`) where the VM then examines the `eetop` field of `t` to extract its `JavaThread` pointer and compare it to null. We can simply read `eetop` directly in `Thread.alive()`:
>> 
>> boolean alive() {
>>   return eetop != 0;
>> } 
>> 
>> I also updated a comment in relation to `eetop`.
>> 
>> Testing: tiers 1-3
>> 
>> Thanks
>
> David Holmes has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Reformat comment block

I am good with this version. Consider the following amendments, if you have any other fixes for this PR in the pipeline. Ignore if not, no need to spend more time testing this.

test/jdk/java/lang/Thread/IsAlive.java line 38:

> 36:         try {
> 37:             while (!Thread.currentThread().isInterrupted()) {
> 38:                 Thread.sleep(10);

Suggestion:

                Thread.sleep(100);

test/jdk/java/lang/Thread/IsAlive.java line 62:

> 60: 
> 61:         if (!spinnerDone) {
> 62:             throw new RuntimeException("last write of terminated thread wasn't seen!");

Suggestion:

            throw new RuntimeException("Last write of terminated thread was not seen!");

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

Marked as reviewed by shade (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/13287#pullrequestreview-1372395326
PR Review Comment: https://git.openjdk.org/jdk/pull/13287#discussion_r1158184386
PR Review Comment: https://git.openjdk.org/jdk/pull/13287#discussion_r1158184236



More information about the build-dev mailing list