[foreign-preview] RFR: 8282953: Drop MemoryLayout::map [v2]
Paul Sandoz
psandoz at openjdk.java.net
Thu Mar 10 23:07:57 UTC 2022
On Thu, 10 Mar 2022 17:49:49 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)
>
> 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
Marked as reviewed by psandoz (Committer).
src/java.base/share/classes/jdk/internal/foreign/LayoutPath.java line 141:
> 139:
> 140: VarHandle handle = Utils.makeSegmentViewVarHandle(valueLayout);
> 141: for (int i = strides.length - 1; i >=0; i--) {
Suggestion:
for (int i = strides.length - 1; i >= 0; i--) {
src/java.base/share/classes/jdk/internal/foreign/LayoutPath.java line 192:
> 190:
> 191: public static LayoutPath rootPath(MemoryLayout layout) {
> 192: return new LayoutPath(layout, 0L, EMPTY_STRIDES,null);
Suggestion:
return new LayoutPath(layout, 0L, EMPTY_STRIDES, null);
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/667
More information about the panama-dev
mailing list