Support DualMapAllocator on aarch64 macOS, and add MapJITAllocator #60117
+68
−13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In conjunction with #60105, this change brings our optimized memory management over to aarch64 macOS, where JITLink is the only supported linker.
First, this changes the way we test for
DualMapAllocatorsupport so that it will be selected on macOS again. We are not allowed tommapRXMAP_SHAREDpages directly, but it's okay tommapwith no protections andmprotectafterwards, so test for that.However, when it is supported, we always prefer to use the new
MapJITAllocatorfor executable pages.MapJITAllocatorusesMAP_JITpages, which are "seen" by every thread as either RX or RW, according to the value of a special thread-local register. When we use this allocator, only a single mapping is required, no copies are necessary when JITting, and nomprotectsyscalls are necessary to finalize the code. Other threads can continue to execute code in theMAP_JITregion while we write to it, since only the thread that is JITting has thejit_rwflag enabled.Bootstrapping sees about a ~10% reduction in peak RSS and run time, with bigger improvements on very JIT-heavy workloads.