[lworld] RFR: 8285763: Implement new approach to dump inlined objects

Alex Menkov amenkov at openjdk.java.net
Wed Apr 27 22:42:41 UTC 2022


Implements new way to dump inlined objects.

Hprof file format changes:
-- dump inlined fields in the holder object by introducing synthetic fields to hold the primitive fields of the inlined type.
    HPROF_GC_CLASS_DUMP records describe the synthetic fields.
    HPROF_GC_INSTANCE_DUMP records dump inlined object as fields of the holder object.
    Example:
        primitive class P1 {
            byte b1;
        }
        primitive class P2 {
            P1 p1;
            int i1;
        }
        class Holder {
            P1 p1;
            P2 p2;
        }

    HPROF_GC_CLASS_DUMP record for Holder class does not contain descriptions for p1 and p2 fields, but instead has:
        p1.b1: byte;
        p2.p1.b1: byte;
        p2.i1: int;

-- new record type is added to describe class with inlined fields:
    HPROF_INLINED_FIELDS
    The record contains HPROF_CLASS_WITH_INLINED_FIELDS subrecords with the following format:
        id         - class ID (dumped as HPROF_GC_CLASS_DUMP)
        u2        - number of instance inlined fields (not including super)

    in the example above 2 (p1.b1, p2.p1.b1, p2.i1)

        [u2       - inlined field index (zero-based)
         u2       - synthetic field count
         id        - original field name (dumped as HPROF_UTF8)
         id]*      - inlined field class ID (dumped by HPROF_GC_CLASS_DUMP)

    in the example above there are 2 elements:
        [0, 1, "p1", P1 HPROF_GC_CLASS_DUMP record]
        [1, 2, "p2", P2 HPROF_GC_CLASS_DUMP record]

    This records allows new hprof parser tools to restore original fields of the object;
    Old tools will see synthetic fields which makes possible manual research of the dump.

-- flat arrays are dumped as HPROF_GC_PRIM_ARRAY_DUMP subrecords (may be byte/short/int array)

-- new record type is added to describe flat arrays:
    HPROF_FLAT_ARRAYS
    The record contains array of HPROF_FLAT_ARRAY subrecords:
        id     - array object ID (dumped as HPROF_GC_PRIM_ARRAY_DUMP)
        id     - element class ID (dumped by HPROF_GC_CLASS_DUMP)

    This records allows new hprof parsers to restore original type of the flat arrays;
    Unfortunately old parsers can't extract much information from the array dump.

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

Commit messages:
 - New heap dumper implementation
 - revert old implementation

Changes: https://git.openjdk.java.net/valhalla/pull/686/files
 Webrev: https://webrevs.openjdk.java.net/?repo=valhalla&pr=686&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8285763
  Stats: 1228 lines in 9 files changed: 882 ins; 156 del; 190 mod
  Patch: https://git.openjdk.java.net/valhalla/pull/686.diff
  Fetch: git fetch https://git.openjdk.java.net/valhalla pull/686/head:pull/686

PR: https://git.openjdk.java.net/valhalla/pull/686



More information about the valhalla-dev mailing list