[foreign-memaccess+abi] RFR: 8274602: Generalize UpcallStub into NativeSymbol [v2]
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Tue Oct 5 14:34:55 UTC 2021
> It might sometimes be useful to define a custom symbol lookup which returns symbols backed by a library that can be unloaded dynamically (e.g. using dlopen).
> We indeed have all the pieces to get there, except that symbnol lookup returns a memory address, which is not a scoped entity.
>
> To address this, I propose that we add a new sealed interface/final class (`NativeSymbol`) which implements `Addressable` and is used in two places:
> * as a return value for a symbol lookup
> * as a proxy for an upcall stub
>
> In other words, `NativeSymbol` is used to reference to some symbol in some library, where the library can have a given scope. Upcall stubs are just a special case where the upcall symbol is synthetized on the fly by the VM. With this in place, I think we can drop `CLinker.UpcallStub` and just use an "anonymous` NativeSymbol to represent upcall stubs.
>
> With this, it should be possible to define a dlopen-based lookup such as the one below:
> https://github.com/sundararajana/panama-jextract-samples/blob/master/dlopen/Dlopen.java
>
> In a way that is completely *safe* - that is, so that it is not possible for a library to be unloaded while a function is being executed (even when the scope associated to the native symbol is shared).
Maurizio Cimadamore has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains ten additional commits since the last revision:
- Merge branch 'foreign-memaccess+abi' into native_symbol
- Use NativeSymbol in downcallHandle
- Merge branch 'foreign-memaccess+abi' into native_symbol
- Add missing copyright headers
- Merge branch 'foreign-memaccess+abi' into native_symbol
- Fix QSort benchmark
- Add scope check
Add test
- Merge branch 'foreign-memaccess+abi' into native_symbol
- Initial push
-------------
Changes:
- all: https://git.openjdk.java.net/panama-foreign/pull/589/files
- new: https://git.openjdk.java.net/panama-foreign/pull/589/files/123fb4ab..3302f2fb
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=589&range=01
- incr: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=589&range=00-01
Stats: 7553 lines in 325 files changed: 5366 ins; 1163 del; 1024 mod
Patch: https://git.openjdk.java.net/panama-foreign/pull/589.diff
Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/589/head:pull/589
PR: https://git.openjdk.java.net/panama-foreign/pull/589
More information about the panama-dev
mailing list