RFR: 8334229: Optimize InterpreterOopMap layout

Xiaolong Peng xpeng at openjdk.org
Mon Jul 1 21:30:48 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.)

Best,
Xiaolong.

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

Commit messages:
 - 8334229: Optimize InterpreterOopMap layout

Changes: https://git.openjdk.org/jdk/pull/19979/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=19979&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8334229
  Stats: 11 lines in 1 file changed: 5 ins; 5 del; 1 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