RFR: 8334229: Optimize InterpreterOopMap layout [v2]
Xiaolong Peng
xpeng at openjdk.org
Mon Jul 1 21:53:52 UTC 2024
> Hi all,
> This PR is re-arrange the fields in InterpreterOopMap to optimize the layout of the class; by moving ```unsigned short _bci ``` to the place after ```int _expression_stack_size```, and ```int _num_oops``` to the place before ```intptr_t _bit_mask[4];```, most of the holes are removed.
>
> Layout before the fix:
>
> (gdb) ptype /xo InterpreterOopMap
> /* offset | size */ type = class InterpreterOopMap : private ResourceObj {
> private:
> /* 0x0000 | 0x0008 */ class Method *_method;
> /* 0x0008 | 0x0002 */ unsigned short _bci;
> /* XXX 2-byte hole */
> /* 0x000c | 0x0004 */ int _mask_size;
> /* 0x0010 | 0x0004 */ int _expression_stack_size;
> protected:
> /* XXX 4-byte hole */
> /* 0x0018 | 0x0020 */ intptr_t _bit_mask[4];
> /* 0x0038 | 0x0004 */ int _num_oops;
> /* XXX 4-byte padding */
>
> /* total size (bytes): 64 */
> }
>
>
> After fix:
>
> (gdb) ptype /xo InterpreterOopMap
> /* offset | size */ type = class InterpreterOopMap : private ResourceObj {
> private:
> /* 0x0000 | 0x0008 */ class Method *_method;
> /* 0x0008 | 0x0004 */ int _mask_size;
> /* 0x000c | 0x0004 */ int _expression_stack_size;
> /* 0x0010 | 0x0002 */ unsigned short _bci;
> protected:
> /* XXX 2-byte hole */
> /* 0x0014 | 0x0004 */ int _num_oops;
> /* 0x0018 | 0x0020 */ intptr_t _bit_mask[4];
>
> /* total size (bytes): 56 */
> }
>
>
> (Also moved ```bool _resource_allocate_bit_mask``` to before ```intptr_t _bit_mask[4];```, so it will use 1 byte of the 2-byte hole, resulting in 1 byte hole in fastdebug build.)
>
> Layout in fastdebug build:
>
> (gdb) ptype /xo InterpreterOopMap
> /* offset | size */ type = class InterpreterOopMap : private ResourceObj {
> private:
> /* 0x0000 | 0x0008 */ class Method *_method;
> /* 0x0008 | 0x0004 */ int _mask_size;
> /* 0x000c | 0x0004 */ int _expression_stack_size;
> /* 0x0010 | 0x0002 */ unsigned short _bci;
> protected:
> /* 0x0012 | 0x0001 */ bool _resource_allocate_bit_mask;
> /* XXX 1-byte hole */
> /* 0x0014 | 0x0004 */ int _num_oops;
> /* 0x0018 | 0x0020 */ intptr_t _bit_mask[4];
>
> ...
Xiaolong Peng has updated the pull request incrementally with one additional commit since the last revision:
Move _resource_allocate_bit_mask to the place before _num_oops for better layout in debug build
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/19979/files
- new: https://git.openjdk.org/jdk/pull/19979/files/a6deded4..db1170ac
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=19979&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=19979&range=00-01
Stats: 4 lines in 1 file changed: 1 ins; 1 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/19979.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/19979/head:pull/19979
PR: https://git.openjdk.org/jdk/pull/19979
More information about the hotspot-runtime-dev
mailing list