summaryrefslogtreecommitdiff
path: root/src/vm/clsload.cpp
diff options
context:
space:
mode:
authorDavid Mason <davmason@microsoft.com>2019-03-19 14:00:36 -0700
committerGitHub <noreply@github.com>2019-03-19 14:00:36 -0700
commit5aacb1dfa019eb4865800d05a408665be322ea77 (patch)
treebfb2a61ca00eb9fe50a3fdec5258b062c6f3d9fe /src/vm/clsload.cpp
parent36b8237ad6ce317d8621985ee9a7ade5201f4fc2 (diff)
downloadcoreclr-5aacb1dfa019eb4865800d05a408665be322ea77.tar.gz
coreclr-5aacb1dfa019eb4865800d05a408665be322ea77.tar.bz2
coreclr-5aacb1dfa019eb4865800d05a408665be322ea77.zip
Reintroduce PR #22617 (Update added types and methoddefs on ApplyMetadata) (#23202)
* Add ApplyMetadata changes back This reverts commit f9c10f995fe65c0e7c30aa1734f7bb22c519983d. * Fix race condition in loading available class hash for R2R with old R2R images or profiler modified R2R images
Diffstat (limited to 'src/vm/clsload.cpp')
-rw-r--r--src/vm/clsload.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/vm/clsload.cpp b/src/vm/clsload.cpp
index 4ffbb3fced..323e29ba60 100644
--- a/src/vm/clsload.cpp
+++ b/src/vm/clsload.cpp
@@ -840,7 +840,8 @@ void ClassLoader::GetClassValue(NameHandleTable nhTable,
continue;
#ifdef FEATURE_READYTORUN
- if (nhTable == nhCaseSensitive && pCurrentClsModule->IsReadyToRun() && pCurrentClsModule->GetReadyToRunInfo()->HasHashtableOfTypes())
+ if (nhTable == nhCaseSensitive && pCurrentClsModule->IsReadyToRun() && pCurrentClsModule->GetReadyToRunInfo()->HasHashtableOfTypes() &&
+ pCurrentClsModule->GetAvailableClassHash() == NULL)
{
// For R2R modules, we only search the hashtable of token types stored in the module's image, and don't fallback
// to searching m_pAvailableClasses or m_pAvailableClassesCaseIns (in fact, we don't even allocate them for R2R modules).
@@ -1618,7 +1619,7 @@ BOOL ClassLoader::FindClassModuleThrowing(
EEClassHashEntry_t * pBucket = foundEntry.GetClassHashBasedEntryValue();
- if (pBucket == NULL && needsToBuildHashtable)
+ if (pBucket == NULL)
{
AvailableClasses_LockHolder lh(this);
@@ -1628,7 +1629,7 @@ BOOL ClassLoader::FindClassModuleThrowing(
pBucket = foundEntry.GetClassHashBasedEntryValue();
#ifndef DACCESS_COMPILE
- if ((pBucket == NULL) && (m_cUnhashedModules > 0))
+ if (needsToBuildHashtable && (pBucket == NULL) && (m_cUnhashedModules > 0))
{
_ASSERT(needsToBuildHashtable);
@@ -1650,6 +1651,7 @@ BOOL ClassLoader::FindClassModuleThrowing(
#endif
}
+ // Same check as above, but this time we've checked with the lock so the table will be populated
if (pBucket == NULL)
{
#if defined(_DEBUG_IMPL) && !defined(DACCESS_COMPILE)
@@ -4184,6 +4186,15 @@ VOID ClassLoader::AddAvailableClassDontHaveLock(Module *pModule,
#endif
CrstHolder ch(&m_AvailableClassLock);
+
+ // R2R pre-computes an export table and tries to avoid populating a class hash at runtime. However the profiler can
+ // still add new types on the fly by calling here. If that occurs we fallback to the slower path of creating the
+ // in memory hashtable as usual.
+ if (!pModule->IsResource() && pModule->GetAvailableClassHash() == NULL)
+ {
+ LazyPopulateCaseSensitiveHashTables();
+ }
+
AddAvailableClassHaveLock(
pModule,
classdef,
@@ -4380,6 +4391,15 @@ VOID ClassLoader::AddExportedTypeDontHaveLock(Module *pManifestModule,
CONTRACTL_END
CrstHolder ch(&m_AvailableClassLock);
+
+ // R2R pre-computes an export table and tries to avoid populating a class hash at runtime. However the profiler can
+ // still add new types on the fly by calling here. If that occurs we fallback to the slower path of creating the
+ // in memory hashtable as usual.
+ if (!pManifestModule->IsResource() && pManifestModule->GetAvailableClassHash() == NULL)
+ {
+ LazyPopulateCaseSensitiveHashTables();
+ }
+
AddExportedTypeHaveLock(
pManifestModule,
cl,