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

Remove os::remap_memory and simplify os::map_memory

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 23
    • 23
    • hotspot
    • None
    • b11

      We have `os::map_memory()` and `os::remap_memory()`.

      `os::map_memory()` maps a file, using mmap() on POSIX, MapViewOfFile() on Windows.

      (Note that the fact that `mmap()` is used on POSIX is (sort of) part of the contract since the way these APIs are used any other implementation (e.g. System V shm) incompatible.)

      We also have `os::remap_memory()`, which replaces an existing mapping with a new mapping.

      `os::remap_memory()` was introduced to transparently handle the fact that we cannot replace mappings on Windows. Here, we need to unmap the old mapping first, then map the new mapping. The original implementation of `os::remap_memory()` did just that.

      However, it turned out that this is not safe. Therefore, JDK-8222379 replaced the windows mechanism with a simple "ShouldNotReachHere". Since then, os::remap_memory is os::map_memory on POSIX systems, and it is not used at all on Windows.

      But since the implicit contract of `os::map_memory()` is to replace existing mappings - since it is using mmap() - there is no need for an explicit remapping function.

      Therefore os::remap_memory can be removed and its (one) caller be replaced with a call to os::map_memory. There are further simplification possibilities.

            stuefe Thomas Stuefe
            stuefe Thomas Stuefe
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: