On Mon, 4 Sep 2023 12:20:52 GMT, Martin Doerr <mdo...@openjdk.org> wrote:

>> Sorry for the delay, I've been on vacation.
>
>> Sorry for the delay, I've been on vacation.
> 
> No problem. Hope you had a good time! Thanks for your feedback.

@TheRealMDoerr We've been discussing the shifts in order to wrap our heads 
around it, and we've ended up with this diagram in order to try and visualize 
what happens:

Let's say we have a struct with 3 ints:


struct Foo {
    int x;
    int y;
    int z;
};


If this struct is passed as an argument, then the load of the second 'half' of 
the struct would look like this:


offset         : 0 .... 32 ..... 64 ..... 96 .... 128
values         : xxxxxxxx|yyyyyyyy|zzzzzzzz|????????   (can't touch bits 
96..128)
Load int       :                  V        +--------+
                                  |                 |
                                  +--------+        |
                                           V        V
In register    :                   ????????|zzzzzzzz   (MSBs are 0)
Shift left     :                   zzzzzzzz|00000000   (LSBs are zero)
Write long     :                  V                 V
Result         : xxxxxxxx|yyyyyyyy|zzzzzzzz|00000000


So, the 'Result' is padded at the tail with zeros.

Does that seem right? Does it seem useful to add this diagram as a comment 
somewhere, for us when we come back to this code a year from now? Thanks

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

PR Comment: https://git.openjdk.org/jdk/pull/15417#issuecomment-1705350592

Reply via email to