[foreign-memaccess+abi] RFR: 8301360: Add dereference layout paths to memory layout API [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Tue Jan 31 10:20:15 UTC 2023


> Now that we have a more general way to attach target layouts to address layouts (see https://git.openjdk.org/panama-foreign/pull/775), it might be useful to add support for layout paths which perform dereference of a given address value. Consider this case:
> 
> 
> struct b {
>    int x;
> };
> 
> struct a {
>     struct b *b;
> };
> 
> 
> Here, our goal is to construct a layout path for "a->b.x".
> 
> To do this, we use a *dereference path element* (see `PathElement#dereferenceElement`). These comes in two flavors:
> 
> * no argument factory - this assumes that the address layout being dereferenced has some target layout set;
> * layout argument factory - this assumes that the address layout being dereferenced does *not* have a target layout set (e.g. it is not always possible to associate a target layout, especially in cyclic cases like a -> b -> a).
> 
> When a dereference element is applied to an existing path, a var handle that fetches the address pointed to by the current path is pushed on the stack, and a new layout path is started. This way, dereference path can be used to "chain" together multiple layout paths. All the intermediate memory read operations occur using a *plain* get. For more complex access operation (e.g. if atomic access is required for the whole dereference chain), multiple var handles have to be obtained.
> 
> It is an error to pass a dereference path to other layout operations such as `select`, `byte/bitOffset[Handle]`.

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

  Drop overload of PathElement.dereferenceElement
  Address review comments

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

Changes:
  - all: https://git.openjdk.org/panama-foreign/pull/776/files
  - new: https://git.openjdk.org/panama-foreign/pull/776/files/0d464383..902c91b5

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

  Stats: 86 lines in 3 files changed: 6 ins; 72 del; 8 mod
  Patch: https://git.openjdk.org/panama-foreign/pull/776.diff
  Fetch: git fetch https://git.openjdk.org/panama-foreign pull/776/head:pull/776

PR: https://git.openjdk.org/panama-foreign/pull/776


More information about the panama-dev mailing list