[foreign-memaccess+abi] RFR: 8291639: Improve the ability to visualize a MemorySegment in human readable forms [v15]

Jorn Vernee jvernee at openjdk.org
Mon Jun 5 15:44:49 UTC 2023


On Wed, 31 May 2023 09:16:11 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Per Minborg has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 46 commits:
>> 
>>  - Merge foreign-memaccess+abi
>>  - Remove redundant imports
>>  - Use invokeExact and raw method handles for composition
>>  - Move method to class
>>  - Update array section doc
>>  - Define offset in the javadocs
>>  - Update javadoc
>>  - Use explicit call rather than using a method
>>  - Add variable Lookup
>>  - Break apart nested switch statements
>>  - ... and 36 more: https://git.openjdk.org/panama-foreign/compare/38f4bfe7...e0fb8727
>
> src/java.base/share/classes/java/lang/foreign/GroupLayout.java line 102:
> 
>> 100:      * Then, for each {@code c_a, a <= N}, there must be a corresponding distinct
>> 101:      * {@code e_b} such that the {@link MemoryLayout#name() name} of {@code c_a}
>> 102:      * {@link Object#equals(Object) equals} the {@link RecordComponent#getName() name} of {@code e_b} and:
> 
> such that the name ... and the name ... are the same

I think the links to the name methods are switched, since `c_a` is the record component, and `e_b` is the layout member.

Also, why is this using `e_b` instead of `e_a`? The latter makes more sense to me, since the component and member layout correspond to each other.

> src/java.base/share/classes/java/lang/foreign/GroupLayout.java line 107:
> 
>> 105:      *        <h4>If {@code e_b} is a {@link ValueLayout };</h4>
>> 106:      *        then {@code c_a} must be of the exact type of {@code e_b}'s {@link ValueLayout#carrier() carrier()}<br>
>> 107:      *        whereby {@code c_a = f_a(MemorySegment ms) = ms.get(e_b, offset + offsetBetween(layout, e_b))}.<br>
> 
> It is not defined what "offset" is. I believe that has to be a parameter to the f_a - e.g. the function takes a segment *and* and offset.

That's what I thought as well, but the returned `Function<MemorySegment, R>` doesn't accept an offset?

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

PR Review Comment: https://git.openjdk.org/panama-foreign/pull/833#discussion_r1218073730
PR Review Comment: https://git.openjdk.org/panama-foreign/pull/833#discussion_r1218089432


More information about the panama-dev mailing list