Delete ArrayEEClass - compute multidim array rank from BaseSize#124944
Delete ArrayEEClass - compute multidim array rank from BaseSize#124944
Conversation
|
Tagging subscribers to this area: @agocke |
…ns local static Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
…ay rank test Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
|
@copilot More feedback above |
...ged/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/RuntimeTypeSystem_1.cs
Outdated
Show resolved
Hide resolved
…ageDumper friends, remove redundant IsArray DAC block Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
…cdac Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
|
@max-charlamb PTLA - small data contract simplification that makes NativeAOT and CoreCLR more similar. Also, could you please take look at the runtime-diagnostics failures? They do not appear related to my change. |
There was a problem hiding this comment.
Pull request overview
Removes the redundant CoreCLR ArrayClass/ArrayEEClass (which only stored array rank) and derives multidimensional array rank from MethodTable::BaseSize, aligning CoreCLR with the existing NativeAOT approach. Updates cDAC (native + managed) and its tests to match the new layout/contract shape.
Changes:
- CoreCLR VM: delete
ArrayClass, refactor array helper methods to file-local statics, and computeMethodTable::GetRank()fromBaseSize. - cDAC: remove
ArrayClassdata/type usage and compute array rank fromBaseSize(plus a new exported global forARRAYBASE_BASESIZE). - Tests: adjust mock descriptors/object layout math and add coverage validating multidim rank derivation.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/vm/array.cpp | Refactors former ArrayClass helpers to static functions; allocates EEClass directly for arrays. |
| src/coreclr/vm/class.h | Removes ArrayClass definition; adds Module::CreateArrayMethodTable friend to allow placement-new EEClass. |
| src/coreclr/vm/classcompat.h | Removes ArrayClass forward decl. |
| src/coreclr/vm/ceeload.h | Removes NativeImageDumper friend declarations. |
| src/coreclr/vm/datadescriptor/datadescriptor.inc | Removes ArrayClass type; adds ArrayBaseSize global exporting ARRAYBASE_BASESIZE. |
| src/coreclr/vm/methodtable.cpp | Simplifies array casting logic and DAC memory enumeration now that ArrayClass is gone. |
| src/coreclr/vm/methodtable.h | Removes ArrayClass forward decl and NativeImageDumper friends. |
| src/coreclr/vm/methodtable.inl | Implements MethodTable::GetRank() using BaseSize - ARRAYBASE_BASESIZE. |
| src/coreclr/vm/object.inl | Computes lower-bounds offset using pMT->GetRank() directly. |
| src/coreclr/vm/vars.hpp | Removes ArrayClass forward decl. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/DataType.cs | Removes DataType.ArrayClass. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Constants.cs | Adds Globals.ArrayBaseSize. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/RuntimeTypeSystem_1.cs | Computes multidim rank from BaseSize using Globals.ArrayBaseSize. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/EEClass.cs | Deletes managed ArrayClass data reader. |
| src/native/managed/cdac/tests/ContractDescriptor/TargetTests.SubDescriptors.cs | Removes ArrayClass size-only descriptor entry. |
| src/native/managed/cdac/tests/MethodTableTests.cs | Adds ValidateMultidimArrayRank coverage for rank derivation. |
| src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.cs | Removes ArrayClassFields descriptor. |
| src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.Object.cs | Updates mock array BaseSize to encode rank for multidim arrays; uses EEClass directly. |
| src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.RuntimeTypeSystem.cs | Removes AddArrayClass; adds Globals.ArrayBaseSize to the mock target. |
| src/native/managed/cdac/tests/ObjectTests.cs | Updates expected multidim array data pointer to account for rank-encoded bounds in BaseSize. |
...ged/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/RuntimeTypeSystem_1.cs
Show resolved
Hide resolved
|
@copilot, please update RuntimeTypeSystem.md docs with the relevant changes. |
…bal, update IsArray pseudocode Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Done in 6e4b409. Updated |
|
@copilot , please fix the build break in |
max-charlamb
left a comment
There was a problem hiding this comment.
lgtm from a cDAC perspective once the cDAC unit tests pass CI
… test method Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Fixed in 0e7648e. The |
ArrayEEClass(ArrayClass) stored onlym_rank— a single byte redundant with information already encoded inMethodTable::m_baseSize. This PR removes the class entirely and derives rank from BaseSize, matching NativeAOT's approach.Changes
CoreCLR VM (C++)
class.h: RemoveArrayClassentirely. RemovePTR_ArrayClasstypedef (no longer needed). AddModule::CreateArrayMethodTableasfriendofEEClass(its constructor isprotected, and the function now calls::new (pMemory) EEClass()directly).methodtable.inl:MethodTable::GetRank()now computes rank from BaseSize:CreateArrayMethodTablesetsBaseSize = ARRAYBASE_BASESIZE + Rank * sizeof(DWORD) * 2forELEMENT_TYPE_ARRAY. TheDATA_ALIGNMENT > 4padding path on 32-bit is dead code on all supported platforms.array.cpp:GenerateArrayAccessorCallSigandInitArrayMethodDescbecome localstatic voidfunctions (wereArrayClassmembers). Allocation usessizeof(EEClass)andEEClass*directly;SetRank()call removed.object.inl:GetLowerBoundsOffsetusespMT->GetRank()directly.datadescriptor.inc: RemoveArrayClasstype block; addCDAC_GLOBAL(ArrayBaseSize, uint32, ARRAYBASE_BASESIZE).methodtable.cpp: Remove redundantif (IsArray())DAC memory enumeration block (now handled uniformly byEEClass::EnumMemoryRegions). Simplify array cast check to use!pTargetMT->IsMultiDimArray()instead ofGetInternalCorElementType() == ELEMENT_TYPE_SZARRAY.methodtable.h,ceeload.h: Delete allfriend class NativeImageDumper;declarations throughout the repo (4 occurrences).Managed cDAC
DataType.ArrayClass,Data.ArrayClass.RuntimeTypeSystem_1.IsArray()computes rank fromBaseSizeusing the newArrayBaseSizeglobal (Constants.Globals.ArrayBaseSize).cDAC Tests
ArrayClass; multidim arrayMethodTablemock now setsBaseSize = ArrayBaseSize + rank * 2 * sizeof(int)(previously always usedArrayBaseSize, which was inconsistent with the real runtime).ObjectTestsdata-pointer assertions updated: for a rank-R multidim array, data starts ataddress + ArrayBaseSize + R * 2 * sizeof(int).ValidateMultidimArrayRanktest (as a[Theory]over all standard architectures) directly verifyingIsArray()returns correct rank (4 and 1) from BaseSize.Documentation
docs/design/datacontracts/RuntimeTypeSystem.md: Removed theArrayClass | Rankdata descriptor row, addedArrayBaseSizeto the globals table, and updated theIsArraypseudocode to derive multidimensional array rank fromBaseSizeinstead of reading fromArrayClass.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.