Skip to content

Commit 2266376

Browse files
authored
Removing m_hostAssemblyMap and ceremony around it (#61292)
* remove m_hostAssemblyMap and ceremony around it * Removes SHash::AddPhases - support for callouts in hosted scenarios. * typos
1 parent 39ece73 commit 2266376

File tree

10 files changed

+136
-574
lines changed

10 files changed

+136
-574
lines changed

src/coreclr/binder/assembly.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace BINDER_SPACE
2424
m_pAssemblyName = NULL;
2525
m_isInTPA = false;
2626
m_pBinder = NULL;
27+
m_domainAssembly = NULL;
2728
}
2829

2930
Assembly::~Assembly()

src/coreclr/binder/inc/assembly.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
#include "bundle.h"
2929

30+
class DomainAssembly;
31+
3032
namespace BINDER_SPACE
3133
{
3234
// BINDER_SPACE::Assembly represents a result of binding to an actual assembly (PEImage)
@@ -53,12 +55,24 @@ namespace BINDER_SPACE
5355
return m_pBinder;
5456
}
5557

58+
DomainAssembly* GetDomainAssembly()
59+
{
60+
return m_domainAssembly;
61+
}
62+
63+
void SetDomainAssembly(DomainAssembly* value)
64+
{
65+
_ASSERTE(value == NULL || m_domainAssembly == NULL);
66+
m_domainAssembly = value;
67+
}
68+
5669
private:
5770
LONG m_cRef;
5871
PEImage *m_pPEImage;
5972
AssemblyName *m_pAssemblyName;
6073
AssemblyBinder *m_pBinder;
6174
bool m_isInTPA;
75+
DomainAssembly *m_domainAssembly;
6276

