#ifdef FEATURE_COMINTEROP
#include "comtoclrcall.h"
-#include "sxshelpers.h"
#include "runtimecallablewrapper.h"
#include "mngstdinterfaces.h"
#include "olevariant.h"
#include "nativeoverlapped.h"
-#include "compatibilityflags.h"
-
#ifndef FEATURE_PAL
#include "dwreport.h"
#endif // !FEATURE_PAL
#include "clrprivtypecachewinrt.h"
-
-#pragma warning(push)
-#pragma warning(disable:4324)
-#include "marvin32.h"
-#pragma warning(pop)
-
// this file handles string conversion errors for itself
#undef MAKE_TRANSLATIONFAILED
return (GetComOrRemotingFlag() == COMorRemoting_COM);
}
-STDAPI GetXMLObjectEx(IXMLParser **ppv);
-
COMorRemotingFlag AppDomain::GetPreferComInsteadOfManagedRemotingFromConfigFile()
{
CONTRACTL
_ASSERTE(g_pPreallocatedSentinelObject == NULL);
OBJECTREF pPreallocatedSentinalObject = AllocateObject(g_pObjectClass);
-#if CHECK_APP_DOMAIN_LEAKS
- pPreallocatedSentinalObject->SetSyncBlockAppDomainAgile();
-#endif
g_pPreallocatedSentinelObject = CreatePinningHandle( pPreallocatedSentinalObject );
#ifdef FEATURE_PREJIT
EXCEPTIONREF pRudeAbortException = (EXCEPTIONREF)AllocateObject(g_pThreadAbortExceptionClass);
-#if CHECK_APP_DOMAIN_LEAKS
- pRudeAbortException->SetSyncBlockAppDomainAgile();
-#endif
pRudeAbortException->SetHResult(COR_E_THREADABORTED);
pRudeAbortException->SetXCode(EXCEPTION_COMPLUS);
_ASSERTE(g_pPreallocatedRudeThreadAbortException == NULL);
EXCEPTIONREF pAbortException = (EXCEPTIONREF)AllocateObject(g_pThreadAbortExceptionClass);
-#if CHECK_APP_DOMAIN_LEAKS
- pAbortException->SetSyncBlockAppDomainAgile();
-#endif
pAbortException->SetHResult(COR_E_THREADABORTED);
pAbortException->SetXCode(EXCEPTION_COMPLUS);
_ASSERTE(g_pPreallocatedThreadAbortException == NULL);
return Thread::AS_Unknown;
}
-void SystemDomain::SetThreadAptState (IMDInternalImport* pScope, Thread::ApartmentState state)
+void SystemDomain::SetThreadAptState (Thread::ApartmentState state)
{
STANDARD_VM_CONTRACT;
- BOOL fIsLegacy = FALSE;
-
- // Check for legacy behavior regarding COM Apartment state of the main thread.
-
-#define METAMODEL_MAJOR_VER_WITH_NEW_BEHAVIOR 2
-#define METAMODEL_MINOR_VER_WITH_NEW_BEHAVIOR 0
-
- LPCSTR pVer;
- IfFailThrow(pScope->GetVersionString(&pVer));
-
- // Does this look like a version?
- if (pVer != NULL)
- {
- // Is it 'vN.' where N is a digit?
- if ((pVer[0] == 'v' || pVer[0] == 'V') &&
- IS_DIGIT(pVer[1]) &&
- (pVer[2] == '.') )
- {
- // Looks like a version. Is it lesser than v2.0 major version where we start using new behavior?
- fIsLegacy = DIGIT_TO_INT(pVer[1]) < METAMODEL_MAJOR_VER_WITH_NEW_BEHAVIOR;
- }
- }
-
- if (!fIsLegacy && g_pConfig != NULL)
- {
- fIsLegacy = g_pConfig->LegacyApartmentInitPolicy();
- }
-
-
Thread* pThread = GetThread();
_ASSERTE(pThread);
Thread::ApartmentState pState = pThread->SetApartment(Thread::AS_InSTA, TRUE);
_ASSERTE(pState == Thread::AS_InSTA);
}
- else if ((state == Thread::AS_InMTA) || (!fIsLegacy))
+ else if (state == Thread::AS_InMTA)
{
- // If either MTAThreadAttribute is specified or (if no attribute is specified and we are not
- // running in legacy mode), then
- // we will set the apartment state to MTA. The reason for this is to ensure the apartment
- // state is consistent and reliably set. Without this, the apartment state for the main
- // thread would be undefined and would actually be dependent on if the assembly was
- // ngen'd, which other type were loaded, etc.
Thread::ApartmentState pState = pThread->SetApartment(Thread::AS_InMTA, TRUE);
_ASSERTE(pState == Thread::AS_InMTA);
}
#endif // DACCESS_COMPILE
-void AppDomain::CacheStringsForDAC()
-{
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- MODE_ANY;
- }
- CONTRACTL_END;
-
- //
- // If the application base, private bin paths, and configuration file are
- // available, cache them so DAC can read them out of memory
- //
-}
-
#ifndef DACCESS_COMPILE
BOOL AppDomain::AddFileToCache(AssemblySpec* pSpec, PEAssembly *pFile, BOOL fAllowFailure)
setupDomain.Call(args);
}
GCPROTECT_END();
-
- CacheStringsForDAC();
#endif // CROSSGEN_COMPILE
}
// have exited the domain.
//
#ifdef FEATURE_TIERED_COMPILATION
- m_tieredCompilationManager.Shutdown(FALSE);
+ m_tieredCompilationManager.Shutdown();
#endif
//
LOG((LF_APPDOMAIN | LF_CORDB, LL_INFO10, "AppDomain::Domain [%d] %#08x %ls is collected.\n",
GetId().m_dwId, this, GetFriendlyNameForLogging()));
-
-#if CHECK_APP_DOMAIN_LEAKS
- if (g_pConfig->AppDomainLeaks())
- // at this point shouldn't have any non-agile objects in the heap because we finalized all the non-agile ones.
- SyncBlockCache::GetSyncBlockCache()->CheckForUnloadedInstances(GetIndex());
-#endif // CHECK_APP_DOMAIN_LEAKS
{
GCX_PREEMP();
RemoveMemoryPressure();
// 4. Then we can delete all AsyncPinHandle marked with READYTOCLEAN.
IGCHandleStore *pBucketInDefault = SystemDomain::System()->DefaultDomain()->m_handleStore;
- pBucket->RelocateAsyncPinnedHandles(pBucketInDefault);
+ auto clearIfComplete = [](Object* object)
+ {
+ LIMITED_METHOD_CONTRACT;
+
+ assert(object != nullptr);
+ if (object->GetGCSafeMethodTable() != g_pOverlappedDataClass)
+ {
+ return;
+ }
+
+ OVERLAPPEDDATAREF overlapped = (OVERLAPPEDDATAREF)(ObjectToOBJECTREF((Object*)object));
+ if (overlapped->HasCompleted())
+ {
+ // IO has finished. We don't need to pin the user buffer any longer.
+ overlapped->m_userObject = NULL;
+ }
+
+ BashMTForPinnedObject(ObjectToOBJECTREF(object));
+ };
+
+ auto setHandle = [](Object* object, OBJECTHANDLE handle)
+ {
+ LIMITED_METHOD_CONTRACT;
+
+ assert(object != nullptr);
+ assert(handle);
+
+ if (object->GetGCSafeMethodTable() != g_pOverlappedDataClass)
+ {
+ return;
+ }
+
+ OverlappedDataObject* overlapped = (OverlappedDataObject*)object;
+ overlapped->m_pinSelf = handle;
+ };
+
+ pBucket->RelocateAsyncPinnedHandles(pBucketInDefault, clearIfComplete, setHandle);
OverlappedDataObject::RequestCleanup();
}
return pMT;
}
-#ifndef DACCESS_COMPILE
-
-
-//------------------------------------------------------------------------
-BOOL GetCompatibilityFlag(CompatibilityFlag flag)
-{
- CONTRACTL {
- NOTHROW;
- GC_NOTRIGGER;
- SO_TOLERANT;
- } CONTRACTL_END;
-
- return FALSE;
-}
-#endif // !DACCESS_COMPILE
-
//---------------------------------------------------------------------------------------
//
BOOL