[foreign] RFR Add sizeof method to Struct type
Sundararajan Athijegannathan
sundararajan.athijegannathan at oracle.com
Thu Jul 26 16:40:26 UTC 2018
Updated webrev: http://cr.openjdk.java.net/~sundar/8208284/webrev.01/
Left a FIXME comment in ScopeImpl.allocateStruct and removed alignment
in Struct.sizeof
-Sundar
On 26/07/18, 8:51 PM, Henry Jen wrote:
> Allocation do the alignment to make sure we get proper address alignment. We don’t need that here as we want to know the actual size.
>
> I am not 100% sure why current implementation add that alignment padding, perhaps to optimize access, but I am not sure if that’s necessary as the C compiler could have done that. We do want to make allocation at right boundary, NativeScope does align that allocation to 8 which we may want to make it dynamic to each allocation.
>
> Cheers,
> Henry
>
>> On Jul 26, 2018, at 8:06 AM, Sundararajan Athijegannathan<sundararajan.athijegannathan at oracle.com> wrote:
>>
>> Shouldn't this be consistent ScopeImpl.allocateStruct? user would typically allocateStruct and pass then pass ptr and size of that, right?
>>
>> -Sundar
>>
>> On 26/07/18, 8:26 PM, Henry Jen wrote:
>>> I am not sure why we need the Util.alignUp call here, that’s supposed to be used for allocation to arrange address space.
>>>
>>> The layout should have proper padding and give the right size as if you call sizeof() in C on the struct.
>>>
>>> Otherwise, SystemABI.sizeof(Layout) should give you the right size based on platform.
>>>
>>> Cheers,
>>> Henry
>>>
>>>
>>>> On Jul 26, 2018, at 1:50 AM, Sundararajan Athijegannathan<sundararajan.athijegannathan at oracle.com> wrote:
>>>>
>>>> Please review.
>>>>
>>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8208284
>>>> Webrev: http://cr.openjdk.java.net/~sundar/8208284/webrev.00/
>>>>
>>>> Thanks,
>>>> -Sundar
More information about the panama-dev
mailing list