-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[cdac] start of RuntimeTypeSystem contract; implement GetMethodTableData SOS method #103444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 19 commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
b98afa8
Implement GetThreadStoreData in cDAC
elinor-fung 890f9c6
Add placeholder for getting thread data
elinor-fung 41ba95c
Apply suggestions from code review
elinor-fung 29214f0
WIP: Metadata contract
lambdageek 8beced0
Merge remote-tracking branch 'elinor-fung/cdac-threadstore' into cdac…
lambdageek 5213286
fix build
lambdageek 622e01a
WIP: ValidateMethodTable
lambdageek e112416
DataCache.GetOrAdd
elinor-fung ae1eac9
wip
lambdageek 79ea0d4
Merge remote-tracking branch 'elinor-fung/cdac-threadstore' into cdac…
lambdageek 5c696da
checkpoint: ValidateWithPossibleAV
lambdageek 6eaf80f
Merge remote-tracking branch 'origin/main' into cdac-wip
lambdageek 3a7808d
checkpoint EEClass from MethodTable
lambdageek 66e5476
checkpoint: ValidateMethodTablePointer
lambdageek 95914b8
cp: delegate from legacy dac
lambdageek 2b8fda3
add Metadata to runtime contract descriptor
lambdageek 5c7d2ac
checkpoint: more MethodTable fields
lambdageek 7be5c60
checkpoint GetMethodTableData implemented
lambdageek 30b7b26
checkpoint: same answer as legacy dac
lambdageek 187bcbe
Merge remote-tracking branch 'origin/main' into cdac-wip
lambdageek f0d1fcb
new flags for statics
lambdageek c53db36
fix GCC build
lambdageek b70bb1d
WIP: opaque MethodTableHandle
lambdageek a65fd50
Add contract accessors for MethodTableHandle
lambdageek 6f844bf
fixup
lambdageek 76e0384
simplify FreeObjectMethodTable handling
lambdageek cdb7543
cleanup
lambdageek 78830ea
fixup
lambdageek fbbd45b
Merge remote-tracking branch 'origin/main' into cdac-wip
lambdageek 32665b2
[dac] Return canonical MethodTable instead of EEClass
lambdageek acf8436
Delete unreferenced MethodTable flags
lambdageek f246c86
add Metadata contract doc; fixups
lambdageek 8409f3e
Merge remote-tracking branch 'origin/main' into cdac-wip
lambdageek 08d069a
rename DacpMethodTableData:klass field
lambdageek 674655f
document GetMethodTableData string baseSize adjustment
lambdageek 2ae4625
Apply suggestions from code review
lambdageek e18a2be
fix typo
lambdageek 846e779
rename flag to ContainsGCPointers
lambdageek 383af83
[vm] rename ContainsPointers flag to ContainsGCPointers
lambdageek 0f8c7f1
code style suggestions from code review
lambdageek 7a337c1
BUGFIX: read DwFlags2 from the correct offset
lambdageek a7c8158
hide utility methods
lambdageek f4a3493
remove EEClass_1 struct
lambdageek 10624c7
Merge remote-tracking branch 'origin/main' into cdac-wip
lambdageek 65cc531
rename data descriptor members to remove prefixes
lambdageek d526087
cleanup the contract docs
lambdageek 0a4112e
remove hungariant notation prefixes from data descriptors
lambdageek 1071ca4
DAC: always set wNumVirtuals and wNumVtableSlots to 0
lambdageek 6c5235c
Remove NumVirtuals and NumVtableSlots from Metadata.md
lambdageek 95b728a
Merge remote-tracking branch 'origin/main' into cdac-wip
lambdageek 6573e14
"untrusted" -> "non-validated"
lambdageek 8596892
merge fixup
lambdageek 6eabf42
remove #if 0
lambdageek 4d3200d
cleanup
lambdageek 2e66740
pull test target helpers out
lambdageek 8533148
Add one FreeObjectMethodTable unit test
lambdageek 77cf405
clean up the test helpers a bit
lambdageek f9bce4c
validate that a mock system object is a valid method table
lambdageek 3721992
code review feedback and more tests:
lambdageek 1af7c80
Update src/coreclr/gc/env/gcenv.object.h
lambdageek 993ae1d
Update src/native/managed/cdacreader/src/Contracts/Metadata_1.MethodT…
lambdageek f04d880
Address code review feedback
lambdageek 76859d1
move non-validated MethodTable handling to a separate class
lambdageek a12a407
clear up ComponentSize contract spec and impl
lambdageek 9cf4c5a
rename Metadata -> RuntimeTypeSystem
lambdageek 1814848
add validation failure test; change validation to throw InvalidOperat…
lambdageek 89f98a3
Merge remote-tracking branch 'origin/main' into cdac-wip
lambdageek a0989fa
Update src/native/managed/cdacreader/src/Contracts/RuntimeTypeSystem_…
lambdageek 617bf62
spellcheck
lambdageek 815ff0d
Merge branch 'cdac-wip' of github.com:lambdageek/runtime into cdac-wip
lambdageek 1ab4f08
Add a generic instance test
lambdageek ee3a362
add array instance test
lambdageek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
174 changes: 174 additions & 0 deletions
174
src/native/managed/cdacreader/src/Contracts/Metadata.MethodTableFlags.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using UntrustedMethodTable = Microsoft.Diagnostics.DataContractReader.Contracts.UntrustedMethodTable_1; | ||
using MethodTable = Microsoft.Diagnostics.DataContractReader.Contracts.MethodTable_1; | ||
using UntrustedEEClass = Microsoft.Diagnostics.DataContractReader.Contracts.UntrustedEEClass_1; | ||
using EEClass = Microsoft.Diagnostics.DataContractReader.Contracts.EEClass_1; | ||
|
||
namespace Microsoft.Diagnostics.DataContractReader.Contracts; | ||
|
||
internal partial struct Metadata_1 | ||
{ | ||
[Flags] | ||
internal enum WFLAGS_LOW : uint | ||
{ | ||
// We are overloading the low 2 bytes of m_dwFlags to be a component size for Strings | ||
// and Arrays and some set of flags which we can be assured are of a specified state | ||
// for Strings / Arrays, currently these will be a bunch of generics flags which don't | ||
// apply to Strings / Arrays. | ||
|
||
UNUSED_ComponentSize_1 = 0x00000001, | ||
// GC depends on this bit | ||
HasCriticalFinalizer = 0x00000002, // finalizer must be run on Appdomain Unload | ||
lambdageek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
StaticsMask = 0x0000000C, | ||
StaticsMask_NonDynamic = 0x00000000, | ||
StaticsMask_Dynamic = 0x00000008, // dynamic statics (EnC, reflection.emit) | ||
StaticsMask_Generics = 0x00000004, // generics statics | ||
StaticsMask_CrossModuleGenerics = 0x0000000C, // cross module generics statics (NGen) | ||
StaticsMask_IfGenericsThenCrossModule = 0x00000008, // helper constant to get rid of unnecessary check | ||
|
||
|
||
GenericsMask = 0x00000030, | ||
GenericsMask_NonGeneric = 0x00000000, // no instantiation | ||
GenericsMask_GenericInst = 0x00000010, // regular instantiation, e.g. List<String> | ||
GenericsMask_SharedInst = 0x00000020, // shared instantiation, e.g. List<__Canon> or List<MyValueType<__Canon>> | ||
GenericsMask_TypicalInst = 0x00000030, // the type instantiated at its formal parameters, e.g. List<T> | ||
|
||
HasVariance = 0x00000100, // This is an instantiated type some of whose type parameters are co- or contra-variant | ||
|
||
HasDefaultCtor = 0x00000200, | ||
HasPreciseInitCctors = 0x00000400, // Do we need to run class constructors at allocation time? (Not perf important, could be moved to EEClass | ||
|
||
// if FEATURE_HFA | ||
IsHFA = 0x00000800, // This type is an HFA (Homogeneous Floating-point Aggregate) | ||
|
||
// if UNIX_AMD64_ABI | ||
IsRegStructPassed = 0x00000800, // This type is a System V register passed struct. | ||
|
||
IsByRefLike = 0x00001000, | ||
|
||
HasBoxedRegularStatics = 0x00002000, | ||
HasBoxedThreadStatics = 0x00004000, | ||
|
||
// In a perfect world we would fill these flags using other flags that we already have | ||
// which have a constant value for something which has a component size. | ||
UNUSED_ComponentSize_7 = 0x00008000, | ||
|
||
// IMPORTANT! IMPORTANT! IMPORTANT! | ||
// | ||
// As you change the flags in WFLAGS_LOW_ENUM you also need to change this | ||
// to be up to date to reflect the default values of those flags for the | ||
// case where this MethodTable is for a String or Array | ||
StringArrayValues = //SET_FALSE(enum_flag_HasCriticalFinalizer) | | ||
StaticsMask_NonDynamic | | ||
//SET_FALSE(enum_flag_HasBoxedRegularStatics) | | ||
//SET_FALSE(enum_flag_HasBoxedThreadStatics) | | ||
GenericsMask_NonGeneric | | ||
//SET_FALSE(enum_flag_HasVariance) | | ||
//SET_FALSE(enum_flag_HasDefaultCtor) | | ||
//SET_FALSE(enum_flag_HasPreciseInitCctors) | ||
0, | ||
} | ||
|
||
[Flags] | ||
internal enum WFLAGS_HIGH : uint | ||
{ | ||
Category_Mask = 0x000F0000, | ||
|
||
Category_Class = 0x00000000, | ||
Category_Unused_1 = 0x00010000, | ||
Category_Unused_2 = 0x00020000, | ||
Category_Unused_3 = 0x00030000, | ||
|
||
Category_ValueType = 0x00040000, | ||
Category_ValueType_Mask = 0x000C0000, | ||
Category_Nullable = 0x00050000, // sub-category of ValueType | ||
Category_PrimitiveValueType = 0x00060000, // sub-category of ValueType, Enum or primitive value type | ||
Category_TruePrimitive = 0x00070000, // sub-category of ValueType, Primitive (ELEMENT_TYPE_I, etc.) | ||
|
||
Category_Array = 0x00080000, | ||
Category_Array_Mask = 0x000C0000, | ||
// Category_IfArrayThenUnused = 0x00010000, // sub-category of Array | ||
Category_IfArrayThenSzArray = 0x00020000, // sub-category of Array | ||
|
||
Category_Interface = 0x000C0000, | ||
Category_Unused_4 = 0x000D0000, | ||
Category_Unused_5 = 0x000E0000, | ||
Category_Unused_6 = 0x000F0000, | ||
|
||
Category_ElementTypeMask = 0x000E0000, // bits that matter for element type mask | ||
|
||
// GC depends on this bit | ||
HasFinalizer = 0x00100000, // instances require finalization | ||
|
||
IDynamicInterfaceCastable = 0x10000000, // class implements IDynamicInterfaceCastable interface | ||
|
||
ICastable = 0x00400000, // class implements ICastable interface | ||
|
||
RequiresAlign8 = 0x00800000, // Type requires 8-byte alignment (only set on platforms that require this and don't get it implicitly) | ||
|
||
ContainsPointers = 0x01000000, | ||
|
||
HasTypeEquivalence = 0x02000000, // can be equivalent to another type | ||
|
||
IsTrackedReferenceWithFinalizer = 0x04000000, | ||
|
||
// GC depends on this bit | ||
Collectible = 0x00200000, | ||
ContainsGenericVariables = 0x20000000, // we cache this flag to help detect these efficiently and | ||
// to detect this condition when restoring | ||
|
||
ComObject = 0x40000000, // class is a com object | ||
|
||
HasComponentSize = 0x80000000, // This is set if component size is used for flags. | ||
|
||
// Types that require non-trivial interface cast have this bit set in the category | ||
NonTrivialInterfaceCast = Category_Array | ||
| ComObject | ||
| ICastable | ||
| IDynamicInterfaceCastable | ||
| Category_ValueType | ||
|
||
} | ||
} | ||
internal interface IMethodTableFlags | ||
{ | ||
public uint DwFlags { get; } | ||
public uint DwFlags2 { get; } | ||
public uint BaseSize { get; } | ||
|
||
private Metadata_1.WFLAGS_HIGH FlagsHigh => (Metadata_1.WFLAGS_HIGH)DwFlags; | ||
private Metadata_1.WFLAGS_LOW FlagsLow => (Metadata_1.WFLAGS_LOW)DwFlags; | ||
public int GetTypeDefRid() => (int)(DwFlags2 >> Metadata_1.Constants.MethodTableDwFlags2TypeDefRidShift); | ||
|
||
public Metadata_1.WFLAGS_LOW GetFlag(Metadata_1.WFLAGS_LOW mask) => throw new NotImplementedException("TODO"); | ||
public Metadata_1.WFLAGS_HIGH GetFlag(Metadata_1.WFLAGS_HIGH mask) => FlagsHigh & mask; | ||
public bool IsInterface => GetFlag(Metadata_1.WFLAGS_HIGH.Category_Mask) == Metadata_1.WFLAGS_HIGH.Category_Interface; | ||
public bool IsString => HasComponentSize && !IsArray && RawGetComponentSize() == 2; | ||
|
||
public bool HasComponentSize => GetFlag(Metadata_1.WFLAGS_HIGH.HasComponentSize) != 0; | ||
|
||
public bool IsArray => GetFlag(Metadata_1.WFLAGS_HIGH.Category_Array_Mask) == Metadata_1.WFLAGS_HIGH.Category_Array; | ||
|
||
public bool IsStringOrArray => HasComponentSize; | ||
public ushort RawGetComponentSize() => (ushort)(DwFlags >> 16); | ||
|
||
public bool TestFlagWithMask(Metadata_1.WFLAGS_LOW mask, Metadata_1.WFLAGS_LOW flag) | ||
{ | ||
if (IsStringOrArray) | ||
{ | ||
return (Metadata_1.WFLAGS_LOW.StringArrayValues & mask) == flag; | ||
} | ||
else | ||
{ | ||
return (FlagsLow & mask) == flag; | ||
} | ||
} | ||
public bool HasInstantiation => !TestFlagWithMask(Metadata_1.WFLAGS_LOW.GenericsMask, Metadata_1.WFLAGS_LOW.GenericsMask_NonGeneric); | ||
|
||
public bool ContainsPointers => GetFlag(Metadata_1.WFLAGS_HIGH.ContainsPointers) != 0; | ||
|
||
public bool IsDynamicStatics => !TestFlagWithMask(Metadata_1.WFLAGS_LOW.StaticsMask, Metadata_1.WFLAGS_LOW.StaticsMask_Dynamic); | ||
} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.