Skip to content
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

Frozen objects should be identified as Gen2 in the handle table #97109

Merged
merged 3 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/coreclr/gc/env/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <assert.h>
#include <stdarg.h>
#include <memory.h>
#include <limits.h>

#include <new>

Expand Down
10 changes: 9 additions & 1 deletion src/coreclr/gc/handletable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
DWORD g_dwHandles = 0;
#endif // ENABLE_PERF_COUNTERS || FEATURE_EVENT_TRACE

#ifndef DACCESS_COMPILE
int GetConvertedGeneration(_UNCHECKED_OBJECTREF obj)
{
int generation = g_theGCHeap->WhichGeneration(obj);
return generation == INT_MAX ? max_generation : generation;
}
#endif //DACCESS_COMPILE

/****************************************************************************
*
* FORWARD DECLARATIONS
Expand Down Expand Up @@ -577,7 +585,7 @@ void HndWriteBarrierWorker(OBJECTHANDLE handle, _UNCHECKED_OBJECTREF value)
if (*pClumpAge != 0) // Perf optimization: if clumpAge is 0, nothing more to do
{
// find out generation
int generation = g_theGCHeap->WhichGeneration(value);
int generation = GetConvertedGeneration(value);
uint32_t uType = HandleFetchType(handle);

#ifdef FEATURE_ASYNC_PINNED_HANDLES
Expand Down
12 changes: 12 additions & 0 deletions src/coreclr/gc/handletablepriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -942,3 +942,15 @@ void CALLBACK BlockVerifyAgeMapForBlocks(PTR_TableSegment pSegment, uint32_t uBl
PTR_TableSegment CALLBACK xxxAsyncSegmentIterator(PTR_HandleTable pTable, TableSegment *pPrevSegment, CrstHolderWithState *pCrstHolder);

/*--------------------------------------------------------------------------*/

#ifndef DACCESS_COMPILE

/*
* GetConvertedGeneration
*
* Get the generation of an object, where a frozen object is regarded as max_generation
*
*/
int GetConvertedGeneration(_UNCHECKED_OBJECTREF obj);

#endif //DACCESS_COMPILE
6 changes: 3 additions & 3 deletions src/coreclr/gc/handletablescan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ void BlockResetAgeMapForBlocksWorker(uint32_t *pdwGen, uint32_t dwClumpMask, Sca
{
if (!HndIsNullOrDestroyedHandle(*pValue))
{
int thisAge = g_theGCHeap->WhichGeneration(*pValue);
int thisAge = GetConvertedGeneration(*pValue);
if (minAge > thisAge)
minAge = thisAge;

Expand All @@ -820,7 +820,7 @@ void BlockResetAgeMapForBlocksWorker(uint32_t *pdwGen, uint32_t dwClumpMask, Sca
[](Object*, Object* to, void* ctx)
{
int* minAge = reinterpret_cast<int*>(ctx);
int generation = g_theGCHeap->WhichGeneration(to);
int generation = GetConvertedGeneration(to);
if (*minAge > generation)
{
*minAge = generation;
Expand Down Expand Up @@ -903,7 +903,7 @@ static void VerifyObjectAndAge(_UNCHECKED_OBJECTREF from, _UNCHECKED_OBJECTREF o
{
VerifyObject(from, obj);

int thisAge = g_theGCHeap->WhichGeneration(obj);
int thisAge = GetConvertedGeneration(obj);

//debugging code
//if (minAge > thisAge && thisAge < g_theGCHeap->GetMaxGeneration())
Expand Down
Loading