[foreign-memaccess] [Rev 01] RFR: Simplify MemoryScope implementation to use StampedLock

Maurizio Cimadamore mcimadamore at openjdk.java.net
Wed May 13 20:38:27 UTC 2020

> I've been playing around a bit and discussed this offline with @JornVernee too. A realization I had some time ago is
> that what we're trying to do here is a read/write lock, where multiple acquire can occur at the same time, but where
> close of the root should be exclusive. I think all the machinery around `CLOSING` is essentially due to the code trying
> to mimic that pattern.  This patch simplifies over the status quo, by using a `StampedLock` instead of managing races
> manually through a `CLOSING` state. The tweaked implementation also adds back the atomicity w.r.t. close() vs. dup()
> which was seeked in a previous attempt (see https://git.openjdk.java.net/panama-foreign/pull/160). Also, since now
> there some guarantee that no acquire can take place while a close is also taking place (and pending acquires will be
> invalidated - using the optimistic read logic), then we can just use a single long adder instead of two.  The state is
> also simplified, since we just need a boolean flag.  I ran the `ParallelSum` benchmark and could not spot any obvious
> regression compared to the previous code.

Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:

  Fix typos


  - all: https://git.openjdk.java.net/panama-foreign/pull/163/files
  - new: https://git.openjdk.java.net/panama-foreign/pull/163/files/a954d673..c00475d6

 - full: https://webrevs.openjdk.java.net/panama-foreign/163/webrev.01
 - incr: https://webrevs.openjdk.java.net/panama-foreign/163/webrev.00-01

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

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

More information about the panama-dev mailing list