-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Disable server GC and background GC for CoreCLR WebAssembly builds #127178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e85d3f7
b5b5b6d
806547f
dc7b9f9
c6d22cb
b5305fa
ce4977d
dbf2e93
d4d8bf3
b0d22b5
0bb61e6
7dad94d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,10 +152,10 @@ public readonly struct GCMemoryRegionData | |
| Data descriptors used: | ||
| | Data Descriptor Name | Field | Source | Meaning | | ||
| | --- | --- | --- | --- | | ||
| | `GCHeap` | MarkArray | GC | Pointer to the heap's MarkArray (in sever builds) | | ||
| | `GCHeap` | NextSweepObj | GC | Pointer to the heap's NextSweepObj (in sever builds) | | ||
| | `GCHeap` | BackgroundMinSavedAddr | GC | Heap's background saved lowest address (in sever builds) | | ||
| | `GCHeap` | BackgroundMaxSavedAddr | GC | Heap's background saved highest address (in sever builds) | | ||
| | `GCHeap` | MarkArray | GC | Pointer to the heap's MarkArray (only in server builds with background GC) | | ||
| | `GCHeap` | NextSweepObj | GC | Pointer to the heap's NextSweepObj (only in server builds with background GC) | | ||
| | `GCHeap` | BackgroundMinSavedAddr | GC | Heap's background saved lowest address (only in server builds with background GC) | | ||
| | `GCHeap` | BackgroundMaxSavedAddr | GC | Heap's background saved highest address (only in server builds with background GC) | | ||
| | `GCHeap` | AllocAllocated | GC | Heap's highest address allocated by Alloc (in sever builds) | | ||
| | `GCHeap` | EphemeralHeapSegment | GC | Pointer to the heap's ephemeral heap segment (in sever builds) | | ||
| | `GCHeap` | CardTable | GC | Pointer to the heap's bookkeeping GC data structure (in sever builds) | | ||
|
|
@@ -229,10 +229,10 @@ Global variables used: | |
| | `CompactReasonsLength` | uint | GC | The number of elements in the `CompactReasons` array | | ||
| | `ExpandMechanismsLength` | uint | GC | The number of elements in the `ExpandMechanisms` array | | ||
| | `InterestingMechanismBitsLength` | uint | GC | The number of elements in the `InterestingMechanismBits` array | | ||
| | `GCHeapMarkArray` | TargetPointer | GC | Pointer to the static heap's MarkArray (in workstation builds) | | ||
| | `GCHeapNextSweepObj` | TargetPointer | GC | Pointer to the static heap's NextSweepObj (in workstation builds) | | ||
| | `GCHeapBackgroundMinSavedAddr` | TargetPointer | GC | Background saved lowest address (in workstation builds) | | ||
| | `GCHeapBackgroundMaxSavedAddr` | TargetPointer | GC | Background saved highest address (in workstation builds) | | ||
| | `GCHeapMarkArray` | TargetPointer | GC | Pointer to the static heap's MarkArray (in workstation builds with background GC) | | ||
| | `GCHeapNextSweepObj` | TargetPointer | GC | Pointer to the static heap's NextSweepObj (in workstation builds with background GC) | | ||
| | `GCHeapBackgroundMinSavedAddr` | TargetPointer | GC | Background saved lowest address (in workstation builds with background GC) | | ||
| | `GCHeapBackgroundMaxSavedAddr` | TargetPointer | GC | Background saved highest address (in workstation builds with background GC) | | ||
|
Comment on lines
+232
to
+235
|
||
| | `GCHeapAllocAllocated` | TargetPointer | GC | Highest address allocated by Alloc (in workstation builds) | | ||
| | `GCHeapEphemeralHeapSegment` | TargetPointer | GC | Pointer to an ephemeral heap segment (in workstation builds) | | ||
| | `GCHeapCardTable` | TargetPointer | GC | Pointer to the static heap's bookkeeping GC data structure (in workstation builds) | | ||
|
|
@@ -454,11 +454,39 @@ GCHeapData IGC.GetHeapData() | |
|
|
||
| GCHeapData data; | ||
|
|
||
| // Read fields directly from globals | ||
| data.MarkArray = target.ReadPointer(target.ReadGlobalPointer("GCHeapMarkArray")); | ||
| data.NextSweepObj = target.ReadPointer(target.ReadGlobalPointer("GCHeapNextSweepObj")); | ||
| data.BackgroundMinSavedAddr = target.ReadPointer(target.ReadGlobalPointer("GCHeapBackgroundMinSavedAddr")); | ||
| data.BackgroundMaxSavedAddr = target.ReadPointer(target.ReadGlobalPointer("GCHeapBackgroundMaxSavedAddr")); | ||
| // Read background GC globals - these are absent when background GC is disabled (e.g., on WebAssembly). | ||
| if (target.TryReadGlobalPointer("GCHeapMarkArray", out TargetPointer? markArrayPtr)) | ||
| { | ||
| data.MarkArray = target.ReadPointer(markArrayPtr.Value); | ||
| } | ||
| else | ||
| { | ||
| data.MarkArray = 0; | ||
| } | ||
| if (target.TryReadGlobalPointer("GCHeapNextSweepObj", out TargetPointer? nextSweepObjPtr)) | ||
| { | ||
| data.NextSweepObj = target.ReadPointer(nextSweepObjPtr.Value); | ||
| } | ||
| else | ||
| { | ||
| data.NextSweepObj = 0; | ||
| } | ||
| if (target.TryReadGlobalPointer("GCHeapBackgroundMinSavedAddr", out TargetPointer? bgMinPtr)) | ||
| { | ||
| data.BackgroundMinSavedAddr = target.ReadPointer(bgMinPtr.Value); | ||
| } | ||
| else | ||
| { | ||
| data.BackgroundMinSavedAddr = 0; | ||
| } | ||
| if (target.TryReadGlobalPointer("GCHeapBackgroundMaxSavedAddr", out TargetPointer? bgMaxPtr)) | ||
| { | ||
| data.BackgroundMaxSavedAddr = target.ReadPointer(bgMaxPtr.Value); | ||
| } | ||
| else | ||
| { | ||
| data.BackgroundMaxSavedAddr = 0; | ||
| } | ||
| data.AllocAllocated = target.ReadPointer(target.ReadGlobalPointer("GCHeapAllocAllocated")); | ||
| data.EphemeralHeapSegment = target.ReadPointer(target.ReadGlobalPointer("GCHeapEphemeralHeapSegment")); | ||
| data.CardTable = target.ReadPointer(target.ReadGlobalPointer("GCHeapCardTable")); | ||
|
|
@@ -521,11 +549,41 @@ GCHeapData IGC.GetHeapData(TargetPointer heapAddress) | |
|
|
||
| GCHeapData data; | ||
|
|
||
| // Read fields directly from heap | ||
| data.MarkArray = target.ReadPointer(heapAddress + /* GCHeap::MarkArray offset */); | ||
| data.NextSweepObj = target.ReadPointer(heapAddress + /* GCHeap::NextSweepObj offset */); | ||
| data.BackgroundMinSavedAddr = target.ReadPointer(heapAddress + /* GCHeap::BackgroundMinSavedAddr offset */); | ||
| data.BackgroundMaxSavedAddr = target.ReadPointer(heapAddress + /* GCHeap::BackgroundMaxSavedAddr offset */); | ||
| // Read background GC heap fields - these fields are absent when background GC is disabled (e.g., on WebAssembly). | ||
| // Check whether the field exists in the type layout before reading; default to 0 if not present. | ||
| Target.TypeInfo gcHeapType = target.GetTypeInfo(DataType.GCHeap); | ||
| if (gcHeapType.Fields.ContainsKey("MarkArray")) | ||
| { | ||
| data.MarkArray = target.ReadPointer(heapAddress + /* GCHeap::MarkArray offset */); | ||
| } | ||
| else | ||
| { | ||
| data.MarkArray = 0; | ||
| } | ||
| if (gcHeapType.Fields.ContainsKey("NextSweepObj")) | ||
| { | ||
| data.NextSweepObj = target.ReadPointer(heapAddress + /* GCHeap::NextSweepObj offset */); | ||
| } | ||
| else | ||
| { | ||
| data.NextSweepObj = 0; | ||
| } | ||
| if (gcHeapType.Fields.ContainsKey("BackgroundMinSavedAddr")) | ||
| { | ||
| data.BackgroundMinSavedAddr = target.ReadPointer(heapAddress + /* GCHeap::BackgroundMinSavedAddr offset */); | ||
| } | ||
| else | ||
| { | ||
| data.BackgroundMinSavedAddr = 0; | ||
| } | ||
| if (gcHeapType.Fields.ContainsKey("BackgroundMaxSavedAddr")) | ||
| { | ||
| data.BackgroundMaxSavedAddr = target.ReadPointer(heapAddress + /* GCHeap::BackgroundMaxSavedAddr offset */); | ||
| } | ||
| else | ||
| { | ||
| data.BackgroundMaxSavedAddr = 0; | ||
| } | ||
| data.AllocAllocated = target.ReadPointer(heapAddress + /* GCHeap::AllocAllocated offset */); | ||
| data.EphemeralHeapSegment = target.ReadPointer(heapAddress + /* GCHeap::EphemeralHeapSegment offset */); | ||
| data.CardTable = target.ReadPointer(heapAddress + /* GCHeap::CardTable offset */); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -173,10 +173,10 @@ endif (CLR_CMAKE_HOST_UNIX AND CLR_CMAKE_TARGET_UNIX) | |
| if (FEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION) | ||
| add_definitions(-DFEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION) | ||
| endif(FEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION) | ||
| if (NOT CLR_CMAKE_HOST_ANDROID) | ||
| if (NOT CLR_CMAKE_HOST_ANDROID AND NOT CLR_CMAKE_TARGET_ARCH_WASM AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) | ||
| set(FEATURE_SVR_GC 1) | ||
| add_definitions(-DFEATURE_SVR_GC) | ||
| endif(NOT CLR_CMAKE_HOST_ANDROID) | ||
| endif(NOT CLR_CMAKE_HOST_ANDROID AND NOT CLR_CMAKE_TARGET_ARCH_WASM AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) | ||
|
Comment on lines
+176
to
+179
|
||
| add_definitions(-DFEATURE_SYMDIFF) | ||
|
|
||
| if (FEATURE_TIERED_COMPILATION) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -170,10 +170,10 @@ private GCHeapData GetGCHeapDataFromHeap(IGCHeap heap) | |
|
|
||
| return new GCHeapData() | ||
| { | ||
| MarkArray = heap.MarkArray, | ||
| NextSweepObject = heap.NextSweepObj, | ||
| BackGroundSavedMinAddress = heap.BackgroundMinSavedAddr, | ||
| BackGroundSavedMaxAddress = heap.BackgroundMaxSavedAddr, | ||
| MarkArray = heap.MarkArray ?? TargetPointer.Null, | ||
| NextSweepObject = heap.NextSweepObj ?? TargetPointer.Null, | ||
| BackGroundSavedMinAddress = heap.BackgroundMinSavedAddr ?? TargetPointer.Null, | ||
| BackGroundSavedMaxAddress = heap.BackgroundMaxSavedAddr ?? TargetPointer.Null, | ||
|
Comment on lines
+173
to
+176
|
||
| AllocAllocated = heap.AllocAllocated, | ||
| EphemeralHeapSegment = heap.EphemeralHeapSegment, | ||
| CardTable = heap.CardTable, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updated availability notes correctly call out background GC for MarkArray/NextSweepObj/Background* fields. For consistency with the descriptor changes, please also update the SavedSweepEphemeralSeg/SavedSweepEphemeralStart entries later in this table to mention they’re absent when BACKGROUND_GC is disabled as well (not just when segment GC is unavailable).