[foreign-memaccess+abi] RFR: 8265974: ResourceScope code does not handle close vs. add races well [v2]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Mon Apr 26 20:18:12 UTC 2021


> This PR is motivated by the discussion in:
> 
> https://git.openjdk.java.net/panama-foreign/pull/519
> 
> There seems to be an issue (at least conceptually) in that the code which adds a new cleanup can, in principle, replace CLOSED_LIST with a new cleanup action, which then breaks the list invariants.
> 
> While some fixes are possible, I believe that this part of the code is too complex and there's really no reason as to why we would want to allow CLOSE and ADD to happen in parallel with as few synchronization as possible.
> 
> Since we already have a way to prevent a scope from being closed, it only seems fair that `addCloseAction` should defend against scope closure using acquire. Under this new, simplified world, in the shared case we only have to worry about add vs. add races, as add vs. close is no longer possible.
> 
> I've re-ran the benchmark `ResourceScopeClose` and noticed no performance impact of this code simplification. So I think it would be better to make the code "dumber" but more obviously correct, rather than chasing dubious micro optimizations whose correctess we're not 100% sure about.

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

  Restorew `final` in `ConfinedResourceListImpl`

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

Changes:
  - all: https://git.openjdk.java.net/panama-foreign/pull/520/files
  - new: https://git.openjdk.java.net/panama-foreign/pull/520/files/6b048f36..1764f6e4

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

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

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


More information about the panama-dev mailing list