Integrated: 8334229: Optimize InterpreterOopMap layout
Xiaolong Peng
xpeng at openjdk.org
Wed Jul 3 03:04:23 UTC 2024
On Mon, 1 Jul 2024 21:23:35 GMT, Xiaolong Peng <xpeng at openjdk.org> wrote:
> 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];
>
> ...
This pull request has now been integrated.
Changeset: fac74b11
Author: Xiaolong Peng <xpeng at openjdk.org>
Committer: David Holmes <dholmes at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/fac74b118f5fda4ec297e46238d34ce5b9be1e21
Stats: 10 lines in 1 file changed: 5 ins; 5 del; 0 mod
8334229: Optimize InterpreterOopMap layout
Reviewed-by: coleenp, dholmes
-------------
PR: https://git.openjdk.org/jdk/pull/19979
More information about the hotspot-runtime-dev
mailing list