-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Adjust managed type system for new function pointer handling #84819
Changes from all commits
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 | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -371,7 +371,19 @@ private MethodSignature ParseMethodSignatureImpl(bool skipEmbeddedSignatureData) | |||||||||||||||
Debug.Assert((int)MethodSignatureFlags.CallingConventionVarargs == (int)SignatureCallingConvention.VarArgs); | ||||||||||||||||
Debug.Assert((int)MethodSignatureFlags.UnmanagedCallingConvention == (int)SignatureCallingConvention.Unmanaged); | ||||||||||||||||
|
||||||||||||||||
flags = (MethodSignatureFlags)signatureCallConv; | ||||||||||||||||
// If skipEmbeddedSignatureData is true, we're building the signature for the purposes of building a type. | ||||||||||||||||
// We normalize unmanaged calling convention into a single value - "unmanaged". | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I understand why this is safe. You mean that, after the other change, it no longer matters if you have
vs.
We effectively erase custom modifiers for unmanaged function pointers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modifiers were already erased for runtime pointer types - that's what the existing We have some tests testing this like: runtime/src/tests/reflection/Modifiers/modifiersdata.il Lines 160 to 166 in ed0f1c5
The logic I'm adding basically switches specific calling conventions into things that act like modifiers (previously they would be part of the type identity). The added unit test is then testing two things:
|
||||||||||||||||
if (skipEmbeddedSignatureData) | ||||||||||||||||
{ | ||||||||||||||||
flags = MethodSignatureFlags.UnmanagedCallingConvention; | ||||||||||||||||
|
||||||||||||||||
// But we still need to remember this signature is different, so add this to the EmbeddedSignatureData of the owner signature. | ||||||||||||||||
_embeddedSignatureDataList?.Add(new EmbeddedSignatureData { index = string.Join(".", _indexStack) + "|" + ((int)signatureCallConv).ToString(), kind = EmbeddedSignatureDataKind.UnmanagedCallConv, type = null }); | ||||||||||||||||
} | ||||||||||||||||
else | ||||||||||||||||
{ | ||||||||||||||||
flags = (MethodSignatureFlags)signatureCallConv; | ||||||||||||||||
} | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
if (!header.IsInstance) | ||||||||||||||||
|
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.
Why do we need this as a EmbeddedSignatureDataKind instead of as a MethodSignatureFlags?
I think I might be missing something. It seems like this change applies to the nested arguments of a function pointer, rather than the function pointer itself. Is that right? Does that mean that this is only for function pointers of function pointers?
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.
EmbeddedSignatureData is attached to method signatures, but we can decide which method signature it should attach to.
Consider:
void Blah(delegate*unmanaged[Cdecl]<void> x);
. When we're materializing the topmost parent method signature, we set a flag in the parser that it should generate embedded signature data. Embedded signature data is a sidecar that gets attached to the topmost method signature. It can express things in arbitrary type construction nesting. It's really weird. Back to the signature - we want to attach the modopt (and non-meaningful flags) to the topmost EmbeddedSignatureData. If we were to attach it to the nested signature, it would become part of the identity. But we don't want it part of the identity of thedelegate*unmanaged[Cdecl]<void>
type because it was decided that for the type system purposes, the only bit that matters is whether the method is unmanaged (and not the exact calling convention).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.
Ah it was avoiding putting it in the identity that I missed