Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 9 additions & 42 deletions src/coreclr/vm/appdomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ void SystemDomain::LoadBaseSystemClasses()

// Only partially load the system assembly. Other parts of the code will want to access
// the globals in this function before finishing the load.
m_pSystemAssembly = DefaultDomain()->LoadDomainAssembly(NULL, m_pSystemPEAssembly, FILE_LOAD_POST_LOADLIBRARY)->GetAssembly();
m_pSystemAssembly = DefaultDomain()->LoadDomainAssembly(NULL, m_pSystemPEAssembly, FILE_LOAD_POST_ALLOCATE)->GetAssembly();

// Set up binder for CoreLib
CoreLibBinder::AttachModule(m_pSystemAssembly->GetModule());
Expand Down Expand Up @@ -2119,13 +2119,8 @@ static const char *fileLoadLevelName[] =
{
"CREATE", // FILE_LOAD_CREATE
"BEGIN", // FILE_LOAD_BEGIN
"FIND_NATIVE_IMAGE", // FILE_LOAD_FIND_NATIVE_IMAGE
"VERIFY_NATIVE_IMAGE_DEPENDENCIES", // FILE_LOAD_VERIFY_NATIVE_IMAGE_DEPENDENCIES
"ALLOCATE", // FILE_LOAD_ALLOCATE
"ADD_DEPENDENCIES", // FILE_LOAD_ADD_DEPENDENCIES
"PRE_LOADLIBRARY", // FILE_LOAD_PRE_LOADLIBRARY
"LOADLIBRARY", // FILE_LOAD_LOADLIBRARY
"POST_LOADLIBRARY", // FILE_LOAD_POST_LOADLIBRARY
"POST_ALLOCATE", // FILE_LOAD_POST_ALLOCATE
"EAGER_FIXUPS", // FILE_LOAD_EAGER_FIXUPS
"DELIVER_EVENTS", // FILE_LOAD_DELIVER_EVENTS
"VTABLE FIXUPS", // FILE_LOAD_VTABLE_FIXUPS
Expand Down Expand Up @@ -2193,7 +2188,6 @@ BOOL FileLoadLock::CompleteLoadLevel(FileLoadLevel level, BOOL success)
switch(level)
{
case FILE_LOAD_ALLOCATE:
case FILE_LOAD_ADD_DEPENDENCIES:
case FILE_LOAD_DELIVER_EVENTS:
case FILE_LOADED:
case FILE_ACTIVE: // The timing of stress logs is not critical, so even for the FILE_ACTIVE stage we need not do it while the m_pList lock is held.
Expand Down Expand Up @@ -2809,53 +2803,26 @@ void AppDomain::TryIncrementalLoad(DomainAssembly *pFile, FileLoadLevel workLeve

EX_TRY
{

// Special case: for LoadLibrary, we cannot hold the lock during the
// actual LoadLibrary call, because we might get a callback from _CorDllMain on any
// other thread. (Note that this requires DomainAssembly's LoadLibrary to be independently threadsafe.)

if (workLevel == FILE_LOAD_LOADLIBRARY)
{
lockHolder.Release();
released = TRUE;
}

// Do the work
BOOL success = pFile->DoIncrementalLoad(workLevel);
if (released)
{
// Reobtain lock to increment level. (Note that another thread may
// have already done it which is OK.
if (pLoadLock->Acquire(workLevel))
{
// note lockHolder.Acquire isn't wired up to actually take the lock
lockHolder = pLoadLock;
released = FALSE;
}
}

if (!released)
// Complete the level.
if (pLoadLock->CompleteLoadLevel(workLevel, success) &&
pLoadLock->GetLoadLevel()==FILE_LOAD_DELIVER_EVENTS)
{
// Complete the level.
if (pLoadLock->CompleteLoadLevel(workLevel, success) &&
pLoadLock->GetLoadLevel()==FILE_LOAD_DELIVER_EVENTS)
{
lockHolder.Release();
released = TRUE;
pFile->DeliverAsyncEvents();
};
}
lockHolder.Release();
released = TRUE;
pFile->DeliverAsyncEvents();
};
}
EX_HOOK
{
Exception *pEx = GET_EXCEPTION();


//We will cache this error and wire this load to forever fail,
// unless the exception is transient or the file is loaded OK but just cannot execute
if (!pEx->IsTransient() && !pFile->IsLoaded())
{

if (released)
{
// Reobtain lock to increment level. (Note that another thread may
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/vm/ceeload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4425,11 +4425,6 @@ VOID Module::EnsureAllocated()
GetDomainAssembly()->EnsureAllocated();
}

VOID Module::EnsureLibraryLoaded()
{
STANDARD_VM_CONTRACT;
GetDomainAssembly()->EnsureLibraryLoaded();
}
#endif // !DACCESS_COMPILE

CHECK Module::CheckActivated()
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/ceeload.h
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,6 @@ class Module : public ModuleBase
#ifndef DACCESS_COMPILE
VOID EnsureActive();
VOID EnsureAllocated();
VOID EnsureLibraryLoaded();
#endif

CHECK CheckActivated();
Expand Down
62 changes: 9 additions & 53 deletions src/coreclr/vm/domainassembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,30 +389,12 @@ BOOL DomainAssembly::DoIncrementalLoad(FileLoadLevel level)
Begin();
break;

case FILE_LOAD_FIND_NATIVE_IMAGE:
break;

case FILE_LOAD_VERIFY_NATIVE_IMAGE_DEPENDENCIES:
break;

case FILE_LOAD_ALLOCATE:
Allocate();
break;

case FILE_LOAD_ADD_DEPENDENCIES:
AddDependencies();
break;

case FILE_LOAD_PRE_LOADLIBRARY:
PreLoadLibrary();
break;

case FILE_LOAD_LOADLIBRARY:
LoadLibrary();
break;

case FILE_LOAD_POST_LOADLIBRARY:
PostLoadLibrary();
case FILE_LOAD_POST_ALLOCATE:
PostAllocate();
break;

case FILE_LOAD_EAGER_FIXUPS:
Expand Down Expand Up @@ -453,29 +435,7 @@ BOOL DomainAssembly::DoIncrementalLoad(FileLoadLevel level)
return TRUE;
}

void DomainAssembly::PreLoadLibrary()
{
CONTRACTL
{
INSTANCE_CHECK;
STANDARD_VM_CHECK;
}
CONTRACTL_END;

} // DomainAssembly::PreLoadLibrary

void DomainAssembly::LoadLibrary()
{
CONTRACTL
{
INSTANCE_CHECK;
STANDARD_VM_CHECK;
}
CONTRACTL_END;

}

void DomainAssembly::PostLoadLibrary()
void DomainAssembly::PostAllocate()
{
CONTRACTL
{
Expand Down Expand Up @@ -511,11 +471,6 @@ void DomainAssembly::PostLoadLibrary()
#endif
}

void DomainAssembly::AddDependencies()
{
STANDARD_VM_CONTRACT;
}

void DomainAssembly::EagerFixups()
{
WRAPPER_NO_CONTRACT;
Expand Down Expand Up @@ -744,18 +699,16 @@ void DomainAssembly::Allocate()
INSTANCE_CHECK;
STANDARD_VM_CHECK;
INJECT_FAULT(COMPlusThrowOM(););
PRECONDITION(m_pAssembly == NULL);
}
CONTRACTL_END;

AllocMemTracker amTracker;
AllocMemTracker * pamTracker = &amTracker;

Assembly * pAssembly = m_pAssembly;

if (pAssembly==NULL)
Assembly * pAssembly;
{
//! If you decide to remove "if" do not remove this brace: order is important here - in the case of an exception,
//! the Assembly holder must destruct before the AllocMemTracker declared above.
// Order is important here - in the case of an exception, the Assembly holder must destruct before the AllocMemTracker declared above.
NewHolder<Assembly> assemblyHolder(NULL);

assemblyHolder = pAssembly = Assembly::Create(GetPEAssembly(), GetDebuggerInfoBits(), this->IsCollectible(), pamTracker, this->IsCollectible() ? this->GetLoaderAllocator() : NULL);
Expand All @@ -766,6 +719,9 @@ void DomainAssembly::Allocate()
}

SetAssembly(pAssembly);

// Creating the Assembly should have ensured the PEAssembly is loaded
_ASSERT(GetPEAssembly()->IsLoaded());
}

void DomainAssembly::DeliverAsyncEvents()
Expand Down
18 changes: 2 additions & 16 deletions src/coreclr/vm/domainassembly.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,8 @@ enum FileLoadLevel

FILE_LOAD_CREATE,
FILE_LOAD_BEGIN,
FILE_LOAD_FIND_NATIVE_IMAGE,
FILE_LOAD_VERIFY_NATIVE_IMAGE_DEPENDENCIES,
FILE_LOAD_ALLOCATE,
FILE_LOAD_ADD_DEPENDENCIES,
FILE_LOAD_PRE_LOADLIBRARY,
FILE_LOAD_LOADLIBRARY,
FILE_LOAD_POST_LOADLIBRARY,
FILE_LOAD_POST_ALLOCATE,
FILE_LOAD_EAGER_FIXUPS,
FILE_LOAD_DELIVER_EVENTS,
FILE_LOAD_VTABLE_FIXUPS,
Expand Down Expand Up @@ -222,12 +217,6 @@ class DomainAssembly final
return EnsureLoadLevel(FILE_LOAD_ALLOCATE);
}

void EnsureLibraryLoaded()
{
WRAPPER_NO_CONTRACT;
return EnsureLoadLevel(FILE_LOAD_LOADLIBRARY);
}

// EnsureLoadLevel is a generic routine used to ensure that the file is not in a delay loaded
// state (unless it needs to be.) This should be used when a particular level of loading
// is required for an operation. Note that deadlocks are tolerated so the level may be one
Expand Down Expand Up @@ -309,10 +298,7 @@ class DomainAssembly final
#ifndef DACCESS_COMPILE
void Begin();
void Allocate();
void AddDependencies();
void PreLoadLibrary();
void LoadLibrary();
void PostLoadLibrary();
void PostAllocate();
void EagerFixups();
void VtableFixups();
void DeliverSyncEvents();
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/methodtablebuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ MethodTableBuilder::BuildMethodTableThrowing(
}
CONTRACTL_END;

pModule->EnsureLibraryLoaded();
pModule->EnsureAllocated();

// The following structs, defined as private members of MethodTableBuilder, contain the necessary local
// parameters needed for BuildMethodTable Look at the struct definitions for a detailed list of all
Expand Down