[foreign-preview] RFR: 8282953: Drop MemoryLayout::map [v2]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Thu Mar 10 17:49:49 UTC 2022


> This patch removes the `MemoryLayout::map` method. This method was introduced to add some support for VLA (back when we had unbounded sequence layouts).
> 
> This method is quite limited when it comes to define transformations, as it can only alter one layout per call. As such, it is not useful to define global transformations to e.g. flip the endianness of all value layouts nested in a given layout.
> 
> We believe we can do much better than this (and have few ideas floating around) - but for the time being we'd like not to take the "good" name for a method that just doesn't seem all that useful.
> 
> When removing the method, I realized that the `LayoutPath` class had a lot of unneeded complexity:
> 
> * the size function is no longer needed, given that all layouts have a size
> * keeping track of selected indices while navigating layout was only useful for the map operation, so I removed it
> * we had two static methods `addStride` and `addScaledOffset` which did same thing; I dropped the first - the duplication was introduced when we dropped workarounds for "small" segments, in fact the leading `MemorySegment` parameter in the first method is now unused;
> * I have greatly simplified the logic to create var handles from layouts; there is no need to do permutations (a similar simpler scheme was also used in the logic for computing offset method handles)

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

  Remove reference to layout attributes in the MemoryLayout javadoc

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

Changes:
  - all: https://git.openjdk.java.net/panama-foreign/pull/667/files
  - new: https://git.openjdk.java.net/panama-foreign/pull/667/files/38726900..b0d0f439

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

  Stats: 9 lines in 1 file changed: 3 ins; 5 del; 1 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/667.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/667/head:pull/667

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


More information about the panama-dev mailing list