Skip to content

Commit 306d407

Browse files
committed
chore: Simplify comments in MAP_JIT implementation
1 parent 59dca72 commit 306d407

File tree

2 files changed

+3
-18
lines changed

2 files changed

+3
-18
lines changed

cranelift/jit/src/memory/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ pub(crate) fn set_readable_and_executable(
7676
}
7777
}
7878

79-
// ARM64 macOS: Switch thread to execute mode for W^X enforcement.
80-
// pthread_jit_write_protect_np(1) switches the current thread
81-
// to "execute mode" where it can run JIT code (but not write to JIT memory).
82-
// This is Apple's W^X (Write XOR Execute) enforcement for MAP_JIT memory.
79+
// ARM64 macOS: Switch to execute mode for W^X compliance.
8380
#[cfg(all(target_arch = "aarch64", target_os = "macos"))]
8481
{
8582
unsafe extern "C" {

cranelift/jit/src/memory/system.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,7 @@ impl PtrLen {
5353
})
5454
}
5555

56-
/// macOS ARM64: Allocate JIT memory using mmap with MAP_JIT flag.
57-
///
58-
/// PROBLEM: Without MAP_JIT, JIT execution on Apple Silicon fails ~44% of the time.
59-
/// Standard allocators don't set MAP_JIT, causing non-deterministic crashes when
60-
/// threads execute JIT-compiled code.
61-
///
62-
/// SOLUTION: Use mmap directly with MAP_JIT (0x0800) to allocate memory that will
63-
/// become executable. This allows macOS to properly track the memory for W^X
64-
/// (Write XOR Execute) policy enforcement via pthread_jit_write_protect_np.
56+
/// macOS ARM64: Use mmap with MAP_JIT for W^X policy compliance.
6557
#[cfg(all(
6658
target_arch = "aarch64",
6759
target_os = "macos",
@@ -146,11 +138,7 @@ impl PtrLen {
146138

147139
// `MMapMut` from `cfg(feature = "selinux-fix")` already deallocates properly.
148140

149-
/// macOS ARM64: Deallocate MAP_JIT memory using munmap.
150-
///
151-
/// Memory allocated with mmap+MAP_JIT must be freed with munmap, not the
152-
/// standard allocator. We also reset protection to RW before unmapping
153-
/// to avoid potential issues with protected memory.
141+
/// macOS ARM64: Free MAP_JIT memory with munmap.
154142
#[cfg(all(
155143
target_arch = "aarch64",
156144
target_os = "macos",

0 commit comments

Comments
 (0)