-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Cleanup dead delegate code #129662
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
base: main
Are you sure you want to change the base?
Cleanup dead delegate code #129662
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 | ||
|---|---|---|---|---|
|
|
@@ -379,8 +379,7 @@ internal static Delegate CreateDelegateNoSecurityCheck(Type type, object? target | |||
|
|
||||
| // Initialize the method... | ||||
| Delegate d = InternalAlloc(rtType); | ||||
| // This is a new internal API added in Whidbey. Currently it's only | ||||
| // used by the dynamic method code to generate a wrapper delegate. | ||||
| // This is a new internal API added in Whidbey. | ||||
|
Member
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.
Suggested change
Whibey shipped in 2005. This is not new anymore. |
||||
| // Allow flexible binding options since the target method is | ||||
| // unambiguously provided to us. | ||||
|
|
||||
|
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -166,7 +166,7 @@ internal MulticastDelegate NewMulticastDelegate(object[] invocationList, int inv | |
|
|
||
| internal void StoreDynamicMethod(MethodInfo dynamicMethod) | ||
| { | ||
| Debug.Assert(_invocationCount == 0); | ||
|
Contributor
Author
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. This assert was incorrect for oven virtual delegates.
Member
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. This method is only ever used to create dynamic method delegate. I do not think there is a way to have open virtual delegate that points to dynamic method. We may want to delete this method instead (see my other feedback). |
||
| Debug.Assert(HasSingleTarget); | ||
| _helperObject = dynamicMethod; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3268,7 +3268,6 @@ DacDbiInterfaceImpl::DelegateType DacDbiInterfaceImpl::GetDelegateType(VMPTR_Obj | |||||||||||||
| { | ||||||||||||||
| // If this delegate points to a static function or this is a open virtual delegate, this should be non-null | ||||||||||||||
|
Member
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. Is this comment correct? Open virtual delegate is going to have
Member
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. Lines 166 to 170 in e556d5a
runtime/docs/design/datacontracts/Object.md Line 214 in e556d5a
should be update to match too
Contributor
Author
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. I've fixed that in the other PR so I'd rather not touch this here.
Member
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. I thought that the primary goal of this PR is to delete all remnants of the wrapper stubs that I have missed. |
||||||||||||||
| // Special case: This might fail in a VSD delegate (instance open virtual)... | ||||||||||||||
| // TODO: There is the special signatures cases missing. | ||||||||||||||
| TADDR targetMethodPtr = PCODEToPINSTR(pDelObj->GetMethodPtrAux()); | ||||||||||||||
| if (targetMethodPtr == (TADDR)NULL) | ||||||||||||||
| { | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1812,10 +1812,7 @@ MethodDesc *COMDelegate::GetMethodDesc(OBJECTREF orDelegate) | |
|
|
||
| // If you modify this logic, please update cDAC IObject.GetDelegateInfo. | ||
|
|
||
| MethodDesc *pMethodHandle = NULL; | ||
|
|
||
| DELEGATEREF thisDel = (DELEGATEREF) orDelegate; | ||
| DELEGATEREF innerDel = NULL; | ||
|
|
||
| INT_PTR count = thisDel->GetInvocationCount(); | ||
| if (count != 0) | ||
|
|
@@ -1825,48 +1822,24 @@ MethodDesc *COMDelegate::GetMethodDesc(OBJECTREF orDelegate) | |
| // - unamanaged ftn ptr - _invocationList == NULL && _invocationCount == -1 | ||
| // - virtual delegate - _invocationList == null && _invocationCount == (target MethodDesc) | ||
| // or _invocationList points to a LoaderAllocator/DynamicResolver | ||
|
Member
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. I do not think _invocationList ever points to a LoaderAllocator/DynamicResolver in the current implementation. Do you agree? I think all comments and code (e.g. InvocationListLogicallyNull ) that deal with it can be deleted.
Contributor
Author
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. Ah right I've only moved it there in my other PR. Since that makes it the case, I'd not touch this however.
Member
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. Before this delta, the comment was referring to wrapper Delegate so one can guess it is obsolete. After this delta, the comment is simply incorrect that is not an improvement. I understand that some of the changes will conflict. It is the cost of splitting large changes into multiple PRs. It is important that each of the split PRs is coherent on its own as much as possible. |
||
| innerDel = (DELEGATEREF) thisDel->GetInvocationList(); | ||
| bool fOpenVirtualDelegate = false; | ||
|
|
||
| if (innerDel != NULL) | ||
| { | ||
| MethodTable *pMT = innerDel->GetMethodTable(); | ||
| if (pMT->IsDelegate()) | ||
| return GetMethodDesc(innerDel); | ||
| if (!pMT->IsArray()) | ||
| { | ||
| // must be a virtual one | ||
| fOpenVirtualDelegate = true; | ||
| } | ||
| } | ||
| else | ||
| { | ||
| if (count != DELEGATE_MARKER_UNMANAGEDFPTR) | ||
| { | ||
| // must be a virtual one | ||
| fOpenVirtualDelegate = true; | ||
| } | ||
| } | ||
| // we return the method desc for the invoke | ||
|
Member
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. This looks like unfinished sentence. Should this say "... for the first two cases" or something? |
||
| OBJECTREF invocationList = thisDel->GetInvocationList(); | ||
| if ((invocationList != NULL && invocationList->GetMethodTable()->IsArray()) || count == DELEGATE_MARKER_UNMANAGEDFPTR) | ||
| return FindDelegateInvokeMethod(thisDel->GetMethodTable()); | ||
|
|
||
| if (fOpenVirtualDelegate) | ||
| pMethodHandle = GetMethodDescForOpenVirtualDelegate(thisDel); | ||
| else | ||
| pMethodHandle = FindDelegateInvokeMethod(thisDel->GetMethodTable()); | ||
| return GetMethodDescForOpenVirtualDelegate(thisDel); | ||
| } | ||
| else | ||
| { | ||
| // Next, check for an open delegate | ||
| PCODE code = thisDel->GetMethodPtrAux(); | ||
|
|
||
| if (code == (PCODE)NULL) | ||
| { | ||
| // Must be a normal delegate | ||
| code = thisDel->GetMethodPtr(); | ||
| } | ||
|
|
||
| pMethodHandle = NonVirtualEntry2MethodDesc(code); | ||
| // Next, check for an open delegate | ||
| PCODE code = thisDel->GetMethodPtrAux(); | ||
| if (code == (PCODE)NULL) | ||
| { | ||
| // Must be a normal delegate | ||
| code = thisDel->GetMethodPtr(); | ||
| } | ||
|
|
||
| MethodDesc *pMethodHandle = NonVirtualEntry2MethodDesc(code); | ||
| _ASSERTE(pMethodHandle); | ||
| return pMethodHandle; | ||
| } | ||
|
|
||
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.
Non-sensical comment