6377
inline void SetBinder(AssemblyBinder *pBinder)
6478
{

src/coreclr/inc/CrstTypes.def

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,6 @@ Crst HandleTable
236236
SameLevelAs HandleTable
237237
End
238238

239-
Crst HostAssemblyMap
240-
End
241-
242-
Crst HostAssemblyMapAdd
243-
AcquiredBefore HostAssemblyMap
244-
End
245-
246239
Crst IbcProfile
247240
End
248241

@@ -586,4 +579,4 @@ End
586579

587580
Crst PgoData
588581
AcquiredBefore LoaderHeap
589-
End
582+
End

src/coreclr/inc/crsttypes.h

Lines changed: 78 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//
22
// Licensed to the .NET Foundation under one or more agreements.
33
// The .NET Foundation licenses this file to you under the MIT license.
4-
// See the LICENSE file in the project root for more information.
54
//
65

76
#ifndef __CRST_TYPES_INCLUDED
@@ -11,7 +10,7 @@
1110

1211
// This file describes the range of Crst types available and their mapping to a numeric level (used by the
1312
// runtime in debug mode to validate we're deadlock free). To modify these settings edit the
14-
// file:CrstTypes.def file and run the clr\bin\CrstTypeTool utility to generate a new version of this file.
13+
// file:CrstTypes.def file and run the clr\artifacts\CrstTypeTool utility to generate a new version of this file.
1514

1615
// Each Crst type is declared as a value in the following CrstType enum.
1716
enum CrstType
@@ -59,85 +58,83 @@ enum CrstType
5958
CrstGCCover = 40,
6059
CrstGlobalStrLiteralMap = 41,
6160
CrstHandleTable = 42,
62-
CrstHostAssemblyMap = 43,
63-
CrstHostAssemblyMapAdd = 44,
64-
CrstIbcProfile = 45,
65-
CrstIJWFixupData = 46,
66-
CrstIJWHash = 47,
67-
CrstILStubGen = 48,
68-
CrstInlineTrackingMap = 49,
69-
CrstInstMethodHashTable = 50,
70-
CrstInterop = 51,
71-
CrstInteropData = 52,
72-
CrstIsJMCMethod = 53,
73-
CrstISymUnmanagedReader = 54,
74-
CrstJit = 55,
75-
CrstJitGenericHandleCache = 56,
76-
CrstJitInlineTrackingMap = 57,
77-
CrstJitPatchpoint = 58,
78-
CrstJitPerf = 59,
79-
CrstJumpStubCache = 60,
80-
CrstLeafLock = 61,
81-
CrstListLock = 62,
82-
CrstLoaderAllocator = 63,
83-
CrstLoaderAllocatorReferences = 64,
84-
CrstLoaderHeap = 65,
85-
CrstManagedObjectWrapperMap = 66,
86-
CrstMethodDescBackpatchInfoTracker = 67,
87-
CrstModule = 68,
88-
CrstModuleFixup = 69,
89-
CrstModuleLookupTable = 70,
90-
CrstMulticoreJitHash = 71,
91-
CrstMulticoreJitManager = 72,
92-
CrstNativeImageEagerFixups = 73,
93-
CrstNativeImageLoad = 74,
94-
CrstNls = 75,
95-
CrstNotifyGdb = 76,
96-
CrstObjectList = 77,
97-
CrstPEImage = 78,
98-
CrstPendingTypeLoadEntry = 79,
99-
CrstPgoData = 80,
100-
CrstPinnedByrefValidation = 81,
101-
CrstProfilerGCRefDataFreeList = 82,
102-
CrstProfilingAPIStatus = 83,
103-
CrstRCWCache = 84,
104-
CrstRCWCleanupList = 85,
105-
CrstReadyToRunEntryPointToMethodDescMap = 86,
106-
CrstReflection = 87,
107-
CrstReJITGlobalRequest = 88,
108-
CrstRetThunkCache = 89,
109-
CrstSavedExceptionInfo = 90,
110-
CrstSaveModuleProfileData = 91,
111-
CrstSecurityStackwalkCache = 92,
112-
CrstSigConvert = 93,
113-
CrstSingleUseLock = 94,
114-
CrstSpecialStatics = 95,
115-
CrstStackSampler = 96,
116-
CrstStressLog = 97,
117-
CrstStubCache = 98,
118-
CrstStubDispatchCache = 99,
119-
CrstStubUnwindInfoHeapSegments = 100,
120-
CrstSyncBlockCache = 101,
121-
CrstSyncHashLock = 102,
122-
CrstSystemBaseDomain = 103,
123-
CrstSystemDomain = 104,
124-
CrstSystemDomainDelayedUnloadList = 105,
125-
CrstThreadIdDispenser = 106,
126-
CrstThreadpoolTimerQueue = 107,
127-
CrstThreadpoolWaitThreads = 108,
128-
CrstThreadpoolWorker = 109,
129-
CrstThreadStore = 110,
130-
CrstTieredCompilation = 111,
131-
CrstTypeEquivalenceMap = 112,
132-
CrstTypeIDMap = 113,
133-
CrstUMEntryThunkCache = 114,
134-
CrstUMEntryThunkFreeListLock = 115,
135-
CrstUniqueStack = 116,
136-
CrstUnresolvedClassLock = 117,
137-
CrstUnwindInfoTableLock = 118,
138-
CrstVSDIndirectionCellLock = 119,
139-
CrstWrapperTemplate = 120,
140-
kNumberOfCrstTypes = 121
61+
CrstIbcProfile = 43,
62+
CrstIJWFixupData = 44,
63+
CrstIJWHash = 45,
64+
CrstILStubGen = 46,
65+
CrstInlineTrackingMap = 47,
66+
CrstInstMethodHashTable = 48,
67+
CrstInterop = 49,
68+
CrstInteropData = 50,
69+
CrstIsJMCMethod = 51,
70+
CrstISymUnmanagedReader = 52,
71+
CrstJit = 53,
72+
CrstJitGenericHandleCache = 54,
73+
CrstJitInlineTrackingMap = 55,
74+
CrstJitPatchpoint = 56,
75+
CrstJitPerf = 57,
76+
CrstJumpStubCache = 58,
77+
CrstLeafLock = 59,
78+
CrstListLock = 60,
79+
CrstLoaderAllocator = 61,
80+
CrstLoaderAllocatorReferences = 62,
81+
CrstLoaderHeap = 63,
82+
CrstManagedObjectWrapperMap = 64,
83+
CrstMethodDescBackpatchInfoTracker = 65,
84+
CrstModule = 66,
85+
CrstModuleFixup = 67,
86+
CrstModuleLookupTable = 68,
87+
CrstMulticoreJitHash = 69,
88+
CrstMulticoreJitManager = 70,
89+
CrstNativeImageEagerFixups = 71,
90+
CrstNativeImageLoad = 72,
91+
CrstNls = 73,
92+
CrstNotifyGdb = 74,
93+
CrstObjectList = 75,
94+
CrstPEImage = 76,
95+
CrstPendingTypeLoadEntry = 77,
96+
CrstPgoData = 78,
97+
CrstPinnedByrefValidation = 79,
98+
CrstProfilerGCRefDataFreeList = 80,
99+
CrstProfilingAPIStatus = 81,
100+
CrstRCWCache = 82,
101+
CrstRCWCleanupList = 83,
102+
CrstReadyToRunEntryPointToMethodDescMap = 84,
103+
CrstReflection = 85,
104+
CrstReJITGlobalRequest = 86,
105+
CrstRetThunkCache = 87,
106+
CrstSavedExceptionInfo = 88,
107+
CrstSaveModuleProfileData = 89,
108+
CrstSecurityStackwalkCache = 90,
109+
CrstSigConvert = 91,
110+
CrstSingleUseLock = 92,
111+
CrstSpecialStatics = 93,
112+
CrstStackSampler = 94,
113+
CrstStressLog = 95,
114+
CrstStubCache = 96,
115+
CrstStubDispatchCache = 97,
116+
CrstStubUnwindInfoHeapSegments = 98,
117+
CrstSyncBlockCache = 99,
118+
CrstSyncHashLock = 100,
119+
CrstSystemBaseDomain = 101,
120+
CrstSystemDomain = 102,
121+
CrstSystemDomainDelayedUnloadList = 103,
122+
CrstThreadIdDispenser = 104,
123+
CrstThreadpoolTimerQueue = 105,
124+
CrstThreadpoolWaitThreads = 106,
125+
CrstThreadpoolWorker = 107,
126+
CrstThreadStore = 108,
127+
CrstTieredCompilation = 109,
128+
CrstTypeEquivalenceMap = 110,
129+
CrstTypeIDMap = 111,
130+
CrstUMEntryThunkCache = 112,
131+
CrstUMEntryThunkFreeListLock = 113,
132+
CrstUniqueStack = 114,
133+
CrstUnresolvedClassLock = 115,
134+
CrstUnwindInfoTableLock = 116,
135+
CrstVSDIndirectionCellLock = 117,
136+
CrstWrapperTemplate = 118,
137+
kNumberOfCrstTypes = 119
141138
};
142139

143140
#endif // __CRST_TYPES_INCLUDED
@@ -191,8 +188,6 @@ int g_rgCrstLevelMap[] =
191188
10, // CrstGCCover
192189
13, // CrstGlobalStrLiteralMap
193190
1, // CrstHandleTable
194-
0, // CrstHostAssemblyMap
195-
3, // CrstHostAssemblyMapAdd
196191
0, // CrstIbcProfile
197192
8, // CrstIJWFixupData
198193
0, // CrstIJWHash
@@ -317,8 +312,6 @@ LPCSTR g_rgCrstNameMap[] =
317312
"CrstGCCover",
318313
"CrstGlobalStrLiteralMap",
319314
"CrstHandleTable",
320-
"CrstHostAssemblyMap",
321-
"CrstHostAssemblyMapAdd",
322315
"CrstIbcProfile",
323316
"CrstIJWFixupData",
324317
"CrstIJWHash",

src/coreclr/inc/shash.h

Lines changed: 3 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,6 @@ class EMPTY_BASES_DECL SHash : public TRAITS
264264
// NoThrow version of CheckGrowth function. Returns FALSE on failure.
265265
BOOL CheckGrowthNoThrow();
266266

267-
// See if it is OK to grow the hash table by one element. If not, allocate new
268-
// hash table and return it together with its size *pcNewSize (used by code:AddPhases).
269-
// Returns NULL if there already is space for one element.
270-
element_t * CheckGrowth_OnlyAllocateNewTable(count_t * pcNewSize);
271-
272267
// Allocates new resized hash table for growth. Does not update the hash table on the object.
273268
// The new size is computed based on the current population, growth factor, and maximum density factor.
274269
element_t * Grow_OnlyAllocateNewTable(count_t * pcNewSize);
@@ -278,7 +273,7 @@ class EMPTY_BASES_DECL SHash : public TRAITS
278273

279274
// Utility function to allocate new table (does not copy the values into it yet). Returns the size of new table in
280275
// *pcNewTableSize (finds next prime).
281-
// Phase 1 of code:Reallocate - it is split to support code:AddPhases.
276+
// Phase 1 of code:Reallocate
282277
element_t * AllocateNewTable(count_t requestedSize, count_t * pcNewTableSize);
283278

284279
// NoThrow version of AllocateNewTable utility function. Returns NULL on failure.
@@ -287,11 +282,11 @@ class EMPTY_BASES_DECL SHash : public TRAITS
287282
// Utility function to replace old table with newly allocated table (as allocated by
288283
// code:AllocateNewTable). Copies all 'old' values into the new table first.
289284
// Returns the old table. Caller is expected to delete it (via code:DeleteOldTable).
290-
// Phase 2 of code:Reallocate - it is split to support code:AddPhases.
285+
// Phase 2 of code:Reallocate
291286
element_t * ReplaceTable(element_t * newTable, count_t newTableSize);
292287

