diff options
Diffstat (limited to 'src/vm/stubhelpers.cpp')
-rw-r--r-- | src/vm/stubhelpers.cpp | 230 |
1 files changed, 17 insertions, 213 deletions
diff --git a/src/vm/stubhelpers.cpp b/src/vm/stubhelpers.cpp index cbe1d37c94..0a5c143bf4 100644 --- a/src/vm/stubhelpers.cpp +++ b/src/vm/stubhelpers.cpp @@ -21,10 +21,6 @@ #include "comdatetime.h" #include "gcheaputilities.h" #include "interoputil.h" -#include "gcscan.h" -#ifdef FEATURE_REMOTING -#include "remoting.h" -#endif #ifdef FEATURE_COMINTEROP #include <oletls.h> @@ -61,7 +57,7 @@ void StubHelpers::ValidateObjectInternal(Object *pObjUNSAFE, BOOL fValidateNextO } CONTRACTL_END; - _ASSERTE(GCScan::GetGcRuntimeStructuresValid()); + _ASSERTE(GCHeapUtilities::GetGCHeap()->RuntimeStructuresValid()); // validate the object - there's no need to validate next object's // header since we validate the next object explicitly below @@ -162,7 +158,7 @@ void StubHelpers::ProcessByrefValidationList() { entry = s_ByrefValidationEntries[i]; - Object *pObjUNSAFE = GCHeapUtilities::GetGCHeap()->GetContainingObject(entry.pByref); + Object *pObjUNSAFE = GCHeapUtilities::GetGCHeap()->GetContainingObject(entry.pByref, false); ValidateObjectInternal(pObjUNSAFE, TRUE); } } @@ -373,42 +369,6 @@ FORCEINLINE static void *GetCOMIPFromRCW_GetTarget(IUnknown *pUnk, ComPlusCallIn { LIMITED_METHOD_CONTRACT; -#ifndef FEATURE_CORECLR -#ifdef _TARGET_X86_ - // m_pInterceptStub is either NULL if we never called on this method, -1 if we're not - // hosted, or the host hook stub if we are hosted. The stub will extract the real target - // from the 'this' argument. - PVOID pInterceptStub = VolatileLoadWithoutBarrier(&pComInfo->m_pInterceptStub); - - if (pInterceptStub != (LPVOID)-1) - { - if (pInterceptStub != NULL) - { - return pInterceptStub; - } - - if (NDirect::IsHostHookEnabled() || pComInfo->HasCopyCtorArgs()) - { - return NULL; - } - - if (!EnsureWritablePagesNoThrow(&pComInfo->m_pInterceptStub, sizeof(pComInfo->m_pInterceptStub))) - { - return NULL; - } - - pComInfo->m_pInterceptStub = (LPVOID)-1; - } -#else // _TARGET_X86_ -#ifdef FEATURE_INCLUDE_ALL_INTERFACES - if (NDirect::IsHostHookEnabled()) - { - // There's one static stub on !_TARGET_X86_. - return (LPVOID)GetEEFuncEntryPoint(PInvokeStubForHost); - } -#endif // FEATURE_INCLUDE_ALL_INTERFACES -#endif // _TARGET_X86_ -#endif // FEATURE_CORECLR LPVOID *lpVtbl = *(LPVOID **)pUnk; return lpVtbl[pComInfo->m_cachedComSlot]; @@ -435,44 +395,6 @@ NOINLINE static IUnknown* GetCOMIPFromRCWHelper(LPVOID pFCall, OBJECTREF pSrc, M pRetUnk.Release(); } -#ifndef FEATURE_CORECLR -#ifdef _TARGET_X86_ - GCX_PREEMP(); - Stub *pInterceptStub = NULL; - - if (pComInfo->m_pInterceptStub == NULL) - { - if (pComInfo->HasCopyCtorArgs()) - { - // static stub that gets its arguments in a thread-static field - pInterceptStub = NDirect::GetStubForCopyCtor(); - } - - if (NDirect::IsHostHookEnabled()) - { - pInterceptStub = pComInfo->GenerateStubForHost( - pMD->GetDomain()->GetLoaderAllocator()->GetStubHeap(), - pInterceptStub); - } - - EnsureWritablePages(&pComInfo->m_pInterceptStub); - - if (pInterceptStub != NULL) - { - if (InterlockedCompareExchangeT(&pComInfo->m_pInterceptStub, - (LPVOID)pInterceptStub->GetEntryPoint(), - NULL) != NULL) - { - pInterceptStub->DecRef(); - } - } - else - { - pComInfo->m_pInterceptStub = (LPVOID)-1; - } - } -#endif // _TARGET_X86_ -#endif // !FEATURE_CORECLR *ppTarget = GetCOMIPFromRCW_GetTarget(pRetUnk, pComInfo); _ASSERTE(*ppTarget != NULL); @@ -852,10 +774,7 @@ FCIMPL1(StringObject*, StubHelpers::UriMarshaler__GetRawUriFromNative, ABI::Wind GCX_PREEMP(); // Get the RawUri string from the WinRT URI object - { - LeaveRuntimeHolder lrh(**(size_t**)(IUnknown*)pIUriRC); - IfFailThrow(pIUriRC->get_RawUri(hsRawUriName.Address())); - } + IfFailThrow(pIUriRC->get_RawUri(hsRawUriName.Address())); pwszRawUri = hsRawUriName.GetRawBuffer(&cchRawUri); } @@ -904,18 +823,15 @@ StubHelpers::EventArgsMarshaler__CreateNativeNCCEventArgsInstance SafeComHolderPreemp<IInspectable> pInner; HRESULT hr; - { - LeaveRuntimeHolder lrh(**(size_t **)(IUnknown *)pFactory); - hr = pFactory->CreateInstanceWithAllParameters( - (ABI::Windows::UI::Xaml::Interop::NotifyCollectionChangedAction)action, - (ABI::Windows::UI::Xaml::Interop::IBindableVector *)newItem, - (ABI::Windows::UI::Xaml::Interop::IBindableVector *)oldItem, - newIndex, - oldIndex, - NULL, - &pInner, - &pArgsRC); - } + hr = pFactory->CreateInstanceWithAllParameters( + (ABI::Windows::UI::Xaml::Interop::NotifyCollectionChangedAction)action, + (ABI::Windows::UI::Xaml::Interop::IBindableVector *)newItem, + (ABI::Windows::UI::Xaml::Interop::IBindableVector *)oldItem, + newIndex, + oldIndex, + NULL, + &pInner, + &pArgsRC); IfFailThrow(hr); END_QCALL; @@ -937,14 +853,11 @@ ABI::Windows::UI::Xaml::Data::IPropertyChangedEventArgs* QCALLTYPE SafeComHolderPreemp<IInspectable> pInner; HRESULT hr; - { - LeaveRuntimeHolder lrh(**(size_t **)(IUnknown *)pFactory); - hr = pFactory->CreateInstance( - name, - NULL, - &pInner, - &pArgsRC); - } + hr = pFactory->CreateInstance( + name, + NULL, + &pInner, + &pArgsRC); IfFailThrow(hr); END_QCALL; @@ -1261,13 +1174,6 @@ FCIMPL2(void*, StubHelpers::GetDelegateTarget, DelegateObject *pThisUNSAFE, UINT // see IL code gen in NDirectStubLinker::DoNDirect for details. *ppStubArg = target; -#ifdef FEATURE_INCLUDE_ALL_INTERFACES - if (NDirect::IsHostHookEnabled()) - { - // There's one static stub on !_TARGET_X86_. - pEntryPoint = GetEEFuncEntryPoint(PInvokeStubForHost); - } -#endif // FEATURE_INCLUDE_ALL_INTERFACES #elif defined(_TARGET_ARM_) // @ARMTODO: Nothing to do for ARM yet since we don't support the hosted path. #endif // _WIN64, _TARGET_ARM_ @@ -1285,109 +1191,7 @@ FCIMPL2(void*, StubHelpers::GetDelegateTarget, DelegateObject *pThisUNSAFE, UINT } FCIMPLEND -#ifndef FEATURE_CORECLR // CAS -static void DoDeclarativeActionsForPInvoke(MethodDesc* pCurrent) -{ - CONTRACTL - { - MODE_COOPERATIVE; - GC_TRIGGERS; - THROWS; - SO_INTOLERANT; - } - CONTRACTL_END; - - MethodSecurityDescriptor MDSecDesc(pCurrent); - MethodSecurityDescriptor::LookupOrCreateMethodSecurityDescriptor(&MDSecDesc); - - DeclActionInfo* pRuntimeDeclActionInfo = MDSecDesc.GetRuntimeDeclActionInfo(); - if (pRuntimeDeclActionInfo != NULL) - { - // Tell the debugger not to start on any managed code that we call in this method - FrameWithCookie<DebuggerSecurityCodeMarkFrame> __dbgSecFrame; - - Security::DoDeclarativeActions(pCurrent, pRuntimeDeclActionInfo, NULL, &MDSecDesc); - - // Pop the debugger frame - __dbgSecFrame.Pop(); - } -} -#endif // FEATURE_CORECLR - -#ifndef FEATURE_CORECLR -#ifndef _WIN64 -FCIMPL3(void*, StubHelpers::GetFinalStubTarget, LPVOID pStubArg, LPVOID pUnmngThis, DWORD dwFlags) -{ - CONTRACTL - { - FCALL_CHECK; - PRECONDITION(SF_IsForwardStub(dwFlags)); - } - CONTRACTL_END; - if (SF_IsCALLIStub(dwFlags)) - { - // stub argument is the target - return pStubArg; - } - else if (SF_IsDelegateStub(dwFlags)) - { - // stub argument is not used but we pass _methodPtrAux which is the target - return pStubArg; - } - else if (SF_IsCOMStub(dwFlags)) - { - // stub argument is a ComPlusCallMethodDesc - ComPlusCallMethodDesc *pCMD = (ComPlusCallMethodDesc *)pStubArg; - LPVOID *lpVtbl = *(LPVOID **)pUnmngThis; - return lpVtbl[pCMD->m_pComPlusCallInfo->m_cachedComSlot]; - } - else // P/Invoke - { - // secret stub argument is an NDirectMethodDesc - NDirectMethodDesc *pNMD = (NDirectMethodDesc *)pStubArg; - return pNMD->GetNativeNDirectTarget(); - } -} -FCIMPLEND -#endif // !_WIN64 - -FCIMPL1(void, StubHelpers::DemandPermission, NDirectMethodDesc *pNMD) -{ - FCALL_CONTRACT; - - // ETWOnStartup (SecurityCatchCall, SecurityCatchCallEnd); // this is messing up HMF below - - if (pNMD != NULL) - { - g_IBCLogger.LogMethodDescAccess(pNMD); - - if (pNMD->IsInterceptedForDeclSecurity()) - { - if (pNMD->IsInterceptedForDeclSecurityCASDemandsOnly() && - SecurityStackWalk::HasFlagsOrFullyTrusted(1 << SECURITY_UNMANAGED_CODE)) - { - // Track perfmon counters. Runtime security checks. - Security::IncrementSecurityPerfCounter(); - } - else - { - HELPER_METHOD_FRAME_BEGIN_0(); - DoDeclarativeActionsForPInvoke(pNMD); - HELPER_METHOD_FRAME_END(); - } - } - } - else - { - // This is either CLR->COM or delegate P/Invoke (we don't call this helper for CALLI). - HELPER_METHOD_FRAME_BEGIN_0(); - SecurityStackWalk::SpecialDemand(SSWT_DECLARATIVE_DEMAND, SECURITY_UNMANAGED_CODE); - HELPER_METHOD_FRAME_END(); - } -} -FCIMPLEND -#endif // !FEATURE_CORECLR FCIMPL2(void, StubHelpers::ThrowInteropParamException, UINT resID, UINT paramIdx) { |