From 2cd2916df8d361fd7db198ddafacb93c60a64235 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 13 Apr 2026 21:29:19 +0000 Subject: [PATCH 1/6] Implement RequiresAlign8 in cDAC end-to-end Add RequiresAlign8 = 0x00800000 to WFLAGS_HIGH in MethodTableFlags_1.cs, add bool RequiresAlign8(TypeHandle) to IRuntimeTypeSystem interface, implement it in RuntimeTypeSystem_1.cs following ContainsGCPointers pattern, replace legacy-delegation stub in DacDbiImpl.cs with full implementation following IsValueType pattern including #if DEBUG legacy validation, and add unit tests covering both flag-set and flag-unset cases. Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/ace0eac0-7c85-43f8-8a5e-71227ee36e84 Co-authored-by: barosiak <76071368+barosiak@users.noreply.github.com> --- .../Contracts/IRuntimeTypeSystem.cs | 2 + .../Contracts/RuntimeTypeSystem_1.cs | 1 + .../MethodTableFlags_1.cs | 2 + .../Dbi/DacDbiImpl.cs | 26 +++++++++++- .../managed/cdac/tests/MethodTableTests.cs | 41 +++++++++++++++++++ 5 files changed, 71 insertions(+), 1 deletion(-) diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeTypeSystem.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeTypeSystem.cs index 624edbe5eebaac..1f6c7f9bde9466 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeTypeSystem.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeTypeSystem.cs @@ -117,6 +117,8 @@ public interface IRuntimeTypeSystem : IContract bool IsString(TypeHandle typeHandle) => throw new NotImplementedException(); // True if the MethodTable represents a type that contains managed references bool ContainsGCPointers(TypeHandle typeHandle) => throw new NotImplementedException(); + // True if the type requires 8-byte alignment (FEATURE_64BIT_ALIGNMENT) + bool RequiresAlign8(TypeHandle typeHandle) => throw new NotImplementedException(); // True if the MethodTable represents a continuation type used by the async continuation feature bool IsContinuation(TypeHandle typeHandle) => throw new NotImplementedException(); bool IsDynamicStatics(TypeHandle typeHandle) => throw new NotImplementedException(); diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/RuntimeTypeSystem_1.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/RuntimeTypeSystem_1.cs index a0eb76b9f0d484..496f64f2608b92 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/RuntimeTypeSystem_1.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/RuntimeTypeSystem_1.cs @@ -551,6 +551,7 @@ private Data.EEClass GetClassData(TypeHandle typeHandle) public bool IsString(TypeHandle typeHandle) => !typeHandle.IsMethodTable() ? false : _methodTables[typeHandle.Address].Flags.IsString; public bool ContainsGCPointers(TypeHandle typeHandle) => !typeHandle.IsMethodTable() ? false : _methodTables[typeHandle.Address].Flags.ContainsGCPointers; + public bool RequiresAlign8(TypeHandle typeHandle) => !typeHandle.IsMethodTable() ? false : _methodTables[typeHandle.Address].Flags.RequiresAlign8; public bool IsContinuation(TypeHandle typeHandle) => typeHandle.IsMethodTable() && _continuationMethodTablePointer != TargetPointer.Null && _methodTables[typeHandle.Address].ParentMethodTable == _continuationMethodTablePointer; diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/RuntimeTypeSystemHelpers/MethodTableFlags_1.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/RuntimeTypeSystemHelpers/MethodTableFlags_1.cs index afae8767548dd9..e3c62423210ac1 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/RuntimeTypeSystemHelpers/MethodTableFlags_1.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/RuntimeTypeSystemHelpers/MethodTableFlags_1.cs @@ -45,6 +45,7 @@ internal enum WFLAGS_HIGH : uint Category_TruePrimitive = 0x00070000, Category_Interface = 0x000C0000, Collectible = 0x00200000, // GC depends on this bit. + RequiresAlign8 = 0x00800000, // Type requires 8-byte alignment (FEATURE_64BIT_ALIGNMENT) ContainsGCPointers = 0x01000000, ContainsGenericVariables = 0x20000000, @@ -99,6 +100,7 @@ private bool TestFlagWithMask(WFLAGS2_ENUM mask, WFLAGS2_ENUM flag) public ushort ComponentSize => HasComponentSize ? ComponentSizeBits : (ushort)0; public bool HasInstantiation => !TestFlagWithMask(WFLAGS_LOW.GenericsMask, WFLAGS_LOW.GenericsMask_NonGeneric); public bool ContainsGCPointers => GetFlag(WFLAGS_HIGH.ContainsGCPointers) != 0; + public bool RequiresAlign8 => GetFlag(WFLAGS_HIGH.RequiresAlign8) != 0; public bool IsCollectible => GetFlag(WFLAGS_HIGH.Collectible) != 0; public bool IsDynamicStatics => GetFlag(WFLAGS2_ENUM.DynamicStatics) != 0; public bool IsGenericTypeDefinition => TestFlagWithMask(WFLAGS_LOW.GenericsMask, WFLAGS_LOW.GenericsMask_TypicalInstantiation); diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs index 95fdef60493597..3d304c816cf347 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs @@ -638,7 +638,31 @@ public int GetVarArgSig(ulong VASigCookieAddr, ulong* pArgBase, DacDbiTargetBuff => _legacy is not null ? _legacy.GetVarArgSig(VASigCookieAddr, pArgBase, pRetVal) : HResults.E_NOTIMPL; public int RequiresAlign8(ulong thExact, Interop.BOOL* pResult) - => _legacy is not null ? _legacy.RequiresAlign8(thExact, pResult) : HResults.E_NOTIMPL; + { + *pResult = Interop.BOOL.FALSE; + int hr = HResults.S_OK; + try + { + Contracts.IRuntimeTypeSystem rts = _target.Contracts.RuntimeTypeSystem; + Contracts.TypeHandle th = rts.GetTypeHandle(new TargetPointer(thExact)); + *pResult = rts.RequiresAlign8(th) ? Interop.BOOL.TRUE : Interop.BOOL.FALSE; + } + catch (System.Exception ex) + { + hr = ex.HResult; + } +#if DEBUG + if (_legacy is not null) + { + Interop.BOOL resultLocal; + int hrLocal = _legacy.RequiresAlign8(thExact, &resultLocal); + Debug.ValidateHResult(hr, hrLocal); + if (hr == HResults.S_OK) + Debug.Assert(*pResult == resultLocal, $"cDAC: {*pResult}, DAC: {resultLocal}"); + } +#endif + return hr; + } public int ResolveExactGenericArgsToken(uint dwExactGenericArgsTokenIndex, ulong rawToken, ulong* pRetVal) => _legacy is not null ? _legacy.ResolveExactGenericArgsToken(dwExactGenericArgsTokenIndex, rawToken, pRetVal) : HResults.E_NOTIMPL; diff --git a/src/native/managed/cdac/tests/MethodTableTests.cs b/src/native/managed/cdac/tests/MethodTableTests.cs index 62c16a9fac486f..94e93dda1031ba 100644 --- a/src/native/managed/cdac/tests/MethodTableTests.cs +++ b/src/native/managed/cdac/tests/MethodTableTests.cs @@ -501,4 +501,45 @@ public void ValidateContinuationMethodTablePointer(MockTarget.Architecture arch) Assert.Equal(continuationInstanceMethodTablePtr.Value, continuationTypeHandle.Address.Value); Assert.True(contract.IsContinuation(continuationTypeHandle)); } + + [Theory] + [ClassData(typeof(MockTarget.StdArch))] + public void RequiresAlign8_FlagSet_ReturnsTrue(MockTarget.Architecture arch) + { + TargetPointer methodTablePtr = default; + TestPlaceholderTarget target = CreateTarget( + arch, + rtsBuilder => + { + MockEEClass eeClass = rtsBuilder.AddEEClass("Align8Type"); + eeClass.CorTypeAttr = (uint)(System.Reflection.TypeAttributes.Public | System.Reflection.TypeAttributes.Class); + + MockMethodTable methodTable = rtsBuilder.AddMethodTable("Align8Type"); + methodTable.MTFlags = (uint)MethodTableFlags_1.WFLAGS_HIGH.RequiresAlign8; + methodTable.BaseSize = rtsBuilder.Builder.TargetTestHelpers.ObjectBaseSize; + methodTable.ParentMethodTable = rtsBuilder.SystemObjectMethodTable.Address; + methodTable.NumVirtuals = 3; + methodTablePtr = methodTable.Address; + eeClass.MethodTable = methodTable.Address; + methodTable.EEClassOrCanonMT = eeClass.Address; + }); + + IRuntimeTypeSystem contract = target.Contracts.RuntimeTypeSystem; + Contracts.TypeHandle typeHandle = contract.GetTypeHandle(methodTablePtr); + Assert.True(contract.RequiresAlign8(typeHandle)); + } + + [Theory] + [ClassData(typeof(MockTarget.StdArch))] + public void RequiresAlign8_FlagUnset_ReturnsFalse(MockTarget.Architecture arch) + { + TargetPointer systemObjectMethodTablePtr = default; + TestPlaceholderTarget target = CreateTarget( + arch, + rtsBuilder => systemObjectMethodTablePtr = rtsBuilder.SystemObjectMethodTable.Address); + + IRuntimeTypeSystem contract = target.Contracts.RuntimeTypeSystem; + Contracts.TypeHandle typeHandle = contract.GetTypeHandle(systemObjectMethodTablePtr); + Assert.False(contract.RequiresAlign8(typeHandle)); + } } From 7c1c2a0e78bde68548b552bce147ea734d260868 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 13 Apr 2026 21:30:22 +0000 Subject: [PATCH 2/6] Use combined flags in RequiresAlign8 test for realistic scenario Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/ace0eac0-7c85-43f8-8a5e-71227ee36e84 Co-authored-by: barosiak <76071368+barosiak@users.noreply.github.com> --- src/native/managed/cdac/tests/MethodTableTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/managed/cdac/tests/MethodTableTests.cs b/src/native/managed/cdac/tests/MethodTableTests.cs index 94e93dda1031ba..f0b18f0e6c046e 100644 --- a/src/native/managed/cdac/tests/MethodTableTests.cs +++ b/src/native/managed/cdac/tests/MethodTableTests.cs @@ -515,7 +515,7 @@ public void RequiresAlign8_FlagSet_ReturnsTrue(MockTarget.Architecture arch) eeClass.CorTypeAttr = (uint)(System.Reflection.TypeAttributes.Public | System.Reflection.TypeAttributes.Class); MockMethodTable methodTable = rtsBuilder.AddMethodTable("Align8Type"); - methodTable.MTFlags = (uint)MethodTableFlags_1.WFLAGS_HIGH.RequiresAlign8; + methodTable.MTFlags = (uint)(MethodTableFlags_1.WFLAGS_HIGH.Category_ValueType | MethodTableFlags_1.WFLAGS_HIGH.RequiresAlign8); methodTable.BaseSize = rtsBuilder.Builder.TargetTestHelpers.ObjectBaseSize; methodTable.ParentMethodTable = rtsBuilder.SystemObjectMethodTable.Address; methodTable.NumVirtuals = 3; From e9718040cdc42835d35db685f220948bc471f328 Mon Sep 17 00:00:00 2001 From: Barbara Rosiak Date: Tue, 14 Apr 2026 17:25:28 -0700 Subject: [PATCH 3/6] Add missing docs, style changes --- .../design/datacontracts/RuntimeTypeSystem.md | 6 ++ src/coreclr/vm/methodtable.h | 2 +- .../MethodTableFlags_1.cs | 2 +- .../managed/cdac/tests/MethodTableTests.cs | 58 ++++++++++--------- 4 files changed, 38 insertions(+), 30 deletions(-) diff --git a/docs/design/datacontracts/RuntimeTypeSystem.md b/docs/design/datacontracts/RuntimeTypeSystem.md index ff1d0cd2d08af7..bdec8adc615b42 100644 --- a/docs/design/datacontracts/RuntimeTypeSystem.md +++ b/docs/design/datacontracts/RuntimeTypeSystem.md @@ -54,6 +54,8 @@ partial interface IRuntimeTypeSystem : IContract public virtual bool IsString(TypeHandle typeHandle); // True if the MethodTable represents a type that contains managed references public virtual bool ContainsGCPointers(TypeHandle typeHandle); + // True if the type requires 8-byte alignment (FEATURE_64BIT_ALIGNMENT) + public virtual bool RequiresAlign8(TypeHandle typeHandle); // True if the MethodTable represents a continuation type used by the async continuation feature public virtual bool IsContinuation(TypeHandle typeHandle); public virtual bool IsDynamicStatics(TypeHandle typeHandle); @@ -273,6 +275,7 @@ internal partial struct RuntimeTypeSystem_1 Category_TruePrimitive = 0x00070000, Category_Interface = 0x000C0000, Collectible = 0x00200000, + RequiresAlign8 = 0x00800000, ContainsGCPointers = 0x01000000, ContainsGenericVariables = 0x20000000, HasComponentSize = 0x80000000, // This is set if lower 16 bits is used for the component size, @@ -319,6 +322,7 @@ internal partial struct RuntimeTypeSystem_1 public ushort ComponentSize => HasComponentSize ? ComponentSizeBits : (ushort)0; public bool HasInstantiation => !TestFlagWithMask(WFLAGS_LOW.GenericsMask, WFLAGS_LOW.GenericsMask_NonGeneric); public bool ContainsGCPointers => GetFlag(WFLAGS_HIGH.ContainsGCPointers) != 0; + public bool RequiresAlign8 => GetFlag(WFLAGS_HIGH.RequiresAlign8) != 0; public bool IsCollectible => GetFlag(WFLAGS_HIGH.Collectible) != 0; public bool IsDynamicStatics => GetFlag(WFLAGS2_ENUM.DynamicStatics) != 0; public bool IsGenericTypeDefinition => TestFlagWithMask(WFLAGS_LOW.GenericsMask, WFLAGS_LOW.GenericsMask_TypicalInstantiation); @@ -540,6 +544,8 @@ Contracts used: public bool ContainsGCPointers(TypeHandle TypeHandle) => !typeHandle.IsMethodTable() ? false : _methodTables[TypeHandle.Address].Flags.ContainsGCPointers; + public bool RequiresAlign8(TypeHandle TypeHandle) => !typeHandle.IsMethodTable() ? false : _methodTables[TypeHandle.Address].Flags.RequiresAlign8; + public bool IsDynamicStatics(TypeHandle TypeHandle) => !typeHandle.IsMethodTable() ? false : _methodTables[TypeHandle.Address].Flags.IsDynamicStatics; public ushort GetNumInterfaces(TypeHandle TypeHandle) => !typeHandle.IsMethodTable() ? 0 : _methodTables[TypeHandle.Address].NumInterfaces; diff --git a/src/coreclr/vm/methodtable.h b/src/coreclr/vm/methodtable.h index 8001f1a4597592..88cd6ceacbb1ae 100644 --- a/src/coreclr/vm/methodtable.h +++ b/src/coreclr/vm/methodtable.h @@ -3813,7 +3813,7 @@ public : // enum_flag_unused = 0x00400000, #ifdef FEATURE_64BIT_ALIGNMENT - enum_flag_RequiresAlign8 = 0x00800000, // Type requires 8-byte alignment (only set on platforms that require this and don't get it implicitly) + enum_flag_RequiresAlign8 = 0x00800000, // Type requires 8-byte alignment (only set on platforms that require this and don't get it implicitly) [cDAC] [RuntimeTypeSystem]: Contract depends on this value #endif enum_flag_ContainsGCPointers = 0x01000000, // Contains object references. [cDAC] [RuntimeTypeSystem]: Contract depends on this value diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/RuntimeTypeSystemHelpers/MethodTableFlags_1.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/RuntimeTypeSystemHelpers/MethodTableFlags_1.cs index e3c62423210ac1..e89084b3598f4f 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/RuntimeTypeSystemHelpers/MethodTableFlags_1.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/RuntimeTypeSystemHelpers/MethodTableFlags_1.cs @@ -45,7 +45,7 @@ internal enum WFLAGS_HIGH : uint Category_TruePrimitive = 0x00070000, Category_Interface = 0x000C0000, Collectible = 0x00200000, // GC depends on this bit. - RequiresAlign8 = 0x00800000, // Type requires 8-byte alignment (FEATURE_64BIT_ALIGNMENT) + RequiresAlign8 = 0x00800000, ContainsGCPointers = 0x01000000, ContainsGenericVariables = 0x20000000, diff --git a/src/native/managed/cdac/tests/MethodTableTests.cs b/src/native/managed/cdac/tests/MethodTableTests.cs index f0b18f0e6c046e..6a60b3a914428b 100644 --- a/src/native/managed/cdac/tests/MethodTableTests.cs +++ b/src/native/managed/cdac/tests/MethodTableTests.cs @@ -38,6 +38,15 @@ internal static (string Name, ulong Value)[] CreateContractGlobals(MockRTS rtsBu (nameof(Constants.Globals.ArrayBaseSize), rtsBuilder.ArrayBaseSize), ]; + public static IEnumerable StdArchBool() + { + foreach (object[] arch in new MockTarget.StdArch()) + { + yield return [.. arch, true]; + yield return [.. arch, false]; + } + } + internal static TestPlaceholderTarget CreateTarget(MockTarget.Architecture arch, Action configure) { var targetBuilder = new TestPlaceholderTarget.Builder(arch); @@ -503,43 +512,36 @@ public void ValidateContinuationMethodTablePointer(MockTarget.Architecture arch) } [Theory] - [ClassData(typeof(MockTarget.StdArch))] - public void RequiresAlign8_FlagSet_ReturnsTrue(MockTarget.Architecture arch) + [MemberData(nameof(StdArchBool))] + public void RequiresAlign8(MockTarget.Architecture arch, bool flagSet) { TargetPointer methodTablePtr = default; TestPlaceholderTarget target = CreateTarget( arch, rtsBuilder => { - MockEEClass eeClass = rtsBuilder.AddEEClass("Align8Type"); - eeClass.CorTypeAttr = (uint)(System.Reflection.TypeAttributes.Public | System.Reflection.TypeAttributes.Class); - - MockMethodTable methodTable = rtsBuilder.AddMethodTable("Align8Type"); - methodTable.MTFlags = (uint)(MethodTableFlags_1.WFLAGS_HIGH.Category_ValueType | MethodTableFlags_1.WFLAGS_HIGH.RequiresAlign8); - methodTable.BaseSize = rtsBuilder.Builder.TargetTestHelpers.ObjectBaseSize; - methodTable.ParentMethodTable = rtsBuilder.SystemObjectMethodTable.Address; - methodTable.NumVirtuals = 3; - methodTablePtr = methodTable.Address; - eeClass.MethodTable = methodTable.Address; - methodTable.EEClassOrCanonMT = eeClass.Address; + if (flagSet) + { + MockEEClass eeClass = rtsBuilder.AddEEClass("Align8Type"); + eeClass.CorTypeAttr = (uint)(System.Reflection.TypeAttributes.Public | System.Reflection.TypeAttributes.Class); + + MockMethodTable methodTable = rtsBuilder.AddMethodTable("Align8Type"); + methodTable.MTFlags = (uint)(MethodTableFlags_1.WFLAGS_HIGH.Category_ValueType | MethodTableFlags_1.WFLAGS_HIGH.RequiresAlign8); + methodTable.BaseSize = rtsBuilder.Builder.TargetTestHelpers.ObjectBaseSize; + methodTable.ParentMethodTable = rtsBuilder.SystemObjectMethodTable.Address; + methodTable.NumVirtuals = 3; + methodTablePtr = methodTable.Address; + eeClass.MethodTable = methodTable.Address; + methodTable.EEClassOrCanonMT = eeClass.Address; + } + else + { + methodTablePtr = rtsBuilder.SystemObjectMethodTable.Address; + } }); IRuntimeTypeSystem contract = target.Contracts.RuntimeTypeSystem; Contracts.TypeHandle typeHandle = contract.GetTypeHandle(methodTablePtr); - Assert.True(contract.RequiresAlign8(typeHandle)); - } - - [Theory] - [ClassData(typeof(MockTarget.StdArch))] - public void RequiresAlign8_FlagUnset_ReturnsFalse(MockTarget.Architecture arch) - { - TargetPointer systemObjectMethodTablePtr = default; - TestPlaceholderTarget target = CreateTarget( - arch, - rtsBuilder => systemObjectMethodTablePtr = rtsBuilder.SystemObjectMethodTable.Address); - - IRuntimeTypeSystem contract = target.Contracts.RuntimeTypeSystem; - Contracts.TypeHandle typeHandle = contract.GetTypeHandle(systemObjectMethodTablePtr); - Assert.False(contract.RequiresAlign8(typeHandle)); + Assert.Equal(flagSet, contract.RequiresAlign8(typeHandle)); } } From 893c44a0f3af9ec1de116284274b7504c7f826ff Mon Sep 17 00:00:00 2001 From: Barbara Rosiak Date: Wed, 15 Apr 2026 16:45:49 -0700 Subject: [PATCH 4/6] Address pr comments --- docs/design/datacontracts/RuntimeTypeSystem.md | 2 +- .../Contracts/IRuntimeTypeSystem.cs | 2 +- .../Dbi/DacDbiImpl.cs | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/docs/design/datacontracts/RuntimeTypeSystem.md b/docs/design/datacontracts/RuntimeTypeSystem.md index bdec8adc615b42..7f53df2b3a05fc 100644 --- a/docs/design/datacontracts/RuntimeTypeSystem.md +++ b/docs/design/datacontracts/RuntimeTypeSystem.md @@ -54,7 +54,7 @@ partial interface IRuntimeTypeSystem : IContract public virtual bool IsString(TypeHandle typeHandle); // True if the MethodTable represents a type that contains managed references public virtual bool ContainsGCPointers(TypeHandle typeHandle); - // True if the type requires 8-byte alignment (FEATURE_64BIT_ALIGNMENT) + // True if the type requires 8-byte alignment on platforms that don't 8-byte align by default (FEATURE_64BIT_ALIGNMENT) public virtual bool RequiresAlign8(TypeHandle typeHandle); // True if the MethodTable represents a continuation type used by the async continuation feature public virtual bool IsContinuation(TypeHandle typeHandle); diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeTypeSystem.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeTypeSystem.cs index 1f6c7f9bde9466..4db9c40c20e1f5 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeTypeSystem.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeTypeSystem.cs @@ -117,7 +117,7 @@ public interface IRuntimeTypeSystem : IContract bool IsString(TypeHandle typeHandle) => throw new NotImplementedException(); // True if the MethodTable represents a type that contains managed references bool ContainsGCPointers(TypeHandle typeHandle) => throw new NotImplementedException(); - // True if the type requires 8-byte alignment (FEATURE_64BIT_ALIGNMENT) + // True if the type requires 8-byte alignment on platforms that don't 8-byte align by default (FEATURE_64BIT_ALIGNMENT) bool RequiresAlign8(TypeHandle typeHandle) => throw new NotImplementedException(); // True if the MethodTable represents a continuation type used by the async continuation feature bool IsContinuation(TypeHandle typeHandle) => throw new NotImplementedException(); diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs index 3d304c816cf347..289855ac9d41dd 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs @@ -641,11 +641,20 @@ public int RequiresAlign8(ulong thExact, Interop.BOOL* pResult) { *pResult = Interop.BOOL.FALSE; int hr = HResults.S_OK; + RuntimeInfoArchitecture arch = _target.Contracts.RuntimeInfo.GetTargetArchitecture(); try { - Contracts.IRuntimeTypeSystem rts = _target.Contracts.RuntimeTypeSystem; - Contracts.TypeHandle th = rts.GetTypeHandle(new TargetPointer(thExact)); - *pResult = rts.RequiresAlign8(th) ? Interop.BOOL.TRUE : Interop.BOOL.FALSE; + // Some 32-bit platform ABIs require 64-bit alignment (FEATURE_64BIT_ALIGNMENT). + if (arch == RuntimeInfoArchitecture.Arm || arch == RuntimeInfoArchitecture.Wasm) + { + Contracts.IRuntimeTypeSystem rts = _target.Contracts.RuntimeTypeSystem; + Contracts.TypeHandle th = rts.GetTypeHandle(new TargetPointer(thExact)); + *pResult = rts.RequiresAlign8(th) ? Interop.BOOL.TRUE : Interop.BOOL.FALSE; + } + else + { + throw new NotImplementedException(); + } } catch (System.Exception ex) { From 94377b609a10641711da65f4da8812d4f231d516 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 16 Apr 2026 18:28:18 +0000 Subject: [PATCH 5/6] Fix RequiresAlign8: use consistent param naming in docs, simplify DacDbiImpl to match runtime semantics Address PR feedback: - Fix parameter naming in RuntimeTypeSystem.md to use consistent camelCase - Remove architecture guard in DacDbiImpl.RequiresAlign8 per reviewer consensus: API should match runtime semantics (true when bit set, false otherwise) Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/d00d40eb-9997-4c3c-ba75-523c076a9c03 Co-authored-by: barosiak <76071368+barosiak@users.noreply.github.com> --- docs/design/datacontracts/RuntimeTypeSystem.md | 2 +- .../Dbi/DacDbiImpl.cs | 15 +++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/docs/design/datacontracts/RuntimeTypeSystem.md b/docs/design/datacontracts/RuntimeTypeSystem.md index 7f53df2b3a05fc..98f76c62771b5d 100644 --- a/docs/design/datacontracts/RuntimeTypeSystem.md +++ b/docs/design/datacontracts/RuntimeTypeSystem.md @@ -544,7 +544,7 @@ Contracts used: public bool ContainsGCPointers(TypeHandle TypeHandle) => !typeHandle.IsMethodTable() ? false : _methodTables[TypeHandle.Address].Flags.ContainsGCPointers; - public bool RequiresAlign8(TypeHandle TypeHandle) => !typeHandle.IsMethodTable() ? false : _methodTables[TypeHandle.Address].Flags.RequiresAlign8; + public bool RequiresAlign8(TypeHandle typeHandle) => !typeHandle.IsMethodTable() ? false : _methodTables[typeHandle.Address].Flags.RequiresAlign8; public bool IsDynamicStatics(TypeHandle TypeHandle) => !typeHandle.IsMethodTable() ? false : _methodTables[TypeHandle.Address].Flags.IsDynamicStatics; diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs index 289855ac9d41dd..3d304c816cf347 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs @@ -641,20 +641,11 @@ public int RequiresAlign8(ulong thExact, Interop.BOOL* pResult) { *pResult = Interop.BOOL.FALSE; int hr = HResults.S_OK; - RuntimeInfoArchitecture arch = _target.Contracts.RuntimeInfo.GetTargetArchitecture(); try { - // Some 32-bit platform ABIs require 64-bit alignment (FEATURE_64BIT_ALIGNMENT). - if (arch == RuntimeInfoArchitecture.Arm || arch == RuntimeInfoArchitecture.Wasm) - { - Contracts.IRuntimeTypeSystem rts = _target.Contracts.RuntimeTypeSystem; - Contracts.TypeHandle th = rts.GetTypeHandle(new TargetPointer(thExact)); - *pResult = rts.RequiresAlign8(th) ? Interop.BOOL.TRUE : Interop.BOOL.FALSE; - } - else - { - throw new NotImplementedException(); - } + Contracts.IRuntimeTypeSystem rts = _target.Contracts.RuntimeTypeSystem; + Contracts.TypeHandle th = rts.GetTypeHandle(new TargetPointer(thExact)); + *pResult = rts.RequiresAlign8(th) ? Interop.BOOL.TRUE : Interop.BOOL.FALSE; } catch (System.Exception ex) { From a390780dc08509a9cecccb14f352884f5a970cfb Mon Sep 17 00:00:00 2001 From: Barbara Rosiak Date: Thu, 16 Apr 2026 11:35:45 -0700 Subject: [PATCH 6/6] Revert copilot changes --- .../Dbi/DacDbiImpl.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs index 3d304c816cf347..289855ac9d41dd 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs @@ -641,11 +641,20 @@ public int RequiresAlign8(ulong thExact, Interop.BOOL* pResult) { *pResult = Interop.BOOL.FALSE; int hr = HResults.S_OK; + RuntimeInfoArchitecture arch = _target.Contracts.RuntimeInfo.GetTargetArchitecture(); try { - Contracts.IRuntimeTypeSystem rts = _target.Contracts.RuntimeTypeSystem; - Contracts.TypeHandle th = rts.GetTypeHandle(new TargetPointer(thExact)); - *pResult = rts.RequiresAlign8(th) ? Interop.BOOL.TRUE : Interop.BOOL.FALSE; + // Some 32-bit platform ABIs require 64-bit alignment (FEATURE_64BIT_ALIGNMENT). + if (arch == RuntimeInfoArchitecture.Arm || arch == RuntimeInfoArchitecture.Wasm) + { + Contracts.IRuntimeTypeSystem rts = _target.Contracts.RuntimeTypeSystem; + Contracts.TypeHandle th = rts.GetTypeHandle(new TargetPointer(thExact)); + *pResult = rts.RequiresAlign8(th) ? Interop.BOOL.TRUE : Interop.BOOL.FALSE; + } + else + { + throw new NotImplementedException(); + } } catch (System.Exception ex) {