[foreign-preview] Integrated: 8282061: Improve support for deterministic closure of shared scopes

Maurizio Cimadamore mcimadamore at openjdk.java.net
Fri Feb 25 17:44:29 UTC 2022


On Thu, 17 Feb 2022 16:11:52 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).

This pull request has now been integrated.

Changeset: 5eec2e24
Author:    Maurizio Cimadamore <mcimadamore at openjdk.org>
URL:       https://git.openjdk.java.net/panama-foreign/commit/5eec2e24f4d15e3a7577fa27597f0a78f78f6d88
Stats:     96 lines in 6 files changed: 52 ins; 14 del; 30 mod

8282061: Improve support for deterministic closure of shared scopes

Reviewed-by: psandoz, jvernee

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

PR: https://git.openjdk.java.net/panama-foreign/pull/643


More information about the panama-dev mailing list