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

Maurizio Cimadamore mcimadamore at openjdk.java.net
Mon Feb 21 14:37:41 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:

  Avoid creation of ThreadListHandle in first handshake

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

Changes:
  - all: https://git.openjdk.java.net/panama-foreign/pull/643/files
  - new: https://git.openjdk.java.net/panama-foreign/pull/643/files/5e26ae25..56a6543d

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

  Stats: 7 lines in 1 file changed: 5 ins; 1 del; 1 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