RFR: 8305898: Alternative self-forwarding mechanism [v4]

Albert Mingkun Yang ayang at openjdk.org
Thu Feb 15 14:34:54 UTC 2024


On Thu, 15 Feb 2024 14:08:00 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:

>> Even on 32bits system, shouldn't `_mark` = 4 bytes and `_metadata` = 4 bytes, so the total size of `oopDesc` is 8 bytes?
>
> The alignment of a struct must just ensure that the alignments requirement of its fields are satisfied (in the general case) So a struct of two 4 byte ints will have an `alignof` 4 bytes and a `sizeof` 8 bytes
> ```c++
> #include <cstdint>
> struct S {
>     uint32_t a;
>     uint32_t b;
> };
> 
> static_assert(alignof(S) == 4);
> static_assert(sizeof(S) == 8);

Thank you for the explanation; I mistakenly thought a struct is aligned to its size...

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17755#discussion_r1491107746


More information about the hotspot-gc-dev mailing list