JDK-8234930 : Use MAP_JIT when allocating pages for code cache on macOS
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11,14,17
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • Submitted: 2019-11-27
  • Updated: 2022-05-26
  • Resolved: 2020-12-15
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 11 JDK 17 JDK 8
11.0.15Fixed 17 b02Fixed 8u351Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
According to Apple documentation (e.g. https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_cs_allow-jit ) the MAP_JIT flag should be used when mmap:ing memory for JIT compilers. We should investigate if that flag can and should be used for the code cache.

On macOS MAP_JIT cannot be used in conjunction with MAP_FIXED when mapping
a page for codecache. Therefore our traditional technique of doing commit
and uncommit - replacing a mapping with another one at the same address
range but swapped MAP_NORESERVE - does not work.
The "exec" flag basically means "its code cache" and it should be used
consistently for the same mapping (reserve-commit-uncommit etc)
This affects pd_reserve_memory, pd_commit_memory, pd_uncommit_memory functions
Comments
Fix Request (11u): This patch is a strong prerequest for mac-aarch64 port. it was made slightly different to upstream patch so on platforms other than macos this patch equals to "nothing". It should be pretty safe for non-macos. Testing: GHA-tier1, SAP nightlies from Thomas Stuefe
11-12-2021

Changeset: 2273f955 Author: Anton Kozlov <akozlov@openjdk.org> Committer: Thomas Stuefe <stuefe@openjdk.org> Date: 2020-12-15 18:43:49 +0000 URL: https://git.openjdk.java.net/jdk/commit/2273f955
15-12-2020

RFR thread: https://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2020-August/041463.html
02-09-2020

MAP_JIT allows to codesign the java bundle without allow-unsigned-executable-memory entitlement, which can be considered as a robustness improvement.
27-08-2020