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

CDS archived heap object support for 64-bit Windows

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P4
    • 24
    • None
    • hotspot
    • b11
    • windows

    Description

      In JDK-8179302, when CDS archive heap objects was first introduced, we didn't support Windows:

      https://github.com/openjdk/jdk/blob/9b11bd7f4a511ddadf9f02e82aab6ba78beb6763/src/hotspot/share/utilities/macros.hpp#L624-L625

      #if INCLUDE_CDS && INCLUDE_G1GC && defined(_LP64) && !defined(_WINDOWS)
      #define INCLUDE_CDS_JAVA_HEAP 1
      ...
      #else
      #define INCLUDE_CDS_JAVA_HEAP 0
      #endif

      The reasons were:

      - The Windows implementation of os::map_memory() cannot map the contents of a file into a region that's already reserved by the garbage collector.
      - We had a high failure rate for mapping the CDS archive on Windows due to ASLR, sometimes as high as 50%. So it didn't seem worth the effort (mainly testing) to support archived heap objects on Windows.

      Both of the above issues were fixed in JDK-8231610. We can use the MetaspaceShared::use_windows_memory_mapping() mode introduced in JDK-8231610 in FileMapInfo::map_heap_region_impl().

      E.g., change this:
      https://github.com/openjdk/jdk/blame/9b11bd7f4a511ddadf9f02e82aab6ba78beb6763/src/hotspot/share/cds/filemap.cpp#L2181-L2183

      to this:
        char* base;
        if (MetaspaceShared::use_windows_memory_mapping()) {
          // new code for Windows - use read()
          if (!read_region(MetaspaceShared::hp, addr,
                           align_up(_mapped_heap_memregion.byte_size(), os::vm_page_size()),
                           /* do_commit = */ true)) {
            dealloc_heap_region();
            log_error(cds)("Failed to read archived heap region at " INTPTR_FORMAT, p2i(addr));
            return false;
          }
          base = addr;
        } else {
          // old code for all other platforms: use mmap().
          base = map_memory(_fd, _full_path, r->file_offset(),
                            addr, _mapped_heap_memregion.byte_size(), r->read_only(),
                            r->allow_exec());


      Attachments

        Issue Links

          Activity

            People

              iklam Ioi Lam
              iklam Ioi Lam
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: