@@ -1061,27 +1061,8 @@ void ClassLoader::TryEnsureLoaded(TypeHandle typeHnd, ClassLoadLevel level)
1061
1061
#endif // DACCESS_COMPILE
1062
1062
}
1063
1063
1064
- // This is separated out to avoid the overhead of C++ exception handling in the non-locking case.
1065
1064
/* static */
1066
- TypeHandle ClassLoader::LookupTypeKeyUnderLock (TypeKey *pKey,
1067
- EETypeHashTable *pTable,
1068
- CrstBase *pLock)
1069
- {
1070
- WRAPPER_NO_CONTRACT;
1071
- SUPPORTS_DAC;
1072
-
1073
- // m_AvailableTypesLock has to be taken in cooperative mode to avoid deadlocks during GC
1074
- GCX_MAYBE_COOP_NO_THREAD_BROKEN (!IsGCThread ());
1075
-
1076
- CrstHolder ch (pLock);
1077
- return pTable->GetValue (pKey);
1078
- }
1079
-
1080
- /* static */
1081
- TypeHandle ClassLoader::LookupTypeKey (TypeKey *pKey,
1082
- EETypeHashTable *pTable,
1083
- CrstBase *pLock,
1084
- BOOL fCheckUnderLock )
1065
+ TypeHandle ClassLoader::LookupTypeKey (TypeKey *pKey, EETypeHashTable *pTable)
1085
1066
{
1086
1067
CONTRACTL {
1087
1068
NOTHROW;
@@ -1090,26 +1071,15 @@ TypeHandle ClassLoader::LookupTypeKey(TypeKey *pKey,
1090
1071
PRECONDITION (CheckPointer (pKey));
1091
1072
PRECONDITION (pKey->IsConstructed ());
1092
1073
PRECONDITION (CheckPointer (pTable));
1093
- PRECONDITION (!fCheckUnderLock || CheckPointer (pLock));
1094
1074
MODE_ANY;
1095
1075
SUPPORTS_DAC;
1096
1076
} CONTRACTL_END;
1097
1077
1098
- TypeHandle th;
1099
-
1100
- if (fCheckUnderLock )
1101
- {
1102
- th = LookupTypeKeyUnderLock (pKey, pTable, pLock);
1103
- }
1104
- else
1105
- {
1106
- th = pTable->GetValue (pKey);
1107
- }
1108
- return th;
1078
+ return pTable->GetValue (pKey);
1109
1079
}
1110
1080
1111
1081
/* static */
1112
- TypeHandle ClassLoader::LookupInLoaderModule (TypeKey *pKey, BOOL fCheckUnderLock )
1082
+ TypeHandle ClassLoader::LookupInLoaderModule (TypeKey *pKey)
1113
1083
{
1114
1084
CONTRACTL {
1115
1085
NOTHROW;
@@ -1124,39 +1094,12 @@ TypeHandle ClassLoader::LookupInLoaderModule(TypeKey *pKey, BOOL fCheckUnderLock
1124
1094
Module *pLoaderModule = ComputeLoaderModule (pKey);
1125
1095
PREFIX_ASSUME (pLoaderModule!=NULL );
1126
1096
1127
- return LookupTypeKey (pKey,
1128
- pLoaderModule->GetAvailableParamTypes (),
1129
- &pLoaderModule->GetClassLoader ()->m_AvailableTypesLock ,
1130
- fCheckUnderLock );
1097
+ return LookupTypeKey (pKey, pLoaderModule->GetAvailableParamTypes ());
1131
1098
}
1132
1099
1133
1100
1134
1101
/* static */
1135
1102
TypeHandle ClassLoader::LookupTypeHandleForTypeKey (TypeKey *pKey)
1136
- {
1137
- WRAPPER_NO_CONTRACT;
1138
- SUPPORTS_DAC;
1139
-
1140
- // Make an initial lookup without taking any locks.
1141
- TypeHandle th = LookupTypeHandleForTypeKeyInner (pKey, FALSE );
1142
-
1143
- // A non-null TypeHandle for the above lookup indicates success
1144
- // A null TypeHandle only indicates "well, it might have been there,
1145
- // try again with a lock". This kind of negative result will
1146
- // only happen while accessing the underlying EETypeHashTable
1147
- // during a resize, i.e. very rarely. In such a case, we just
1148
- // perform the lookup again, but indicate that appropriate locks
1149
- // should be taken.
1150
-
1151
- if (th.IsNull ())
1152
- {
1153
- th = LookupTypeHandleForTypeKeyInner (pKey, TRUE );
1154
- }
1155
-
1156
- return th;
1157
- }
1158
- /* static */
1159
- TypeHandle ClassLoader::LookupTypeHandleForTypeKeyInner (TypeKey *pKey, BOOL fCheckUnderLock )
1160
1103
{
1161
1104
CONTRACTL
1162
1105
{
@@ -1184,7 +1127,7 @@ TypeHandle ClassLoader::LookupTypeHandleForTypeKeyInner(TypeKey *pKey, BOOL fChe
1184
1127
// If the thing is not NGEN'd then this may
1185
1128
// be different to pPreferredZapModule. If they are the same then
1186
1129
// we can reuse the results of the lookup above.
1187
- TypeHandle thLM = LookupInLoaderModule (pKey, fCheckUnderLock );
1130
+ TypeHandle thLM = LookupInLoaderModule (pKey);
1188
1131
if (!thLM.IsNull ())
1189
1132
{
1190
1133
return thLM;
@@ -2055,11 +1998,10 @@ VOID ClassLoader::Init(AllocMemTracker *pamTracker)
2055
1998
CrstAvailableClass,
2056
1999
CRST_REENTRANCY);
2057
2000
2058
- // This lock is taken within the classloader whenever we have to insert a new param. type into the table
2059
- // This lock also needs to be taken for a read operation in a GC_NOTRIGGER scope, thus the ANYMODE flag.
2001
+ // This lock is taken within the classloader whenever we have to insert a new param. type into the table.
2060
2002
m_AvailableTypesLock.Init (
2061
- CrstAvailableParamTypes,
2062
- (CrstFlags)(CRST_UNSAFE_ANYMODE | CRST_DEBUGGER_THREAD) );
2003
+ CrstAvailableParamTypes,
2004
+ CRST_DEBUGGER_THREAD);
2063
2005
2064
2006
#ifdef _DEBUG
2065
2007
CorTypeInfo::CheckConsistency ();
@@ -3104,9 +3046,6 @@ TypeHandle ClassLoader::PublishType(TypeKey *pTypeKey, TypeHandle typeHnd)
3104
3046
Module *pLoaderModule = ComputeLoaderModule (pTypeKey);
3105
3047
EETypeHashTable *pTable = pLoaderModule->GetAvailableParamTypes ();
3106
3048
3107
- // m_AvailableTypesLock has to be taken in cooperative mode to avoid deadlocks during GC
3108
- GCX_COOP ();
3109
-
3110
3049
CrstHolder ch (&pLoaderModule->GetClassLoader ()->m_AvailableTypesLock );
3111
3050
3112
3051
// The type could have been loaded by a different thread as side-effect of avoiding deadlocks caused by LoadsTypeViolation
@@ -3121,9 +3060,6 @@ TypeHandle ClassLoader::PublishType(TypeKey *pTypeKey, TypeHandle typeHnd)
3121
3060
Module *pModule = pTypeKey->GetModule ();
3122
3061
mdTypeDef typeDef = pTypeKey->GetTypeToken ();
3123
3062
3124
- // m_AvailableTypesLock has to be taken in cooperative mode to avoid deadlocks during GC
3125
- GCX_COOP ();
3126
-
3127
3063
CrstHolder ch (&pModule->GetClassLoader ()->m_AvailableTypesLock );
3128
3064
3129
3065
// ! We cannot fail after this point.
0 commit comments