From 8497225d69d8d40b10176a35f87a7267666c7438 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Wed, 18 Sep 2024 09:26:45 -0700 Subject: [PATCH] Cleanup delegate-related code (#107966) * Cleanup delegate-related code - Deleted unused and unreachable code - Fix minor leak of delegate Stubs with collectible assemblies --------- Co-authored-by: Juan Hoyos <19413848+hoyosjs@users.noreply.github.com> Co-authored-by: Noah Falk --- src/coreclr/vm/class.cpp | 4 - src/coreclr/vm/class.h | 16 +--- src/coreclr/vm/clrtocomcall.cpp | 4 +- src/coreclr/vm/codeman.h | 3 - src/coreclr/vm/comdelegate.cpp | 45 ++++------ src/coreclr/vm/comdelegate.h | 2 +- src/coreclr/vm/methodtablebuilder.cpp | 10 +-- src/coreclr/vm/stublink.cpp | 43 +--------- src/coreclr/vm/stublink.h | 61 ++------------ src/coreclr/vm/stubmgr.cpp | 116 +++----------------------- 10 files changed, 45 insertions(+), 259 deletions(-) diff --git a/src/coreclr/vm/class.cpp b/src/coreclr/vm/class.cpp index 8f7d33be46a21b..f15c87cf3b96ff 100644 --- a/src/coreclr/vm/class.cpp +++ b/src/coreclr/vm/class.cpp @@ -144,10 +144,6 @@ void EEClass::Destruct(MethodTable * pOwningMT) ExecutableWriterHolder stubWriterHolder(pDelegateEEClass->m_pInstRetBuffCallStub, sizeof(Stub)); stubWriterHolder.GetRW()->DecRef(); } - // While m_pMultiCastInvokeStub is also a member, - // it is owned by the m_pMulticastStubCache, not by the class - // - it is shared across classes. So we don't decrement - // its ref count here } #ifdef FEATURE_COMINTEROP diff --git a/src/coreclr/vm/class.h b/src/coreclr/vm/class.h index 743d34ca3a88aa..71044dd056b374 100644 --- a/src/coreclr/vm/class.h +++ b/src/coreclr/vm/class.h @@ -1895,11 +1895,9 @@ class DelegateEEClass : public EEClass PTR_Stub m_pStaticCallStub; PTR_Stub m_pInstRetBuffCallStub; PTR_MethodDesc m_pInvokeMethod; - PTR_Stub m_pMultiCastInvokeStub; - PTR_Stub m_pWrapperDelegateInvokeStub; + PCODE m_pMultiCastInvokeStub; + PCODE m_pWrapperDelegateInvokeStub; UMThunkMarshInfo* m_pUMThunkMarshInfo; - PTR_MethodDesc m_pBeginInvokeMethod; - PTR_MethodDesc m_pEndInvokeMethod; Volatile m_pMarshalStub; #ifdef FEATURE_COMINTEROP @@ -1911,16 +1909,6 @@ class DelegateEEClass : public EEClass return m_pInvokeMethod; } - PTR_MethodDesc GetBeginInvokeMethod() - { - return m_pBeginInvokeMethod; - } - - PTR_MethodDesc GetEndInvokeMethod() - { - return m_pEndInvokeMethod; - } - #ifndef DACCESS_COMPILE DelegateEEClass() : EEClass() { diff --git a/src/coreclr/vm/clrtocomcall.cpp b/src/coreclr/vm/clrtocomcall.cpp index 3df537c9656c9d..4be5a434ba3ebd 100644 --- a/src/coreclr/vm/clrtocomcall.cpp +++ b/src/coreclr/vm/clrtocomcall.cpp @@ -389,13 +389,13 @@ static CallsiteDetails CreateCallsiteDetails(_In_ FramedMethodFrame *pFrame) DelegateEEClass* delegateCls = (DelegateEEClass*)pMD->GetMethodTable()->GetClass(); _ASSERTE(pFrame->GetThis()->GetMethodTable()->IsDelegate()); - if (pMD == delegateCls->m_pBeginInvokeMethod) + if (strcmp(pMD->GetName(), "BeginInvoke") == 0) { callsiteFlags |= CallsiteDetails::BeginInvoke; } else { - _ASSERTE(pMD == delegateCls->m_pEndInvokeMethod); + _ASSERTE(strcmp(pMD->GetName(), "EndInvoke") == 0); callsiteFlags |= CallsiteDetails::EndInvoke; } diff --git a/src/coreclr/vm/codeman.h b/src/coreclr/vm/codeman.h index 0ff86927b6a584..7ea0d5dbff8b70 100644 --- a/src/coreclr/vm/codeman.h +++ b/src/coreclr/vm/codeman.h @@ -108,9 +108,6 @@ enum StubCodeBlockKind : int STUB_CODE_BLOCK_NOCODE, STUB_CODE_BLOCK_MANAGED, STUB_CODE_BLOCK_STUBLINK, - // Placeholdes used by NGen images - STUB_CODE_BLOCK_VIRTUAL_METHOD_THUNK, - STUB_CODE_BLOCK_EXTERNAL_METHOD_THUNK, // Placeholdes used by ReadyToRun images STUB_CODE_BLOCK_METHOD_CALL_THUNK, }; diff --git a/src/coreclr/vm/comdelegate.cpp b/src/coreclr/vm/comdelegate.cpp index 2cb10d29b1a28b..63eee56011bb0c 100644 --- a/src/coreclr/vm/comdelegate.cpp +++ b/src/coreclr/vm/comdelegate.cpp @@ -1945,19 +1945,8 @@ PCODE COMDelegate::GetInvokeMethodStub(EEImplMethodDesc* pMD) } else { - - // Since we do not support asynchronous delegates in CoreCLR, we much ensure that it was indeed a async delegate call - // and not an invalid-delegate-layout condition. - // - // If the call was indeed for async delegate invocation, we will just throw an exception. - if ((pMD == pClass->GetBeginInvokeMethod()) || (pMD == pClass->GetEndInvokeMethod())) - { - COMPlusThrow(kPlatformNotSupportedException); - } - - - _ASSERTE(!"Bad Delegate layout"); - COMPlusThrow(kInvalidProgramException); + // We do not support asynchronous delegates in CoreCLR + COMPlusThrow(kPlatformNotSupportedException); } RETURN ret; @@ -2137,8 +2126,7 @@ FCIMPL1(PCODE, COMDelegate::GetMulticastInvoke, MethodTable* pDelegateMT) _ASSERTE(pDelegateMT != NULL); DelegateEEClass* delegateEEClass = (DelegateEEClass*)pDelegateMT->GetClass(); - Stub *pStub = delegateEEClass->m_pMultiCastInvokeStub; - return (pStub != NULL) ? pStub->GetEntryPoint() : (PCODE)NULL; + return delegateEEClass->m_pMultiCastInvokeStub; } FCIMPLEND @@ -2147,13 +2135,13 @@ extern "C" PCODE QCALLTYPE Delegate_GetMulticastInvokeSlow(MethodTable* pDelegat QCALL_CONTRACT; _ASSERTE(pDelegateMT != NULL); - PCODE fptr = (PCODE)NULL; + PCODE pStub = (PCODE)NULL; BEGIN_QCALL; DelegateEEClass *delegateEEClass = (DelegateEEClass*)pDelegateMT->GetClass(); - Stub *pStub = delegateEEClass->m_pMultiCastInvokeStub; - if (pStub == NULL) + pStub = delegateEEClass->m_pMultiCastInvokeStub; + if (pStub == (PCODE)NULL) { MethodDesc* pMD = delegateEEClass->GetInvokeMethod(); @@ -2263,17 +2251,15 @@ extern "C" PCODE QCALLTYPE Delegate_GetMulticastInvokeSlow(MethodTable* pDelegat pSig, cbSig, NULL, &sl); - pStub = Stub::NewStub(JitILStub(pStubMD)); + pStub = JitILStub(pStubMD); - InterlockedCompareExchangeT(&delegateEEClass->m_pMultiCastInvokeStub, pStub, NULL); + InterlockedCompareExchangeT(&delegateEEClass->m_pMultiCastInvokeStub, pStub, (PCODE)NULL); pStub = delegateEEClass->m_pMultiCastInvokeStub; } - fptr = pStub->GetEntryPoint(); - END_QCALL; - return fptr; + return pStub; } PCODE COMDelegate::GetWrapperInvoke(MethodDesc* pMD) @@ -2288,11 +2274,10 @@ PCODE COMDelegate::GetWrapperInvoke(MethodDesc* pMD) MethodTable * pDelegateMT = pMD->GetMethodTable(); DelegateEEClass* delegateEEClass = (DelegateEEClass*) pDelegateMT->GetClass(); - Stub *pStub = delegateEEClass->m_pWrapperDelegateInvokeStub; + PCODE pStub = delegateEEClass->m_pWrapperDelegateInvokeStub; - if (pStub == NULL) + if (pStub == (PCODE)NULL) { - GCX_PREEMP(); MetaSig sig(pMD); @@ -2333,12 +2318,12 @@ PCODE COMDelegate::GetWrapperInvoke(MethodDesc* pMD) NULL, &sl); - pStub = Stub::NewStub(JitILStub(pStubMD)); - - InterlockedCompareExchangeT(&delegateEEClass->m_pWrapperDelegateInvokeStub, pStub, NULL); + pStub = JitILStub(pStubMD); + InterlockedCompareExchangeT(&delegateEEClass->m_pWrapperDelegateInvokeStub, pStub, (PCODE)NULL); + pStub = delegateEEClass->m_pWrapperDelegateInvokeStub; } - return pStub->GetEntryPoint(); + return pStub; } diff --git a/src/coreclr/vm/comdelegate.h b/src/coreclr/vm/comdelegate.h index bb12973f505e25..a195264acdb23f 100644 --- a/src/coreclr/vm/comdelegate.h +++ b/src/coreclr/vm/comdelegate.h @@ -213,7 +213,7 @@ class ShuffleThunkCache : public StubCacheBase STANDARD_VM_CONTRACT; ((CPUSTUBLINKER*)pstublinker)->EmitShuffleThunk((ShuffleEntry*)pRawStub); - return NEWSTUB_FL_THUNK; + return NEWSTUB_FL_SHUFFLE_THUNK; } //--------------------------------------------------------- diff --git a/src/coreclr/vm/methodtablebuilder.cpp b/src/coreclr/vm/methodtablebuilder.cpp index dfa63c2d02141b..205060bff044ef 100644 --- a/src/coreclr/vm/methodtablebuilder.cpp +++ b/src/coreclr/vm/methodtablebuilder.cpp @@ -6138,15 +6138,9 @@ MethodTableBuilder::InitMethodDesc( BAD_FORMAT_NOTHROW_ASSERT(((DelegateEEClass*)GetHalfBakedClass())->m_pInvokeMethod == NULL); ((DelegateEEClass*)GetHalfBakedClass())->m_pInvokeMethod = pNewMD; } - else if (strcmp(pMethodName, "BeginInvoke") == 0) + else if (strcmp(pMethodName, "BeginInvoke") == 0 || strcmp(pMethodName, "EndInvoke") == 0) { - BAD_FORMAT_NOTHROW_ASSERT(((DelegateEEClass*)GetHalfBakedClass())->m_pBeginInvokeMethod == NULL); - ((DelegateEEClass*)GetHalfBakedClass())->m_pBeginInvokeMethod = pNewMD; - } - else if (strcmp(pMethodName, "EndInvoke") == 0) - { - BAD_FORMAT_NOTHROW_ASSERT(((DelegateEEClass*)GetHalfBakedClass())->m_pEndInvokeMethod == NULL); - ((DelegateEEClass*)GetHalfBakedClass())->m_pEndInvokeMethod = pNewMD; + // Obsolete async methods } else { diff --git a/src/coreclr/vm/stublink.cpp b/src/coreclr/vm/stublink.cpp index be99fec4577707..efe9f73776a9ae 100644 --- a/src/coreclr/vm/stublink.cpp +++ b/src/coreclr/vm/stublink.cpp @@ -350,7 +350,6 @@ StubLinker::StubLinker() m_pCodeElements = NULL; m_pFirstCodeLabel = NULL; m_pFirstLabelRef = NULL; - m_pPatchLabel = NULL; m_pTargetMethod = NULL; m_stackSize = 0; m_fDataOnly = FALSE; @@ -622,26 +621,6 @@ CodeLabel* StubLinker::EmitNewCodeLabel() } -//--------------------------------------------------------------- -// Creates & emits the patch offset label for the stub -//--------------------------------------------------------------- -VOID StubLinker::EmitPatchLabel() -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - // - // Note that it's OK to have re-emit the patch label, - // just use the later one. - // - - m_pPatchLabel = EmitNewCodeLabel(); -} - //--------------------------------------------------------------- // Returns final location of label as an offset from the start // of the stub. Can only be called after linkage. @@ -1099,31 +1078,15 @@ bool StubLinker::EmitStub(Stub* pStub, int globalsize, int totalSize, LoaderHeap ZeroMemory(pCodeRW + lastCodeOffset, globalsize - lastCodeOffset); } - // Set additional stub data. - // - Fill in the target method for the Instantiating stub. - // - // - Fill in patch offset, if we have one - // Note that these offsets are relative to the start of the stub, - // not the code, so you'll have to add sizeof(Stub) to get to the - // right spot. + // Fill in the target method for the Instantiating stub. if (pStubRW->IsInstantiatingStub()) { _ASSERTE(m_pTargetMethod != NULL); - _ASSERTE(m_pPatchLabel == NULL); pStubRW->SetInstantiatedMethodDesc(m_pTargetMethod); LOG((LF_CORDB, LL_INFO100, "SL::ES: InstantiatedMethod fd:0x%x\n", pStub->GetInstantiatedMethodDesc())); } - else if (m_pPatchLabel != NULL) - { - UINT32 uLabelOffset = GetLabelOffset(m_pPatchLabel); - _ASSERTE(FitsIn(uLabelOffset)); - pStubRW->SetPatchOffset(static_cast(uLabelOffset)); - - LOG((LF_CORDB, LL_INFO100, "SL::ES: patch offset:0x%x\n", - pStub->GetPatchOffset())); - } #ifdef STUBLINKER_GENERATES_UNWIND_INFO if (pStub->HasUnwindInfo()) @@ -2260,8 +2223,8 @@ void Stub::SetupStub(int numCodeBytes, DWORD flags m_numCodeBytesAndFlags |= EXTERNAL_ENTRY_BIT; if ((flags & NEWSTUB_FL_INSTANTIATING_METHOD) != 0) m_numCodeBytesAndFlags |= INSTANTIATING_STUB_BIT; - if ((flags & NEWSTUB_FL_THUNK) != 0) - m_numCodeBytesAndFlags |= THUNK_BIT; + if ((flags & NEWSTUB_FL_SHUFFLE_THUNK) != 0) + m_numCodeBytesAndFlags |= SHUFFLE_THUNK_BIT; } #ifdef STUBLINKER_GENERATES_UNWIND_INFO diff --git a/src/coreclr/vm/stublink.h b/src/coreclr/vm/stublink.h index 3d01f2b6561d68..4856aa2e709b82 100644 --- a/src/coreclr/vm/stublink.h +++ b/src/coreclr/vm/stublink.h @@ -184,12 +184,6 @@ class StubLinker //--------------------------------------------------------------- VOID EmitLabel(CodeLabel* pCodeLabel); - //--------------------------------------------------------------- - // Emits the patch label for the stub. - // Throws exception on failure. - //--------------------------------------------------------------- - void EmitPatchLabel(); - //--------------------------------------------------------------- // Create a new label to an external address. // Throws exception on failure. @@ -280,9 +274,6 @@ class StubLinker CodeElement *m_pCodeElements; // stored in *reverse* order CodeLabel *m_pFirstCodeLabel; // linked list of CodeLabels LabelRef *m_pFirstLabelRef; // linked list of references - CodeLabel *m_pPatchLabel; // label of stub patch offset - // currently just for multicast - // frames. PTR_MethodDesc m_pTargetMethod; // Used for instantiating stubs. SHORT m_stackSize; // count of pushes/pops CQuickHeap m_quickHeap; // throwaway heap for @@ -452,7 +443,7 @@ enum NewStubFlags NEWSTUB_FL_MULTICAST = 0x00000002, NEWSTUB_FL_EXTERNAL = 0x00000004, NEWSTUB_FL_LOADERHEAP = 0x00000008, - NEWSTUB_FL_THUNK = 0x00000010 + NEWSTUB_FL_SHUFFLE_THUNK = 0x00000010 }; @@ -477,12 +468,12 @@ class Stub LOADER_HEAP_BIT = 0x20000000, INSTANTIATING_STUB_BIT = 0x10000000, UNWIND_INFO_BIT = 0x08000000, - THUNK_BIT = 0x04000000, + SHUFFLE_THUNK_BIT = 0x04000000, - CODEBYTES_MASK = THUNK_BIT - 1, + CODEBYTES_MASK = SHUFFLE_THUNK_BIT - 1, MAX_CODEBYTES = CODEBYTES_MASK + 1, }; - static_assert_no_msg(CODEBYTES_MASK < THUNK_BIT); + static_assert_no_msg(CODEBYTES_MASK < SHUFFLE_THUNK_BIT); public: //------------------------------------------------------------------- @@ -530,46 +521,10 @@ class Stub //------------------------------------------------------------------- // Used by the debugger to help step through stubs //------------------------------------------------------------------- - BOOL IsManagedThunk() - { - LIMITED_METHOD_CONTRACT; - return (m_numCodeBytesAndFlags & THUNK_BIT) != 0; - } - - //------------------------------------------------------------------- - // For stubs which execute user code, a patch offset needs to be set - // to tell the debugger how far into the stub code the debugger has - // to step until the frame is set up. - //------------------------------------------------------------------- - void SetPatchOffset(USHORT offset) - { - LIMITED_METHOD_CONTRACT; - _ASSERTE(!IsInstantiatingStub()); - m_data.PatchOffset = offset; - } - - //------------------------------------------------------------------- - // For stubs which execute user code, a patch offset needs to be set - // to tell the debugger how far into the stub code the debugger has - // to step until the frame is set up. - //------------------------------------------------------------------- - USHORT GetPatchOffset() - { - LIMITED_METHOD_CONTRACT; - _ASSERTE(!IsInstantiatingStub()); - return m_data.PatchOffset; - } - - //------------------------------------------------------------------- - // For stubs which execute user code, a patch offset needs to be set - // to tell the debugger how far into the stub code the debugger has - // to step until the frame is set up. - //------------------------------------------------------------------- - TADDR GetPatchAddress() + BOOL IsShuffleThunk() { LIMITED_METHOD_CONTRACT; - _ASSERTE(!IsInstantiatingStub()); - return dac_cast(GetEntryPointInternal()) + GetPatchOffset(); + return (m_numCodeBytesAndFlags & SHUFFLE_THUNK_BIT) != 0; } //------------------------------------------------------------------- @@ -834,8 +789,8 @@ class Stub UINT32 m_numCodeBytesAndFlags; union { - USHORT PatchOffset; - PTR_MethodDesc InstantiatedMethod; + // Stub kind specific data + PTR_MethodDesc InstantiatedMethod; // Valid for IsInstantiatingStub() only } m_data; #ifdef _DEBUG diff --git a/src/coreclr/vm/stubmgr.cpp b/src/coreclr/vm/stubmgr.cpp index f2e47656ee0aa9..d7f18a4a54cf22 100644 --- a/src/coreclr/vm/stubmgr.cpp +++ b/src/coreclr/vm/stubmgr.cpp @@ -1285,21 +1285,14 @@ BOOL StubLinkStubManager::DoTraceStub(PCODE stubStartAddress, LOG_TRACE_DESTINATION(trace, stubStartAddress, "StubLinkStubManager(InstantiatingMethod)::DoTraceStub"); return TRUE; } - else if (stub->IsManagedThunk()) + else if (stub->IsShuffleThunk()) { trace->InitForManagerPush(stubStartAddress, this); - LOG_TRACE_DESTINATION(trace, stubStartAddress, "StubLinkStubManager(ManagedThunk)::DoTraceStub"); - return TRUE; - } - else if (stub->GetPatchOffset() != 0) - { - // The patch offset is currently only non-zero in x86 non-IL delegate scenarios. - trace->InitForFramePush((PCODE)stub->GetPatchAddress()); - LOG_TRACE_DESTINATION(trace, stubStartAddress, "StubLinkStubManager::DoTraceStub"); + LOG_TRACE_DESTINATION(trace, stubStartAddress, "StubLinkStubManager(ShuffleThunk)::DoTraceStub"); return TRUE; } - LOG((LF_CORDB, LL_INFO10000, "StubLinkStubManager::DoTraceStub: patch offset is 0!\n")); + LOG((LF_CORDB, LL_INFO10000, "StubLinkStubManager::DoTraceStub: no known target\n")); return FALSE; } @@ -1332,9 +1325,7 @@ static PCODE GetStubTarget(PTR_MethodDesc pTargetMD) return targetCode.GetNativeCode(); } -// Managed thunks are often implemented in terms of Delegates -// so the below utilizes Delegate internals. -static BOOL TraceManagedThunk( +static BOOL TraceShuffleThunk( TraceDestination *trace, T_CONTEXT *pContext, BYTE **pRetAddr) @@ -1345,89 +1336,14 @@ static BOOL TraceManagedThunk( } CONTRACTL_END; - PCODE destAddr; - PCODE pc = ::GetIP(pContext); - - // Retrieve the this pointer from the context. -#if defined(TARGET_X86) - (*pRetAddr) = *(BYTE **)(size_t)(pContext->Esp); - - BYTE* pThis = (BYTE*)(size_t)(pContext->Ecx); - - destAddr = *(PCODE*)(pThis + DelegateObject::GetOffsetOfMethodPtrAux()); - -#elif defined(TARGET_AMD64) - - // - // We need to check whether the following is the correct return address. - // - (*pRetAddr) = *(BYTE **)(size_t)(pContext->Rsp); - - LOG((LF_CORDB, LL_INFO10000, "TraceManagedThunk: at %p, retAddr is %p\n", pc, (*pRetAddr))); - - // NOTE: This doesn't work correctly and we anticipate changing it in the future. See - // the discussion at https://github.com/dotnet/runtime/pull/104731/files#r1693796408 - // for details. - DELEGATEREF orDelegate; - if (GetEEFuncEntryPoint(SinglecastDelegateInvokeStub) == pc) - { - LOG((LF_CORDB, LL_INFO10000, "TraceManagedThunk: isSingle\n")); - - orDelegate = (DELEGATEREF)ObjectToOBJECTREF(StubManagerHelpers::GetThisPtr(pContext)); - destAddr = orDelegate->GetMethodPtr(); - if (StubManager::TraceStub(destAddr, trace)) - { - LOG((LF_CORDB,LL_INFO10000, "TraceManagedThunk: ppbDest: %p\n", destAddr)); - LOG((LF_CORDB,LL_INFO10000, "TraceManagedThunk: res: 1, result type: %d\n", trace->GetTraceType())); - return TRUE; - } - } - else - { - // We get here if we are stopped at the beginning of a shuffle thunk. - // The next address we are going to is _methodPtrAux. - Stub* pStub = Stub::RecoverStub(pc); - - // We use the patch offset field to indicate whether the stub has a hidden return buffer argument. - // This field is set in SetupShuffleThunk(). - orDelegate = (pStub->GetPatchOffset() != 0) - ? (DELEGATEREF)ObjectToOBJECTREF(StubManagerHelpers::GetSecondArg(pContext)) // This stub has a hidden return buffer argument. - : (DELEGATEREF)ObjectToOBJECTREF(StubManagerHelpers::GetThisPtr(pContext)); - } - - destAddr = orDelegate->GetMethodPtrAux(); - -#elif defined(TARGET_ARM) - (*pRetAddr) = (BYTE *)(size_t)(pContext->Lr); - BYTE* pThis = (BYTE*)(size_t)(pContext->R0); - - // Could be in the singlecast invoke stub (in which case the next destination is in _methodPtr) or a - // shuffle thunk (destination in _methodPtrAux). - int offsetOfNextDest = (pc == GetEEFuncEntryPoint(SinglecastDelegateInvokeStub)) - ? DelegateObject::GetOffsetOfMethodPtr() - : DelegateObject::GetOffsetOfMethodPtrAux(); - destAddr = *(PCODE*)(pThis + offsetOfNextDest); - -#elif defined(TARGET_ARM64) - (*pRetAddr) = (BYTE *)(size_t)(pContext->Lr); - BYTE* pThis = (BYTE*)(size_t)(pContext->X0); - - // Could be in the singlecast invoke stub (in which case the next destination is in _methodPtr) or a - // shuffle thunk (destination in _methodPtrAux). - int offsetOfNextDest = (pc == GetEEFuncEntryPoint(SinglecastDelegateInvokeStub)) - ? DelegateObject::GetOffsetOfMethodPtr() - : DelegateObject::GetOffsetOfMethodPtrAux(); - destAddr = *(PCODE*)(pThis + offsetOfNextDest); - -#else - PORTABILITY_ASSERT("TraceManagedThunk"); - destAddr = (PCODE)NULL; -#endif + *pRetAddr = (BYTE *)StubManagerHelpers::GetReturnAddress(pContext); - LOG((LF_CORDB,LL_INFO10000, "TraceManagedThunk: ppbDest: %p\n", destAddr)); + DELEGATEREF orDelegate = (DELEGATEREF)ObjectToOBJECTREF(StubManagerHelpers::GetThisPtr(pContext)); + PCODE destAddr = orDelegate->GetMethodPtrAux(); + LOG((LF_CORDB,LL_INFO10000, "TraceShuffleThunk: ppbDest: %p\n", destAddr)); BOOL res = StubManager::TraceStub(destAddr, trace); - LOG((LF_CORDB,LL_INFO10000, "TraceManagedThunk: res: %d, result type: %d\n", res, trace->GetTraceType())); + LOG((LF_CORDB,LL_INFO10000, "TraceShuffleThunk: res: %d, result type: %d\n", res, trace->GetTraceType())); return res; } @@ -1475,10 +1391,10 @@ BOOL StubLinkStubManager::TraceManager(Thread *thread, BYTE *pbDel = (BYTE *)StubManagerHelpers::GetThisPtr(pContext); return TraceDelegateObject(pbDel, trace); } - else if (stub->IsManagedThunk()) + else if (stub->IsShuffleThunk()) { - LOG((LF_CORDB,LL_INFO10000, "SLSM:TM ManagedThunk\n")); - return TraceManagedThunk(trace, pContext, pRetAddr); + LOG((LF_CORDB,LL_INFO10000, "SLSM:TM ShuffleThunk\n")); + return TraceShuffleThunk(trace, pContext, pRetAddr); } // Runtime bug if we get here. Did we make a change in StubLinkStubManager::DoTraceStub() that @@ -1620,8 +1536,6 @@ BOOL RangeSectionStubManager::CheckIsStub_Internal(PCODE stubStartAddress) case STUB_CODE_BLOCK_PRECODE: case STUB_CODE_BLOCK_JUMPSTUB: case STUB_CODE_BLOCK_STUBLINK: - case STUB_CODE_BLOCK_VIRTUAL_METHOD_THUNK: - case STUB_CODE_BLOCK_EXTERNAL_METHOD_THUNK: case STUB_CODE_BLOCK_METHOD_CALL_THUNK: case STUB_CODE_BLOCK_VSD_DISPATCH_STUB: case STUB_CODE_BLOCK_VSD_RESOLVE_STUB: @@ -1725,12 +1639,6 @@ LPCWSTR RangeSectionStubManager::GetStubManagerName(PCODE addr) case STUB_CODE_BLOCK_STUBLINK: return W("StubLinkStub"); - case STUB_CODE_BLOCK_VIRTUAL_METHOD_THUNK: - return W("VirtualMethodThunk"); - - case STUB_CODE_BLOCK_EXTERNAL_METHOD_THUNK: - return W("ExternalMethodThunk"); - case STUB_CODE_BLOCK_METHOD_CALL_THUNK: return W("MethodCallThunk");