293288
// Utility function to delete old table (as returned by code:ReplaceTable).
294-
// Phase 3 of code:Reallocate - it is split to support code:AddPhases.
289+
// Phase 3 of code:Reallocate
295290
void DeleteOldTable(element_t * oldTable);
296291

297292
// Utility function that does not call code:CheckGrowth.
@@ -502,92 +497,6 @@ class EMPTY_BASES_DECL SHash : public TRAITS
502497
}
503498
};
504499

505-
// Wrapper and holder for adding an element to the hash table. Useful for Add operations that have to happen
506-
// under a rare lock that does not allow call out into host.
507-
// There are 3 phases:
508-
// 1. code:PreallocateForAdd ... Can allocate memory (calls into host).
509-
// 2. code:Add ... Adds one element (does NOT call into host).
510-
// or code:AddNothing_PublishPreallocatedTable ... Publishes the pre-allocated memory from step #1 (if any).
511-
// 3. code:DeleteOldTable (or destructor) ... Can delete the old memory (calls into host).
512-
// Example:
513-
// CrstHolder lockAdd(&crstLockForAdd); // Serialize all Add operations.
514-
// HostAssemblyMap::AddPhases addCall;
515-
// addCall.PreallocateForAdd(&shash); // 1. Allocates memory for one Add call (if needed). addCall serves as holder for the allocated memory.
516-
// {
517-
// // We cannot call out into host from ForbidSuspend region (i.e. no allocations/deallocations).
518-
// ForbidSuspendThreadHolder suspend; // Required by the 'special' read-lock
519-
// {
520-
// CrstHolder lock(&crstLock);
521-
// if (some_condition)
522-
// { // 2a. Add item. This may replace SHash inner table with the one pre-allocated in step 1.
523-
// addCall.Add(shashItem);
524-
// }
525-
// else
526-
// { // 2b. Skip adding item. This may replace SHash inner table with the one pre-allocated in step 1.
527-
// addCall.AddNothing_PublishPreallocatedTable();
528-
// }
529-
// }
530-
// }
531-
// addCall.DeleteOldTable(); // 3. Cleanup old table memory from shash (if it was replaced by pre-allocated table in step 2).
532-
// // Note: addCall destructor would take care of deleting the memory as well.
533-
class AddPhases
534-
{
535-
public:
536-
AddPhases();
537-
~AddPhases();
538-
539-
// Prepares object for one call to code:Add. Pre-allocates new table memory if needed, does not publish
540-
// the table yet (it is kept ready only in this holder for call to code:Add).
541-
// Calls out into host.
542-
void PreallocateForAdd(SHash * pHash);
543-
544-
// Add an element to the hash table. This will never replace an element; multiple elements may be stored
545-
// with the same key.
546-
// Will use/publish pre-allocated memory from code:PreallocateForAdd.
547-
// Does not call out into host.
548-
// Only one Add* method can be called once per object! (Create a new object for each call)
549-
void Add(const element_t & element);
550-
551-
// Element will not be added to the hash table.
552-
// Will use/publish pre-allocated memory from code:PreallocateForAdd.
553-
// Does not call out into host.
554-
// Only one Add* method can be called once per object! (Create a new object for each call)
555-
void AddNothing_PublishPreallocatedTable();
556-
557-
// Deletes old table if it was replaced by call to code:Add or code:AddNothing_PublishPreallocatedTable.
558-
// Calls out into host.
559-
void DeleteOldTable();
560-
561-
private:
562-
SHash * m_pHash;
563-
element_t * m_newTable;
564-
count_t m_newTableSize;
565-
element_t * m_oldTable;
566-
567-
#ifdef _DEBUG
568-
PTR_element_t dbg_m_table;
569-
count_t dbg_m_tableSize;
570-
count_t dbg_m_tableCount;
571-
count_t dbg_m_tableOccupied;
572-
count_t dbg_m_tableMax;
573-
BOOL dbg_m_fAddCalled;
574-
#endif //_DEBUG
575-
}; // class SHash::AddPhases
576-
577-
// Adds an entry to the hash table according to the guidelines above for
578-
// avoiding a callout to the host while the read lock is held.
579-
// Returns true if elem was added to the map, otherwise false.
580-
// When elem was not added (false is returned), and if ppStoredElem is non-null,
581-
// then it is set to point to the value in the map.
582-
template <typename LockHolderT,
583-
typename AddLockHolderT,
584-
typename LockT,
585-
typename AddLockT>
586-
bool CheckAddInPhases(
587-
element_t const & elem,
588-
LockT & lock,
589-
AddLockT & addLock,
590-
IUnknown * addRefObject = nullptr);
591500

592501
private:
593502

0 commit comments

Comments
 (0)