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

Maurizio Cimadamore mcimadamore at openjdk.java.net
Tue Feb 22 09:57:54 UTC 2022


> 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:

  Address review comments:
  Fix comments in scopedMemoryAccess::closeScope

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

Changes:
  - all: https://git.openjdk.java.net/panama-foreign/pull/643/files
  - new: https://git.openjdk.java.net/panama-foreign/pull/643/files/fee2a483..a266c779

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=643&range=08
 - incr: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=643&range=07-08

  Stats: 12 lines in 1 file changed: 0 ins; 0 del; 12 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/643.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/643/head:pull/643

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


More information about the panama-dev mailing list