cDAC test cleanup - Allocator adds HeapFragments by default#126780
Open
noahfalk wants to merge 1 commit intodotnet:mainfrom
Open
cDAC test cleanup - Allocator adds HeapFragments by default#126780noahfalk wants to merge 1 commit intodotnet:mainfrom
noahfalk wants to merge 1 commit intodotnet:mainfrom
Conversation
Previously the tests used a two step process of first using BumpAllocator to calculate a simulated address for a new HeapFragment, then separately calling Builder.AddHeapFragment() to store it. Now the allocator automatically stores all allocations eliminating the need for a 2nd call. This is follow up from the recent PR feedback asking to consolidate the AllocateAndAdd() helper. Removing the need for it entirely seemed cleaner. dotnet#126466 (comment)
Member
Author
Contributor
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR simplifies cDAC test setup by making MockMemorySpace.BumpAllocator automatically register each allocated HeapFragment with the owning MockMemorySpace.Builder, removing the need for many manual AddHeapFragment(s) calls across tests and mock descriptor builders.
Changes:
- Updated
MockMemorySpace.Builder.CreateAllocator/BumpAllocatorsoAllocateauto-registers fragments with the builder. - Removed redundant
AddHeapFragment/AddHeapFragmentscalls in tests and mock descriptor helpers that useBumpAllocator. - Deleted now-unnecessary
AllocateAndAddhelper methods in multiple mock builders.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/native/managed/cdac/tests/ThreadTests.cs | Removes manual fragment registration for exception handle allocations now covered by allocator auto-registration. |
| src/native/managed/cdac/tests/PrecodeStubsTests.cs | Removes redundant AddHeapFragment calls for allocator-backed precode/stub data allocations. |
| src/native/managed/cdac/tests/MockMemorySpace.cs | Updates CreateAllocator to construct a builder-bound allocator and documents auto-registration behavior. |
| src/native/managed/cdac/tests/MockMemorySpace.BumpAllocator.cs | Adds builder reference and registers each successful allocation via AddHeapFragment. |
| src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.Thread.cs | Removes AllocateAndAdd and redundant AddHeapFragments calls; relies on allocator registration. |
| src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.SyncBlock.cs | Removes AllocateAndAdd helper and redundant fragment registrations. |
| src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.RuntimeTypeSystem.cs | Removes manual AddHeapFragment after allocator allocations. |
| src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.RuntimeFunctions.cs | Removes AllocateAndAdd helper and uses allocator registration for runtime function/unwind allocations. |
| src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.ReJIT.cs | Removes redundant manual registration of allocator-produced fragments. |
| src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.Object.cs | Removes manual fragment registration for allocator-backed managed object allocations. |
| src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.MethodDescriptors.cs | Removes redundant AddHeapFragment calls after allocations. |
| src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.Loader.cs | Removes AllocateAndAdd helper and redundant fragment registrations for module/assembly/string allocations. |
| src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.HashMap.cs | Removes AllocateAndAdd helper and redundant fragment registration for hash map structures. |
| src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.GC.cs | Removes redundant manual registrations for GC allocator-backed globals/regions/tables. |
| src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.ExecutionManager.cs | Removes redundant fragment registrations for allocator-backed execution manager structures. |
| src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.CodeVersions.cs | Removes AllocateAndAdd helper and redundant registrations for code versioning nodes/states. |
| src/native/managed/cdac/tests/MockDescriptors/MockBuiltInComBuilder.cs | Removes AllocateAndAdd helper and redundant fragment registration for COM mock allocations. |
| src/native/managed/cdac/tests/MethodTableTests.cs | Removes manual registration of allocator-produced partial fragments used for E_INVALIDARG scenarios. |
| src/native/managed/cdac/tests/LoaderTests.cs | Removes redundant manual fragment registration in PE/Webcil image mock setup. |
| src/native/managed/cdac/tests/GCMemoryRegionTests.cs | Removes manual fragment registrations for allocator-based memory region graph construction. |
| src/native/managed/cdac/tests/DebuggerTests.cs | Removes redundant fragment registration for allocator-backed debugger globals/structures. |
| src/native/managed/cdac/tests/ClrDataExceptionStateTests.cs | Removes manual registration for allocator-backed exception handle fragments. |
| src/native/managed/cdac/tests/AuxiliarySymbolsTests.cs | Removes redundant fragment registrations for allocator-based helper/name data. |
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.
Previously the tests used a two step process of first using BumpAllocator to calculate a simulated address for a new HeapFragment, then separately calling Builder.AddHeapFragment() to store it. Now the allocator automatically stores all allocations eliminating the need for a 2nd call.
This is follow up from the recent PR feedback asking to consolidate the AllocateAndAdd() helper. Removing the need for it entirely seemed cleaner. #126466 (comment)