summaryrefslogtreecommitdiff
path: root/src/vm/dllimportcallback.cpp
diff options
context:
space:
mode:
authorJan Vorlicek <janvorli@microsoft.com>2018-10-04 10:18:23 +0200
committerGitHub <noreply@github.com>2018-10-04 10:18:23 +0200
commit11832401739148f1f1e9419cb51180ba5263a41b (patch)
tree91e81791918d307b0bc9f8255d022fd2fbfbd970 /src/vm/dllimportcallback.cpp
parent0068168531e849cbad8388f00f3f23e58d3a01b4 (diff)
downloadcoreclr-11832401739148f1f1e9419cb51180ba5263a41b.tar.gz
coreclr-11832401739148f1f1e9419cb51180ba5263a41b.tar.bz2
coreclr-11832401739148f1f1e9419cb51180ba5263a41b.zip
Remove AppDomain unload (#20250)
* Remove AppDomain unload This change removes all code in AppDomain that's related to AppDomain unloading which is obsolete in CoreCLR. It also removes all calls to the removed methods. In few places, I have made the change simpler by taking into account the fact that there is always just one AppDomain.
Diffstat (limited to 'src/vm/dllimportcallback.cpp')
-rw-r--r--src/vm/dllimportcallback.cpp173
1 files changed, 1 insertions, 172 deletions
diff --git a/src/vm/dllimportcallback.cpp b/src/vm/dllimportcallback.cpp
index 2becba5bfe..c064872981 100644
--- a/src/vm/dllimportcallback.cpp
+++ b/src/vm/dllimportcallback.cpp
@@ -106,70 +106,6 @@ private:
static UMEntryThunkFreeList s_thunkFreeList(DEFAULT_THUNK_FREE_LIST_THRESHOLD);
-EXTERN_C void STDCALL UM2MThunk_WrapperHelper(void *pThunkArgs,
- int argLen,
- void *pAddr,
- UMEntryThunk *pEntryThunk,
- Thread *pThread);
-
-// This is used as target of callback from DoADCallBack. It sets up the environment and effectively
-// calls back into the thunk that needed to switch ADs.
-void UM2MThunk_Wrapper(LPVOID ptr) // UM2MThunk_Args
-{
- STATIC_CONTRACT_THROWS;
- STATIC_CONTRACT_GC_TRIGGERS;
- STATIC_CONTRACT_MODE_COOPERATIVE;
- STATIC_CONTRACT_SO_INTOLERANT;
-
- UM2MThunk_Args *pArgs = (UM2MThunk_Args *) ptr;
- Thread* pThread = GetThread();
-
- BEGIN_CALL_TO_MANAGED();
-
- // return value is saved to pArgs->pThunkArgs
- UM2MThunk_WrapperHelper(pArgs->pThunkArgs,
- pArgs->argLen,
- pArgs->pAddr,
- pArgs->pEntryThunk,
- pThread);
-
- END_CALL_TO_MANAGED();
-}
-
-EXTERN_C void STDCALL UM2MDoADCallBack(UMEntryThunk *pEntryThunk,
- void *pAddr,
- void *pArgs,
- int argLen)
-{
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- MODE_COOPERATIVE;
- ENTRY_POINT;
- PRECONDITION(CheckPointer(pEntryThunk));
- PRECONDITION(CheckPointer(pArgs));
- }
- CONTRACTL_END;
-
- UM2MThunk_Args args = { pEntryThunk, pAddr, pArgs, argLen };
-
-
- INSTALL_MANAGED_EXCEPTION_DISPATCHER;
- INSTALL_UNWIND_AND_CONTINUE_HANDLER;
- {
- AppDomainFromIDHolder domain(pEntryThunk->GetDomainId(),FALSE);
- domain.ThrowIfUnloaded();
- if(!domain->CanReversePInvokeEnter())
- COMPlusThrow(kNotSupportedException);
- }
-
- GetThread()->DoADCallBack(pEntryThunk->GetDomainId(), UM2MThunk_Wrapper, &args);
-
- UNINSTALL_UNWIND_AND_CONTINUE_HANDLER;
- UNINSTALL_MANAGED_EXCEPTION_DISPATCHER;
-}
-
#if defined(_TARGET_X86_) && !defined(FEATURE_STUBS_AS_IL)
EXTERN_C VOID __cdecl UMThunkStubRareDisable();
@@ -198,10 +134,6 @@ VOID UMEntryThunk::CompileUMThunkWorker(UMThunkStubInfo *pInfo,
CodeLabel* pRejoinThreadLabel = pcpusl->NewCodeLabel();
CodeLabel* pDisableGCLabel = pcpusl->NewCodeLabel();
CodeLabel* pRejoinGCLabel = pcpusl->NewCodeLabel();
- CodeLabel* pDoADCallBackLabel = pcpusl->NewCodeLabel();
- CodeLabel* pDoneADCallBackLabel = pcpusl->NewCodeLabel();
- CodeLabel* pADCallBackEpilog = pcpusl->NewCodeLabel();
- CodeLabel* pDoADCallBackStartLabel = pcpusl->NewAbsoluteCodeLabel();
// We come into this code with UMEntryThunk in EAX
const X86Reg kEAXentryThunk = kEAX;
@@ -318,22 +250,6 @@ VOID UMEntryThunk::CompileUMThunkWorker(UMThunkStubInfo *pInfo,
// lea ebx, [ebp + 8]
pcpusl->X86EmitIndexLea(kEBX, kEBP, 8);
- // Load pThread->m_pDomain into edx
- // mov edx,[ecx + offsetof(Thread, m_pAppDomain)]
- pcpusl->X86EmitIndexRegLoad(kEDX, kECXthread, Thread::GetOffsetOfAppDomain());
-
- // Load pThread->m_pAppDomain->m_dwId into edx
- // mov edx,[edx + offsetof(AppDomain, m_dwId)]
- pcpusl->X86EmitIndexRegLoad(kEDX, kEDX, AppDomain::GetOffsetOfId());
-
- // check if the app domain of the thread matches that of delegate
- // cmp edx,[eax + offsetof(UMEntryThunk, m_dwDomainId))]
- pcpusl->X86EmitOffsetModRM(0x3b, kEDX, kEAXentryThunk, offsetof(UMEntryThunk, m_dwDomainId));
-
- // jne pWrongAppDomain ; mismatch. This will call back into the stub with the
- // correct AppDomain through DoADCallBack
- pcpusl->X86EmitCondJump(pDoADCallBackLabel, X86CondCode::kJNE);
-
//
// ----------------------------------------------------------------------------------------------
//
@@ -376,14 +292,6 @@ VOID UMEntryThunk::CompileUMThunkWorker(UMThunkStubInfo *pInfo,
// +-------------------------+
//
- // It's important that the "restart" after an AppDomain switch will skip
- // the check for g_TrapReturningThreads. That's because, during shutdown,
- // we can only go through the UMThunkStubRareDisable pathway if we have
- // not yet pushed a frame. (Once pushed, the frame cannot be popped
- // without coordinating with the GC. During shutdown, such coordination
- // would deadlock).
- pcpusl->EmitLabel(pDoADCallBackStartLabel);
-
// save the thread pointer
pcpusl->X86EmitPushReg(kECXthread);
@@ -564,33 +472,13 @@ VOID UMEntryThunk::CompileUMThunkWorker(UMThunkStubInfo *pInfo,
// restore the thread pointer
pcpusl->X86EmitPopReg(kECXthread);
-
- // Check whether we got here via the switch AD case. We can tell this by looking at whether the
- // caller's arguments immediately precede our EBP frame (they will for the non-switch case but
- // otherwise we will have pushed several frames in the interim). If we did switch now is the time
- // to jump to our inner epilog which will clean up the inner stack frame and return to the runtime
- // AD switching code.
-
- // Does EBX (argument pointer) == EBP + 8?
- // sub ebx, 8
- pcpusl->X86EmitSubReg(kEBX, 8);
-
- // cmp ebx, ebp
- pcpusl->X86EmitR2ROp(0x3B, kEBX, kEBP);
-
- // jne pADCallBackEpilog
- pcpusl->X86EmitCondJump(pADCallBackEpilog, X86CondCode::kJNE);
-
//
// Once we reach this point in the code we're back to a single scenario: the outer frame of the
- // reverse p/invoke. Either we never had to switch AppDomains or the AD switch code has already
- // unwound and returned here to pop off the outer frame.
+ // reverse p/invoke.
//
// ----------------------------------------------------------------------------------------------
//
- pcpusl->EmitLabel(pDoneADCallBackLabel);
-
// move byte ptr [ecx + Thread.m_fPreemptiveGCDisabled],0
pcpusl->X86EmitOffsetModRM(0xc6, (X86Reg)0, kECXthread, Thread::GetOffsetOfGCFlag());
pcpusl->Emit8(0);
@@ -693,47 +581,6 @@ VOID UMEntryThunk::CompileUMThunkWorker(UMThunkStubInfo *pInfo,
pcpusl->X86EmitNearJump(pRejoinGCLabel);
//-------------------------------------------------------------
- // coming here if appdomain didn't match
- //
-
- pcpusl->EmitLabel(pDoADCallBackLabel);
-
- // we will call DoADCallBack which calls into managed code to switch ADs and then calls us
- // back. So when come in the second time the ADs will match and just keep processing.
- // So we need to setup the parms to pass to DoADCallBack one of which is an address inside
- // the stub that will branch back to the top of the stub to start again. Need to setup
- // the parms etc so that when we return from the 2nd call we pop things properly.
-
- // save thread pointer
- pcpusl->X86EmitPushReg(kECXthread);
-
- // push values for UM2MThunk_Args
-
- // Move address of args (EBX) into EDX since some paths below use EBX.
- pcpusl->X86EmitMovRegReg(kEDX, kEBX);
-
- // size of args
- pcpusl->X86EmitPushImm32(pInfo->m_cbSrcStack);
-
- // address of args
- pcpusl->X86EmitPushReg(kEDX);
-
- // addr to call
- pcpusl->X86EmitPushImm32(*pDoADCallBackStartLabel);
-
- // UMEntryThunk
- pcpusl->X86EmitPushReg(kEAXentryThunk);
-
- // call UM2MDoADCallBack
- pcpusl->X86EmitCall(pcpusl->NewExternalCodeLabel((LPVOID) UM2MDoADCallBack), 8);
-
- // We need to clear the thread off the top of the stack and place it in ECX. Two birds with one stone.
- pcpusl->X86EmitPopReg(kECX);
-
- // Re-join the original stub to perform the last parts of the epilog.
- pcpusl->X86EmitNearJump(pDoneADCallBackLabel);
-
- //-------------------------------------------------------------
// Coming here for rare case when enabling GC pre-emptive mode
//
@@ -751,15 +598,6 @@ VOID UMEntryThunk::CompileUMThunkWorker(UMThunkStubInfo *pInfo,
// return to mainline of function
pcpusl->X86EmitNearJump(pEnableRejoin);
-
- //-------------------------------------------------------------
- // Coming here when we switched AppDomain and have successfully called the target. We must return
- // into the runtime code (which will eventually unwind the AD transition and return us to the
- // mainline stub in order to run the outer epilog).
- //
-
- pcpusl->EmitLabel(pADCallBackEpilog);
- pcpusl->X86EmitReturn(0);
}
// Compiles an unmanaged to managed thunk for the given signature.
@@ -1105,15 +943,6 @@ void STDCALL UMEntryThunk::DoRunTimeInit(UMEntryThunk* pUMEntryThunk)
// exceptions don't leak out into managed code.
INSTALL_UNWIND_AND_CONTINUE_HANDLER;
- // The thread object is guaranteed to have been set up at this point.
- Thread *pThread = GetThread();
-
- if (pThread->GetDomain()->GetId() != pUMEntryThunk->GetDomainId())
- {
- // call ourselves again through DoCallBack with a domain transition
- pThread->DoADCallBack(pUMEntryThunk->GetDomainId(), RunTimeInit_Wrapper, pUMEntryThunk);
- }
- else
{
GCX_PREEMP();
pUMEntryThunk->RunTimeInit();