Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4a82e66
Make the EECodeGenManager API surface narrower.
AaronRobinsonMSFT Jun 5, 2025
a43c6d2
Fix GCC build.
AaronRobinsonMSFT Jun 6, 2025
9d74732
Fix contracts
AaronRobinsonMSFT Jun 6, 2025
d7fbfcc
Fix contracts
AaronRobinsonMSFT Jun 6, 2025
2c934d7
Narrow contract
AaronRobinsonMSFT Jun 6, 2025
b839ad9
Fix thread mode on DynamicMethod clean-up
AaronRobinsonMSFT Jun 8, 2025
ced737a
Feedback
AaronRobinsonMSFT Jun 9, 2025
5e94fc3
Fix clean-up of delay structures.
AaronRobinsonMSFT Jun 9, 2025
3f4e1f7
Move DynamicMethodDesc destruction to finalizer queue if not
AaronRobinsonMSFT Jun 12, 2025
9c11801
Fix contract
AaronRobinsonMSFT Jun 12, 2025
6e662e6
Remove GetChunk optimization.
AaronRobinsonMSFT Jun 13, 2025
5d726df
Move finalizer related work functions to finalizerthread.cpp.
AaronRobinsonMSFT Jun 13, 2025
aa27e44
Alter HostCodeHeap memory clean up.
AaronRobinsonMSFT Jun 13, 2025
c1509c6
Merge remote-tracking branch 'upstream/main' into runtime_102858
AaronRobinsonMSFT Jun 13, 2025
4cb0434
Nits
AaronRobinsonMSFT Jun 13, 2025
ae3881c
Unconditionally publish UnwindInfo.
AaronRobinsonMSFT Jun 14, 2025
b28c538
Missed function rename.
AaronRobinsonMSFT Jun 14, 2025
7c1e074
Contract violation fix
AaronRobinsonMSFT Jun 14, 2025
5ab23b9
Merge remote-tracking branch 'upstream/main' into runtime_102858
AaronRobinsonMSFT Jun 14, 2025
976cfdf
Merge remote-tracking branch 'upstream/main' into runtime_102858
AaronRobinsonMSFT Jun 17, 2025
1de0975
Feedback
AaronRobinsonMSFT Jun 17, 2025
ee38616
Merge branch 'main' into runtime_102858
jkotas Jun 22, 2025
929ac29
Feedback
AaronRobinsonMSFT Jul 7, 2025
dc94630
Nits
AaronRobinsonMSFT Jul 7, 2025
f3d18ba
Handle the OOM case for clean-up
AaronRobinsonMSFT Jul 7, 2025
120be6f
Remove RemoveJitData() logic.
AaronRobinsonMSFT Jul 7, 2025
8f21e31
Remove CEECodeGenInfo::BackoutJitData()
AaronRobinsonMSFT Jul 8, 2025
d7349e7
Merge remote-tracking branch 'upstream/main' into runtime_102858
AaronRobinsonMSFT Jul 9, 2025
52cd599
Feedback.
AaronRobinsonMSFT Jul 9, 2025
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
4 changes: 2 additions & 2 deletions src/coreclr/debug/daccess/dacdbiimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3556,9 +3556,9 @@ void DacDbiInterfaceImpl::EnumerateMemRangesForJitCodeHeaps(CQuickArrayList<COR_
{
// We should always have a valid EEJitManager with at least one code heap.
EEJitManager *pEM = ExecutionManager::GetEEJitManager();
_ASSERTE(pEM != NULL && pEM->m_pCodeHeap.IsValid());
_ASSERTE(pEM != NULL && pEM->m_pAllCodeHeaps.IsValid());

PTR_HeapList pHeapList = pEM->m_pCodeHeap;
PTR_HeapList pHeapList = pEM->m_pAllCodeHeaps;
while (pHeapList != NULL)
{
CodeHeap *pHeap = pHeapList->pHeap;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/daccess/fntableaccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ extern "C" NTSTATUS OutOfProcessFunctionTableCallbackEx(IN ReadMemoryFunction
*ppFunctions = 0;
*pnEntries = 0;

DWORD_PTR pHp = JitMan + (DWORD_PTR)offsetof(FakeEEJitManager, m_pCodeHeap);
DWORD_PTR pHp = JitMan + (DWORD_PTR)offsetof(FakeEEJitManager, m_pAllCodeHeaps);

move(pHp, pHp);

Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/debug/daccess/fntableaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ struct FakeEEJitManager
{
LPVOID __VFN_table;
LPVOID m_runtimeSupport;
LPVOID m_pCodeHeap;
// Nothing after this point matters: we only need the correct offset of m_pCodeHeap.
LPVOID m_pAllCodeHeaps;
// Nothing after this point matters: we only need the correct offset of m_pAllCodeHeaps.
};

struct FakeHeapList
Expand Down Expand Up @@ -76,7 +76,7 @@ class CheckDuplicatedStructLayouts
{
#define CHECK_OFFSET(cls, fld) CPP_ASSERT(cls##fld, offsetof(Fake##cls, fld) == offsetof(cls, fld))

CHECK_OFFSET(EEJitManager, m_pCodeHeap);
CHECK_OFFSET(EEJitManager, m_pAllCodeHeaps);

CHECK_OFFSET(HeapList, hpNext);
CHECK_OFFSET(HeapList, startAddress);
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ ClrDataAccess::GetJitManagerList(unsigned int count, struct DacpJitManagerInfo m
currentPtr->codeType = managerPtr->GetCodeType();

EEJitManager *eeJitManager = PTR_EEJitManager(PTR_HOST_TO_TADDR(managerPtr));
currentPtr->ptrHeapList = HOST_CDADDR(eeJitManager->m_pCodeHeap);
currentPtr->ptrHeapList = HOST_CDADDR(eeJitManager->m_pAllCodeHeaps);
}
}
else if (pNeeded)
Expand Down Expand Up @@ -528,7 +528,7 @@ ClrDataAccess::GetCodeHeapList(CLRDATA_ADDRESS jitManager, unsigned int count, s
SOSDacEnter();

EEJitManager *pJitManager = PTR_EEJitManager(TO_TADDR(jitManager));
HeapList *heapList = pJitManager->m_pCodeHeap;
HeapList *heapList = pJitManager->m_pAllCodeHeaps;

if (codeHeaps)
{
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/debug/ee/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2284,10 +2284,10 @@ void DebuggerLazyInit::Init()
DebuggerLazyInit::~DebuggerLazyInit()
{
{
USHORT cBlobs = m_pMemBlobs.Count();
INT32 cBlobs = m_pMemBlobs.Count();
void **rgpBlobs = m_pMemBlobs.Table();

for (int i = 0; i < cBlobs; i++)
for (INT32 i = 0; i < cBlobs; i++)
{
g_pDebugger->ReleaseRemoteBuffer(rgpBlobs[i], false);
}
Expand Down Expand Up @@ -12175,10 +12175,10 @@ HRESULT Debugger::ReleaseRemoteBuffer(void *pBuffer, bool removeFromBlobList)
// Remove the buffer from the blob list if necessary.
if (removeFromBlobList)
{
USHORT cBlobs = GetMemBlobs()->Count();
INT32 cBlobs = GetMemBlobs()->Count();
void **rgpBlobs = GetMemBlobs()->Table();

USHORT i;
INT32 i;
for (i = 0; i < cBlobs; i++)
{
if (rgpBlobs[i] == pBuffer)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/inc/contract.inl
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ void CONTRACT_ASSERT(const char *szElaboration,
}
else
{
strcat_s(Buf,ARRAY_SIZE(Buf), "We can't find the violated contract. Look for an old-style non-holder-based contract.\n");
strcat_s(Buf,ARRAY_SIZE(Buf), "Missing tracking information. Look for data structures that manipulate contract state (i.e., CrstHolder).\n");
}
}

Expand Down
11 changes: 9 additions & 2 deletions src/coreclr/inc/pedecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,19 @@ class MethodSectionIterator
BYTE *m_current;

public:
MethodSectionIterator() = default;

//If code is a target pointer, then GetMethodCode and FindMethodCode return
//target pointers. codeTable may be a pointer of either type, since it is
//converted internally into a host pointer.
MethodSectionIterator(const void *code, SIZE_T codeSize,
const void *codeTable, SIZE_T codeTableSize);
MethodSectionIterator(void *code, SIZE_T codeSize,
void *codeTable, SIZE_T codeTableSize);

MethodSectionIterator(MethodSectionIterator const&) = delete;
MethodSectionIterator& operator=(MethodSectionIterator const&) = delete;
MethodSectionIterator(MethodSectionIterator&&) = default;
MethodSectionIterator& operator=(MethodSectionIterator&&) = default;

BOOL Next();
BYTE *GetMethodCode() { return m_current; } // Get the start of method code of the current method in the iterator
};
Expand Down
36 changes: 33 additions & 3 deletions src/coreclr/inc/utilcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,37 @@ class CUnorderedArrayWithAllocator
ALLOCATOR::Free(this, m_pTable);
}

CUnorderedArrayWithAllocator(CUnorderedArrayWithAllocator const&) = delete;
CUnorderedArrayWithAllocator& operator=(CUnorderedArrayWithAllocator const&) = delete;
CUnorderedArrayWithAllocator(CUnorderedArrayWithAllocator&& other)
: m_iCount{ 0 }
, m_iSize{ 0 }
, m_pTable{ NULL}
{
LIMITED_METHOD_CONTRACT;
other.m_iCount = 0;
other.m_iSize = 0;
other.m_pTable = NULL;
}
CUnorderedArrayWithAllocator& operator=(CUnorderedArrayWithAllocator&& other)
{
LIMITED_METHOD_CONTRACT;
if (this != &other)
{
if (m_pTable != NULL)
ALLOCATOR::Free(this, m_pTable);

m_iCount = other.m_iCount;
m_iSize = other.m_iSize;
m_pTable = other.m_pTable;

other.m_iCount = 0;
other.m_iSize = 0;
other.m_pTable = NULL;
}
return *this;
}

void Clear()
{
WRAPPER_NO_CONTRACT;
Expand Down Expand Up @@ -1061,12 +1092,11 @@ class CUnorderedArrayWithAllocator

#endif // #ifndef DACCESS_COMPILE

USHORT Count()
INT32 Count()
{
LIMITED_METHOD_CONTRACT;
SUPPORTS_DAC;
Comment thread
AaronRobinsonMSFT marked this conversation as resolved.
_ASSERTE(FitsIn<USHORT>(m_iCount));
return static_cast<USHORT>(m_iCount);
return m_iCount;
}

private:
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/utilcode/pedecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2575,11 +2575,11 @@ BOOL PEDecoder::ForceRelocForDLL(LPCWSTR lpFileName)
#endif // _DEBUG

//
// MethodSectionIterator class is used to iterate hot (or) cold method section in an ngen image.
// Also used to iterate over jitted methods in the code heap
// MethodSectionIterator class is used to iterate hot (or) cold method sections
// over jitted methods in the code heap
//
MethodSectionIterator::MethodSectionIterator(const void *code, SIZE_T codeSize,
const void *codeTable, SIZE_T codeTableSize)
MethodSectionIterator::MethodSectionIterator(void *code, SIZE_T codeSize,
void *codeTable, SIZE_T codeTableSize)
{
using namespace NibbleMap;

Expand Down
53 changes: 22 additions & 31 deletions src/coreclr/vm/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2892,56 +2892,47 @@ WORD SparseVTableMap::GetNumVTableSlots()
#endif //FEATURE_COMINTEROP

//*******************************************************************************
void EEClass::AddChunk (MethodDescChunk* pNewChunk)
void EEClass::AddChunk(MethodDescChunk* pNewChunk)
{
STATIC_CONTRACT_NOTHROW;
STATIC_CONTRACT_GC_NOTRIGGER;
STATIC_CONTRACT_FORBID_FAULT;

_ASSERTE(pNewChunk->GetNextChunk() == NULL);

MethodDescChunk* head = GetChunks();
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
PRECONDITION(pNewChunk != NULL);
PRECONDITION(pNewChunk->GetNextChunk() == NULL);
}
CONTRACTL_END;

if (head == NULL)
if (GetChunks() == NULL)
{
SetChunks(pNewChunk);
}
else
{
// Current chunk needs to be added to the end of the list so that
// when reflection is iterating all methods, they would come in declared order
while (head->GetNextChunk() != NULL)
head = head->GetNextChunk();

head->SetNextChunk(pNewChunk);
PTR_MethodDescChunk prevCurr = m_pChunksCurrent;
prevCurr->SetNextChunk(pNewChunk);
m_pChunksCurrent = pNewChunk;
}
}

//*******************************************************************************
void EEClass::AddChunkIfItHasNotBeenAdded (MethodDescChunk* pNewChunk)
void EEClass::AddChunkIfItHasNotBeenAdded(MethodDescChunk* pNewChunk)
{
STATIC_CONTRACT_NOTHROW;
STATIC_CONTRACT_GC_NOTRIGGER;
STATIC_CONTRACT_FORBID_FAULT;
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
PRECONDITION(pNewChunk != NULL);
}
CONTRACTL_END;

// return if the chunk has been added
if (pNewChunk->GetNextChunk() != NULL)
return;

// even if pNewChunk->GetNextChunk() is NULL, this may still be the first chunk we added
// (last in the list) so find the end of the list and verify that
MethodDescChunk *chunk = GetChunks();
if (chunk != NULL)
{
while (chunk->GetNextChunk() != NULL)
chunk = chunk->GetNextChunk();

if (chunk == pNewChunk)
return;
}

pNewChunk->SetNextChunk(GetChunks());
SetChunks(pNewChunk);
Comment thread
AaronRobinsonMSFT marked this conversation as resolved.
AddChunk(pNewChunk);
}

#endif // !DACCESS_COMPILE
Expand Down
17 changes: 13 additions & 4 deletions src/coreclr/vm/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ typedef DPTR(EEClassOptionalFields) PTR_EEClassOptionalFields;
//
// EEClasses hold the following important fields
// * code:EEClass.m_pMethodTable - Points a MethodTable associated with
// * code:EEClass.m_pChunks - a list of code:MethodDescChunk which is simply a list of code:MethodDesc
// * code:EEClass.m_pChunksBegin - a list of code:MethodDescChunk which is simply a list of code:MethodDesc
// which represent the methods.
// * code:EEClass.m_pFieldDescList - a list of fields in the type.
//
Expand Down Expand Up @@ -1387,13 +1387,17 @@ class EEClass // DO NOT CREATE A NEW EEClass USING NEW!
inline void SetChunks (MethodDescChunk* pChunks)
{
LIMITED_METHOD_CONTRACT;
m_pChunks = pChunks;
_ASSERTE(pChunks != NULL);
_ASSERTE(m_pChunksBegin == NULL);
_ASSERTE(m_pChunksCurrent == NULL);
m_pChunksBegin = pChunks;
Comment thread
AaronRobinsonMSFT marked this conversation as resolved.
Outdated
m_pChunksCurrent = pChunks;
}
#endif // !DACCESS_COMPILE
void AddChunk (MethodDescChunk* pNewChunk);

void AddChunkIfItHasNotBeenAdded (MethodDescChunk* pNewChunk);

public:
inline PTR_GuidInfo GetGuidInfo()
{
LIMITED_METHOD_DAC_CONTRACT;
Expand Down Expand Up @@ -1694,7 +1698,12 @@ class EEClass // DO NOT CREATE A NEW EEClass USING NEW!
PTR_MethodTable m_pMethodTable;

PTR_FieldDesc m_pFieldDescList;
PTR_MethodDescChunk m_pChunks;

// Chain of MethodDescChunks. The "begin" pointer shouldn't be updated
// after being set. The "current" pointer will be updated as new MethodDescChunks
// are added.
PTR_MethodDescChunk m_pChunksBegin;
PTR_MethodDescChunk m_pChunksCurrent;
Comment thread
jkotas marked this conversation as resolved.
Outdated

#ifdef FEATURE_COMINTEROP
union
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/class.inl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
inline PTR_MethodDescChunk EEClass::GetChunks()
{
LIMITED_METHOD_DAC_CONTRACT;
return m_pChunks;
return m_pChunksBegin;
}

//*******************************************************************************
Expand Down
Loading
Loading