-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Implementation of SOSDacApi GetMethodDescName for cDAC #106169
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
Changes from 41 commits
255da99
0671cd4
636bb2b
d359ed9
fc24cd4
d93e98b
fead409
d2b36fc
8fdcc24
30da32c
87f7003
143cb86
7284f83
2d5ec4f
8e2dbca
e3964f9
38d0a51
9d88f19
4a4c3a4
510a10f
419cb11
1321aa9
dcc4540
c31bdcf
7517e32
54ab23e
27fcddc
2a41206
dbe3cf4
3a35f41
1eb3b36
785ced4
01d3d24
1b6b6fd
0c7a254
ec9eb54
54ded9a
3ffb03b
e72cea6
c250bb8
c3ebfdb
bcf9fba
de846a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -92,12 +92,49 @@ struct MethodDescHandle | |||||||||||
| } | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| ```csharp | ||||||||||||
| public enum ArrayFunctionType | ||||||||||||
| { | ||||||||||||
| Get = 0, | ||||||||||||
| Set = 1, | ||||||||||||
| Address = 2, | ||||||||||||
| Constructor = 3 | ||||||||||||
| } | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| ```csharp | ||||||||||||
| partial interface IRuntimeTypeSystem : IContract | ||||||||||||
| { | ||||||||||||
| public virtual MethodDescHandle GetMethodDescHandle(TargetPointer methodDescPointer); | ||||||||||||
|
|
||||||||||||
| public virtual TargetPointer GetMethodTable(MethodDescHandle methodDesc); | ||||||||||||
|
|
||||||||||||
| // Return true for an uninstantiated generic method | ||||||||||||
| public virtual bool IsGenericMethodDefinition(MethodDescHandle methodDesc); | ||||||||||||
|
|
||||||||||||
| public virtual ReadOnlySpan<TypeHandle> GetGenericMethodInstantiation(MethodDescHandle methodDesc); | ||||||||||||
|
|
||||||||||||
| // Return mdTokenNil (0x06000000) if the method doesn't have a token, otherwise return the token of the method | ||||||||||||
| public virtual uint GetMethodToken(MethodDescHandle methodDesc); | ||||||||||||
|
|
||||||||||||
| // Return true if a MethodDesc represents an array method | ||||||||||||
| // An array method is also a StoredSigMethodDesc | ||||||||||||
| public virtual bool IsArrayMethod(MethodDescHandle methodDesc, out ArrayFunctionType functionType); | ||||||||||||
|
|
||||||||||||
| // Return true if a MethodDesc represents a dynamically generated method, either an IL Stub dynamically | ||||||||||||
| // generated by the runtime, or a MethodDesc that describes a method represented by the System.Reflection.Emit.DynamicMethod class | ||||||||||||
| // A dynamic method is also a StoredSigMethodDesc | ||||||||||||
| public virtual bool IsDynamicMethod(MethodDescHandle methodDesc, out ReadOnlySpan<byte> methodName); | ||||||||||||
|
|
||||||||||||
| // A StoredSigMethodDesc is a MethodDesc for which the signature isn't found in metadata. | ||||||||||||
| public virtual bool IsStoredSigMethodDesc(MethodDescHandle methodDesc, out ReadOnlySpan<byte> signature); | ||||||||||||
|
|
||||||||||||
| // Return true for a MethodDesc that describes a method represented by the System.Reflection.Emit.DynamicMethod class | ||||||||||||
| // A LCG method is also a StoredSigMethodDesc | ||||||||||||
| public virtual bool IsLCGMethod(MethodDescHandle methodDesc); | ||||||||||||
|
||||||||||||
| inline DWORD IsNoMetadata() const | |
| { | |
| LIMITED_METHOD_DAC_CONTRACT; | |
| return (mcDynamic == GetClassification()); | |
| } |
MethodDesc::IsDynamicMethod and MethodDesc::IsNoMetadata have the same implementation.
The key property of the DynamicMethodDesc is that it has no ECMA-335 metadata, it has no metadata token, etc.
Dynamic IL generation is not the key property of DynamicMethodDesc. The regular ECMA-335 MethodDescs can have dynamically generated (IL) code too. For example, UnsafeAccessors have dynamically generated IL but they are regular MethodDescs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like @jkotas's idea here. Then the IsDynamicMethod api at the cdac level makes total sense, the existing DynamicMethodDesc translates to NoMetadataMethodDesc and gets a better name that more matches its utility, and we get rid of having both MethodDesc::IsNoMetadata and MethodDesc::IsDynamicMethod which are today exactly the same thing. While I'm at it, I'll rename mcDynamic to mcNoMetadata
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trending toward the idea of putting this rename in a separate PR. Opinions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Offline discussion is to put together a separate PR for that. I'll just add a commit to update the cdac contract side naming to IsDynamicMethod, and the renaming of the underlying structures to be less confusing will be a separate PR that will probably miss .NET 9.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to just make
methodNameastringinstead ofReadOnlySpan<byte>, so the consumer doesn't have to know the encoding?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a bad idea. In general, I don't want to expose arrays to contract users, as its far to easy to mutate them, but strings are nice in that they are our only truly immutable type in the BCL, and work nicely for this sort of thing.