JDK-8326067 : Remove os::remap_memory and simplify os::map_memory
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 23
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-02-16
  • Updated: 2024-02-27
  • Resolved: 2024-02-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 23
23 b11Fixed
Related Reports
Relates :  
Relates :  
Description
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.
Comments
Changeset: 20a25f60 Author: Thomas Stuefe <stuefe@openjdk.org> Date: 2024-02-19 19:33:07 +0000 URL: https://git.openjdk.org/jdk/commit/20a25f60ea56ecd28da1ab377f8f2ca8b2098a3b
19-02-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/17893 Date: 2024-02-16 17:15:44 +0000
17-02-2024