[cDAC] Changing loader heaps from string-keyed to enum-keyed dict#127474
[cDAC] Changing loader heaps from string-keyed to enum-keyed dict#127474rcj1 wants to merge 1 commit intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
| public enum LoaderAllocatorHeapType : uint | ||
| { | ||
| LowFrequency = 0, | ||
| HighFrequency = 1, | ||
| Statics = 2, | ||
| Stub = 3, | ||
| Executable = 4, | ||
| FixupPrecode = 5, | ||
| NewStubPrecode = 6, | ||
| DynamicHelpers = 7, | ||
| Indcell = 8, | ||
| CacheEntry = 9, | ||
| } |
There was a problem hiding this comment.
Any reason to explicitly define the size of this enum and values? The flags above do, but given this is a true managed enum, I don't think we need to.
|
|
||
| public enum LoaderAllocatorHeapType : uint | ||
| { | ||
| LowFrequency = 0, |
There was a problem hiding this comment.
Maybe reserve 0 for an Unknown type in case there is something added in the future?
| { | ||
| for (int i = 0; i < loaderHeapCount; i++) | ||
| int i = 0; | ||
| foreach (LoaderAllocatorHeapType heapType in Enum.GetValues<LoaderAllocatorHeapType>()) |
There was a problem hiding this comment.
There was a problem hiding this comment.
So we'd have something like heaps.TryGetValue(GetEnumForFilteredEntry(filteredEntries[i].Name)?
| ClrDataAddress* heaps = stackalloc ClrDataAddress[MockHeapDictionary.Count]; | ||
| int* kinds = stackalloc int[MockHeapDictionary.Count]; | ||
| int hr = impl.GetLoaderAllocatorHeaps(new ClrDataAddress(0x100), MockHeapDictionary.Count, heaps, kinds, &needed); | ||
|
|
||
| Assert.Equal(HResults.S_OK, hr); | ||
| Assert.Equal(MockHeapDictionary.Count, needed); | ||
| for (int i = 0; i < needed; i++) | ||
| int i = 0; | ||
| foreach (LoaderAllocatorHeapType heapType in Enum.GetValues<LoaderAllocatorHeapType>()) | ||
| { | ||
| string name = Marshal.PtrToStringAnsi((nint)names[i])!; | ||
| Assert.Equal((ulong)MockHeapDictionary[name], (ulong)heaps[i]); | ||
| Assert.Equal(0, kinds[i]); // LoaderHeapKindNormal | ||
| if (MockHeapDictionary.TryGetValue(heapType, out TargetPointer expected)) | ||
| { | ||
| Assert.Equal((ulong)expected, (ulong)heaps[i]); | ||
| Assert.Equal(0, kinds[i]); // LoaderHeapKindNormal | ||
| i++; | ||
| } |
There was a problem hiding this comment.
Please revert this unit test. We should verify that it matches the heap names, not the enum.
Follow-up to #127296 (comment)