-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Completely lock-free ClassLoader::LookupTypeKey #61346
Changes from 14 commits
1b003e3
5330325
c5db8c4
c264f69
e8e7d6e
b9b4813
749695a
5569c66
7c3cd08
f8b1021
067cefb
1516f6b
efe6043
f455581
e874b3c
c7eb7e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,16 @@ class DacEnumerableHashTable | |
void EnumMemoryRegions(CLRDataEnumMemoryFlags flags); | ||
#endif // DACCESS_COMPILE | ||
|
||
private: | ||
struct VolatileEntry; | ||
typedef DPTR(struct VolatileEntry) PTR_VolatileEntry; | ||
struct VolatileEntry | ||
{ | ||
VALUE m_sValue; // The derived-class format of an entry | ||
PTR_VolatileEntry m_pNextEntry; // Pointer to the next entry in the bucket chain (or NULL) | ||
DacEnumerableHashValue m_iHashValue; // The hash value associated with the entry | ||
}; | ||
|
||
protected: | ||
// This opaque structure provides enumeration context when walking the set of entries which share a common | ||
// hash code. Initialized by BaseFindFirstEntryByHash and read/updated by BaseFindNextEntryByHash. | ||
|
@@ -106,6 +116,7 @@ class DacEnumerableHashTable | |
TADDR m_pEntry; // The entry the caller is currently looking at (or NULL to begin | ||
// with). This is a VolatileEntry* and should always be a target address | ||
// not a DAC PTR_. | ||
DPTR(PTR_VolatileEntry) m_curBuckets; // The bucket table we are working with. | ||
}; | ||
|
||
// This opaque structure provides enumeration context when walking all entries in the table. Initialized | ||
|
@@ -176,16 +187,9 @@ class DacEnumerableHashTable | |
PTR_Module m_pModule; | ||
|
||
private: | ||
private: | ||
// Internal implementation details. Nothing of interest to sub-classers for here on. | ||
|
||
struct VolatileEntry; | ||
typedef DPTR(struct VolatileEntry) PTR_VolatileEntry; | ||
struct VolatileEntry | ||
{ | ||
VALUE m_sValue; // The derived-class format of an entry | ||
PTR_VolatileEntry m_pNextEntry; // Pointer to the next entry in the bucket chain (or NULL) | ||
DacEnumerableHashValue m_iHashValue; // The hash value associated with the entry | ||
}; | ||
DPTR(VALUE) BaseFindFirstEntryByHashCore(DPTR(PTR_VolatileEntry) curBuckets, DacEnumerableHashValue iHash, LookupContext* pContext); | ||
|
||
#ifndef DACCESS_COMPILE | ||
// Determine loader heap to be used for allocation of entries and bucket lists. | ||
|
@@ -206,11 +210,25 @@ class DacEnumerableHashTable | |
return m_pBuckets; | ||
} | ||
|
||
// our bucket table uses two extra slots - slot [0] contains the length of the table, | ||
// slot [1] will contain the next version of the table if it resizes | ||
static const int SLOT_LENGTH = 0; | ||
static const int SLOT_NEXT = 1; | ||
|
||
static DWORD GetLength(DPTR(PTR_VolatileEntry) buckets) | ||
{ | ||
return (DWORD)dac_cast<TADDR>(buckets[SLOT_LENGTH]); | ||
} | ||
|
||
static DPTR(PTR_VolatileEntry) GetNext(DPTR(PTR_VolatileEntry) buckets) | ||
{ | ||
return (DPTR(PTR_VolatileEntry))dac_cast<TADDR>(buckets[SLOT_NEXT]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hoyosjs - is this correct or from TADDR it must be another dac_cast ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like: static DPTR(PTR_VolatileEntry) GetNext(DPTR(PTR_VolatileEntry) buckets)
{
return dac_cast<DPTR(PTR_VolatileEntry)>(dac_cast<TADDR>(buckets[SLOT_NEXT]));
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand this right
which can be simplified to
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. The |
||
} | ||
|
||
// Loader heap provided at construction time. May be NULL (in which case m_pModule must *not* be NULL). | ||
LoaderHeap *m_pHeap; | ||
|
||
DPTR(PTR_VolatileEntry) m_pBuckets; // Pointer to a simple bucket list (array of VolatileEntry pointers) | ||
DWORD m_cBuckets; // Count of buckets in the above array (always non-zero) | ||
DWORD m_cEntries; // Count of elements | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hoyosjs - If debugger only does lookups, then it will no longer take this look, then
CRST_DEBUGGER_THREAD
is not needed.Can debugger load/publish types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we can't load assemblies, but it's possible that a FuncEval can load a type I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is funceval running on debugger thread?
I assumed that
CRST_DEBUGGER_THREAD
does not cover funceaval, since funceval could JIT and JIT does all kind of stuff (including loading assemblies). If that is attributed to the debugger thread, then debugger thread is not different from anything else.I am not very familiar with how that all works though.
CRST_DEBUGGER_THREAD
is not a big nuisance here. I was just not sure it is still necessary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried removing
CRST_DEBUGGER_THREAD
and running both regular and diagnostics tests (with Chk bits) - everything runs as before. Not sure if that is enough proof thatCRST_DEBUGGER_THREAD
is unnecessary.I just noticed that
CRST_DEBUGGER_THREAD
is always paired withCRST_UNSAFE_ANYMODE
(or sometimesCRST_GC_NOTRIGGER_WHEN_TAKEN
), so since we are removing the other one, maybe we do not needCRST_DEBUGGER_THREAD
either.But do not think
CRST_DEBUGGER_THREAD
is a big nuisance either way - it basically increments/decrements a counter that is checked in couple asserts.