Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8271569

Clean up the use of CDS constants and field offsets

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b16

      Description

      cdsoffsets.cpp contains a table of constants that are used by whitebox testing code

      #define CREATE_OFFSET_MAPS \
          _all = new CDSOffsets("size_t_size", sizeof(size_t), NULL); \
          ADD_NEXT(_all, "int_size", sizeof(int)); \
          ADD_NEXT(_all, "FileMapHeader::_magic", offset_of(FileMapHeader, _magic)); \
          ADD_NEXT(_all, "FileMapHeader::_crc", offset_of(FileMapHeader, _crc)); \
          ADD_NEXT(_all, "FileMapHeader::_version", offset_of(FileMapHeader, _version)); \
          ADD_NEXT(_all, "FileMapHeader::_jvm_ident", offset_of(FileMapHeader, _jvm_ident)); \
          ADD_NEXT(_all, "FileMapHeader::_space[0]", offset_of(FileMapHeader, _space)); \
          ADD_NEXT(_all, "CDSFileMapRegion::_crc", offset_of(CDSFileMapRegion, _crc)); \
          ADD_NEXT(_all, "CDSFileMapRegion::_used", offset_of(CDSFileMapRegion, _used)); \
          ADD_NEXT(_all, "file_header_size", sizeof(FileMapHeader)); \
          ADD_NEXT(_all, "DynamicArchiveHeader::_base_region_crc", offset_of(DynamicArchiveHeader, _base_region_crc)); \
          ADD_NEXT(_all, "CDSFileMapRegion_size", sizeof(CDSFileMapRegion));

      However, some of these constants are not offsets. To avoid confusion, it's better to split this table into two: one with the offsets, and one with the other constants. They will be accessed by two WhiteBox functions:

      WhiteBox::getCDSOffset("DynamicArchiveHeader::_base_region_crc");
      WhiteBox::getCDSConstant("CDSFileMapRegion_size");

      Also, instead of a linked list, this table can be made constant:

      constexpr struct {
          const char* _name;
          size_t _size;
      } cds_offsets[] = {
        { "FileMapHeader::_magic", offset_of(FileMapHeader, _magic) },
        { "FileMapHeader::_crc", offset_of(FileMapHeader, _crc) },
        { "FileMapHeader::_version", offset_of(FileMapHeader, _version) },
        { "FileMapHeader::_jvm_ident", offset_of(FileMapHeader, _jvm_ident) },
        ....
      };

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              minqi Yumin Qi (Inactive)
              Reporter:
              iklam Ioi Lam
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: