[foreign-preview] Integrated: 8282953: Drop MemoryLayout::map

Maurizio Cimadamore mcimadamore at openjdk.java.net
Fri Mar 11 10:15:38 UTC 2022


On Thu, 10 Mar 2022 12:40:10 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> 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)

This pull request has now been integrated.

Changeset: f645d4ff
Author:    Maurizio Cimadamore <mcimadamore at openjdk.org>
URL:       https://git.openjdk.java.net/panama-foreign/commit/f645d4ff204d508bc708cb020e6f7664c5996897
Stats:     232 lines in 4 files changed: 5 ins; 200 del; 27 mod

8282953: Drop MemoryLayout::map

Reviewed-by: psandoz

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

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


More information about the panama-dev mailing list