[foreign-preview] RFR: 8282061: Improve support for deterministic closure of shared scopes [v5]
Jorn Vernee
jvernee at openjdk.java.net
Mon Feb 21 15:49:53 UTC 2022
On Mon, 21 Feb 2022 15:45:41 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> This patch improves the logic for closing shared resource scopes, by using the following algorithm:
>>
>> 1. move the scope from ALIVE to CLOSED - no new thread can access segments associated with the scope
>> 2. do an initial handshake, to collect all threads that are accessing the scope concurrently
>> 3. if no thread is found, finish
>> 4. if some threads T1, T2 ... Tn are found, keep doing handshakes (only against these threads) then go back to (3).
>>
>> Note that the logic no longer require *three* states for shared segment, and also this logic always succeeds - that is the close operation can never fail because of a spurious access found during an handshake.
>>
>> Note that the logic converges quickly, because handshaked threads are deoptimized - meaning that they will have to re-load the liveness state of the resource they are accessing (at which point they will just throw an exception).
>>
>> Implementation-wise, when looking over the code with @fisk , we realized that it is possible for multiple threads to run the handhshake closure concurrently. To collect all the problematic thread, we used a lock free stack (which was already implemented in the hotspot code). Also, to keep problematic threads alive during multiple rounds of handshaking, we use a ThreadHandleList (this is also required to be able to handshake on a specific thread).
>
> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
>
> Tweak comments in scopedMemoryAccess
Nice! Tests also pass on Windows
-------------
Marked as reviewed by jvernee (Committer).
PR: https://git.openjdk.java.net/panama-foreign/pull/643
More information about the panama-dev
mailing list