Skip to content

Commit 2fb3629

Browse files
authored
Remove BaseDomain use in LoaderAllocator and event tracing helpers (dotnet#107481)
- Remove `BaseDomain` member on `LoaderAllocator` - Add asserts in functions using `AppDomain` that the loader allocator is collectible and the type is `LAT_Assembly` (so `AssemblyLoaderAllocator` which always had `AppDomain`) - Remove unnecessary `BaseDomain`/`AppDomain` parameters from event tracing helpers - They were always being called with the current app domain
1 parent 62133e0 commit 2fb3629

File tree

9 files changed

+74
-138
lines changed

9 files changed

+74
-138
lines changed

src/coreclr/inc/eventtracebase.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,6 @@ class Module;
689689
class Assembly;
690690
class MethodDesc;
691691
class MethodTable;
692-
class BaseDomain;
693692
class AppDomain;
694693
class SString;
695694
class CrawlFrame;
@@ -750,12 +749,11 @@ namespace ETW
750749
#ifdef FEATURE_EVENT_TRACE
751750
static VOID SendThreadRundownEvent();
752751
static VOID SendGCRundownEvent();
753-
static VOID IterateDomain(BaseDomain *pDomain, DWORD enumerationOptions);
754-
static VOID IterateAppDomain(AppDomain * pAppDomain, DWORD enumerationOptions);
752+
static VOID IterateAppDomain(DWORD enumerationOptions);
755753
static VOID IterateCollectibleLoaderAllocator(AssemblyLoaderAllocator *pLoaderAllocator, DWORD enumerationOptions);
756754
static VOID IterateAssembly(Assembly *pAssembly, DWORD enumerationOptions);
757755
static VOID IterateModule(Module *pModule, DWORD enumerationOptions);
758-
static VOID EnumerationHelper(Module *moduleFilter, BaseDomain *domainFilter, DWORD enumerationOptions);
756+
static VOID EnumerationHelper(Module *moduleFilter, DWORD enumerationOptions);
759757
static DWORD GetEnumerationOptionsFromRuntimeKeywords();
760758
public:
761759
typedef union _EnumerationStructs
@@ -839,7 +837,7 @@ namespace ETW
839837
static VOID SendModuleEvent(Module *pModule, DWORD dwEventOptions, BOOL bFireDomainModuleEvents=FALSE);
840838
static ULONG SendModuleRange(_In_ Module *pModule, _In_ DWORD dwEventOptions);
841839
static VOID SendAssemblyEvent(Assembly *pAssembly, DWORD dwEventOptions);
842-
static VOID SendDomainEvent(BaseDomain *pBaseDomain, DWORD dwEventOptions, LPCWSTR wszFriendlyName=NULL);
840+
static VOID SendDomainEvent(DWORD dwEventOptions, LPCWSTR wszFriendlyName=NULL);
843841
public:
844842
typedef union _LoaderStructs
845843
{
@@ -877,23 +875,23 @@ namespace ETW
877875

878876
}LoaderStructs;
879877

880-
static VOID DomainLoadReal(BaseDomain *pDomain, _In_opt_ LPWSTR wszFriendlyName=NULL);
878+
static VOID DomainLoadReal(_In_opt_ LPWSTR wszFriendlyName=NULL);
881879

882-
static VOID DomainLoad(BaseDomain *pDomain, _In_opt_ LPWSTR wszFriendlyName = NULL)
880+
static VOID DomainLoad(_In_opt_ LPWSTR wszFriendlyName = NULL)
883881
{
884882
if (ETW_PROVIDER_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER))
885883
{
886-
DomainLoadReal(pDomain, wszFriendlyName);
884+
DomainLoadReal(wszFriendlyName);
887885
}
888886
}
889887

