[foreign-memaccess] RFR: 8253937: Simplify support for shared memory segment
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Fri Oct 2 15:46:54 UTC 2020
This patch removs the dependency between shared memory segment support and VM async exceptions support. This dependency
has proven to be problematic, since not all the code paths in the VM handle async exceptions correctly (this can also
be seen by the number of places which have to be touched in the VM code - which are now reverted by this patch).
Instead, we can adopt a much simpler approach where, if when closing a segment, we detect concurrent access inside the
handshake, we simply fail on close. I've added extra javadoc to clarify that, if a client sees an exception when
closing a segment, that should be perceived as a bug in the code (lack of synchronization) rather than be tempted to
catch the exception and rethrow.
Overall, the support requires a lot less from the VM and I think it's a fairly reasonable compromise. Note that now
shared scopes have three states:
* ALIVE
* CLOSING
* CLOSED
The liveness check upon segment access fails if state != ALIVE; on the other hand, the public API
`MemorySegment::isAlive` returns true, as long as the state is != CLOSED. This means that clients sees only one
transition, from `isAlive() == true` to `isAlive() == false`.
We will keep experimenting with the async exception support in a separate branch, as a future implementation
improvement (note that relaxing the semantics of `close` so that it will *never* fail, is both source- and binary-
compatible with the approach proposed here).
-------------
Commit messages:
- Update javadoc
- Refactor test
- Revert hotspot changes
- Simplify shared segment support, by removing dependencies on VM async exceptions
Changes: https://git.openjdk.java.net/panama-foreign/pull/369/files
Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=369&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8253937
Stats: 251 lines in 16 files changed: 87 ins; 105 del; 59 mod
Patch: https://git.openjdk.java.net/panama-foreign/pull/369.diff
Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/369/head:pull/369
PR: https://git.openjdk.java.net/panama-foreign/pull/369
More information about the panama-dev
mailing list