2 ms·
The compiler cannot reorder the fields. This stuff comes up occasionally in optimizing layout of language VM structures, compilers, in the Linux kernel and othe
by FRex 9y ago
The compiler cannot reorder the fields.
This stuff comes up occasionally in optimizing layout of language VM structures, compilers, in the Linux kernel and other low level situations.
I.e. JVM compressed object pointers rely on the alignment and the native objects representation is definitely well laid out to not waste space due to alignment:
https://stackoverflow.com/a/25120926 https://stackoverflow.com/a/25120926
https://blog.codecentric.de/en/2014/02/35gb-heap-less-32gb-java-jvm-memory-oddities/ https://blog.codecentric.de/en/2014/02/35gb-heap-less-32gb-j...
Lua implementation similarly cares about alignment in some cases:
http://lua-users.org/lists/lua-l/2009-02/msg00305.html http://lua-users.org/lists/lua-l/2009-02/msg00305.html
This is not exactly 'struct packing' but alignment is closely connected to padding so its part of a wider interconnected topic.