890-
static VOID DomainUnload(AppDomain *pDomain);
888+
static VOID DomainUnload();
891889
static VOID CollectibleLoaderAllocatorUnload(AssemblyLoaderAllocator *pLoaderAllocator);
892890
static VOID ModuleLoad(Module *pModule, LONG liReportedSharedModule);
893891
#else
894892
public:
895-
static VOID DomainLoad(BaseDomain *pDomain, _In_opt_ LPWSTR wszFriendlyName=NULL) {};
896-
static VOID DomainUnload(AppDomain *pDomain) {};
893+
static VOID DomainLoad(_In_opt_ LPWSTR wszFriendlyName=NULL) {};
894+
static VOID DomainUnload() {};
897895
static VOID CollectibleLoaderAllocatorUnload(AssemblyLoaderAllocator *pLoaderAllocator) {};
898896
static VOID ModuleLoad(Module *pModule, LONG liReportedSharedModule) {};
899897
#endif // FEATURE_EVENT_TRACE
@@ -904,7 +902,7 @@ namespace ETW
904902
{
905903
friend class ETW::EnumerationLog;
906904
#ifdef FEATURE_EVENT_TRACE
907-
static VOID SendEventsForJitMethods(BaseDomain *pDomainFilter, LoaderAllocator *pLoaderAllocatorFilter, DWORD dwEventOptions);
905+
static VOID SendEventsForJitMethods(BOOL getCodeVersionIds, LoaderAllocator *pLoaderAllocatorFilter, DWORD dwEventOptions);
908906
static VOID SendEventsForJitMethodsHelper(
909907
LoaderAllocator *pLoaderAllocatorFilter,
910908
DWORD dwEventOptions,

src/coreclr/vm/appdomain.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,7 +2014,7 @@ class SystemDomain : public BaseDomain
20142014

20152015
m_pDelayedUnloadListOfLoaderAllocators=NULL;
20162016

2017-
m_GlobalAllocator.Init(this);
2017+
m_GlobalAllocator.Init();
20182018
}
20192019
#endif
20202020

@@ -2023,7 +2023,6 @@ class SystemDomain : public BaseDomain
20232023

20242024
GlobalLoaderAllocator m_GlobalAllocator;
20252025

2026-
20272026
InlineSString<100> m_BaseLibrary;
20282027

20292028
InlineSString<100> m_SystemDirectory;

src/coreclr/vm/assembly.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ Assembly *Assembly::CreateDynamic(AssemblyBinder* pBinder, NativeAssemblyNamePar
456456

457457
// Some of the initialization functions are not virtual. Call through the derived class
458458
// to prevent calling the base class version.
459-
pCollectibleLoaderAllocator->Init(pDomain);
459+
pCollectibleLoaderAllocator->Init();
460460

461461
// Setup the managed proxy now, but do not actually transfer ownership to it.
462462
// Once everything is setup and nothing can fail anymore, the ownership will be

src/coreclr/vm/assemblynative.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ extern "C" INT_PTR QCALLTYPE AssemblyNative_InitializeAssemblyLoadContext(INT_PT
12051205
GCX_PREEMP();
12061206
// Some of the initialization functions are not virtual. Call through the derived class
12071207
// to prevent calling the base class version.
1208-
loaderAllocator->Init(pCurDomain);
1208+
loaderAllocator->Init();
12091209
loaderAllocator->InitVirtualCallStubManager();
12101210

12111211
// Setup the managed proxy now, but do not actually transfer ownership to it.

src/coreclr/vm/corhost.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,11 +559,11 @@ HRESULT CorHost2::CreateAppDomainWithManager(
559559

560560
BEGIN_EXTERNAL_ENTRYPOINT(&hr);
561561

562-
AppDomain* pDomain = SystemDomain::System()->DefaultDomain();
562+
AppDomain* pDomain = AppDomain::GetCurrentDomain();
563563

564564
pDomain->SetFriendlyName(wszFriendlyName);
565565

566-
ETW::LoaderLog::DomainLoad(pDomain, (LPWSTR)wszFriendlyName);
566+
ETW::LoaderLog::DomainLoad((LPWSTR)wszFriendlyName);
567567

568568
if (dwFlags & APPDOMAIN_IGNORE_UNHANDLED_EXCEPTIONS)
569569
pDomain->SetIgnoreUnhandledExceptions();

0 commit comments

Comments
 (0)