Repository navigation
Simplify frozen object heap allocation - #135956
Merged
MichalStrehovsky merged 3 commits intoOct 20, 2026
Merged
Conversation
WASM has no page protection or separate reserve/commit operations, so the Unix mmap(PROT_NONE)/mprotect implementation fails when reflection needs a frozen segment. Use aligned, zeroed native allocations with matching free, and make commit a no-op. Select the WASM partial implementation in NativeAOT CoreLib while leaving the Unix implementation unchanged elsewhere. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a6f3a617-acae-4f4f-95d3-20b2a0bac43c
Contributor
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
jkotas
reviewed
Oct 16, 2026
This was referenced Oct 16, 2026
Closed
Use ordinary zeroed native allocations across platforms and start frozen segments at 4 KB. Remove virtual-memory bookkeeping, platform partials, copied assertion comments, and the unused MProtect interop declaration. Exercise segment growth and compacting GC in the reflection smoke test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6dc84b16-c9f8-4272-be81-c459f49f6429
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The allocator rewrite changes desktop memory policy beyond the stated WASM-only scope without desktop validation.
1 open issue
What changed in this PR
Enables NativeAOT frozen-object allocation on WASM by replacing platform-specific virtual memory operations with shared zero-initialized native allocations.
Changes:
- Reworks segment allocation and removes reserve/commit helpers.
- Removes obsolete project entries and managed
MProtectinterop. - Adds reflection checks for dynamically created array types across forced garbage collection.
| File | Description |
|---|---|
| src/tests/nativeaot/SmokeTests/Reflection/Reflection.cs | Adds runtime-type identity and rank checks. |
| src/libraries/Common/src/Interop/Unix/System.Native/Interop.MProtect.cs | Removes managed protection interop. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj | Removes platform allocator includes. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/FrozenObjectHeapManager.Windows.cs | Removes Windows virtual-memory helpers. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/FrozenObjectHeapManager.Unix.cs | Removes Unix virtual-memory helpers. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/FrozenObjectHeapManager.cs | Uses shared zeroed allocations with smaller initial segments. |
Review effort: Balanced
jkotas
reviewed
Oct 19, 2026
Let NativeMemory.AllocZeroed propagate allocation failures instead of retrying with a smaller frozen segment. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6dc84b16-c9f8-4272-be81-c459f49f6429
jkotas
approved these changes
Oct 19, 2026
Member
Author
|
/ba-g timeout on wasm |
This was referenced Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

The use of this is more rare than on CoreCLR VM. The implementation can be simpler.