Commit c9ce936
[cDAC] Demonstrate Lock as a cross-source IData<T> type
Per Jan's request on PR dotnet#127310
(dotnet#127310 (comment)),
this commit shows what it takes to add System.Threading.Lock to the
native cdac descriptor. Under the new fallback design, the IData<T>
class stays in one place and gains BOTH sources via a per-field
candidate-name cascade -- not a choose-one-source decision.
Runtime side (3 files, matches the throwaway branch shared with Jan):
- `src/coreclr/vm/object.h` -- `class LockObject : public Object`
plus `cdac_data<LockObject>` template exposing the offsets.
- `src/coreclr/vm/datadescriptor/datadescriptor.inc` -- new
`CDAC_TYPE_BEGIN(Lock)` block with T_INT32 `OwningThreadId`
and T_UINT32 `State` / `RecursionCount` fields.
- `src/coreclr/vm/corelib.h` -- `DEFINE_CLASS_U(Threading, Lock,
NoClass)` plus `DEFINE_FIELD_U(...)` for the three fields.
Managed side (1 file change vs the throwaway branch's 2):
- `DataType.cs` -- add `Lock` enum member.
- `Data/Managed/Lock.cs` -- ONE attribute change. The class gains
`nameof(DataType.Lock)` alongside `ManagedFullName` and each
`[Field]` lists both candidate names:
[CdacType(nameof(DataType.Lock), ManagedFullName = "System.Threading.Lock")]
internal sealed partial class Lock : IData<Lock>
{
[Field("State", "_state")] public uint State { get; }
[Field("OwningThreadId", "_owningThreadId")] public int OwningThreadId { get; }
[Field("RecursionCount", "_recursionCount")] public uint RecursionCount { get; }
}
The cdac runtime generator emits a `LayoutPairResolver.Resolve`
call that picks up both sources; each field's read tries
`"State"` against the native cdac descriptor first, falling
through to `"_state"` against the managed type metadata when
needed. No class move / namespace change / caller update.
Contrast with the throwaway branch
(62223d6...b3dfdc8)
which had to delete `Data/Managed/Lock.cs` and add a new
`Data/Lock.cs` with a hand-written ctor and `init` properties,
then update `Contracts/SyncBlock_1.cs` to reference the new
namespace. The new design needs only the runtime-side
`LockObject` plumbing + the single attribute decoration.
Build clean; full cdac test suite still 2206 passing.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 2440300 commit c9ce936
5 files changed
Lines changed: 38 additions & 4 deletions
File tree
- src
- coreclr/vm
- datadescriptor
- native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts
- Data/Managed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
630 | 630 | | |
631 | 631 | | |
632 | 632 | | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
633 | 637 | | |
634 | 638 | | |
635 | 639 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
183 | 190 | | |
184 | 191 | | |
185 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
877 | 877 | | |
878 | 878 | | |
879 | 879 | | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
880 | 902 | | |
881 | 903 | | |
882 | 904 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| |||
0 commit comments