Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
IsAllGCPointers
  • Loading branch information
VSadov committed Mar 22, 2023
commit 2b696d6b1578ed0c221eba9ebbac7f9c3943d39e
6 changes: 2 additions & 4 deletions src/coreclr/vm/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,16 +584,14 @@ MethodTable* Module::CreateArrayMethodTable(TypeHandle elemTypeHnd, CorElementTy
}

// Set up GC information
if (CorTypeInfo::IsObjRef(elemType))
if (CorTypeInfo::IsObjRef(elemType) || pMT->IsAllGCPointers())
{
CGCDescSeries *pSeries;

pMT->SetContainsPointers();

// This array is all GC Pointers
CGCDesc::GetCGCDescFromMT(pMT)->Init( pMT, 1 );

pSeries = CGCDesc::GetCGCDescFromMT(pMT)->GetHighestSeries();
CGCDescSeries* pSeries = CGCDesc::GetCGCDescFromMT(pMT)->GetHighestSeries();

pSeries->SetSeriesOffset(ArrayBase::GetDataPtrOffset(pMT));
// For arrays, the size is the negative of the BaseSize (the GC always adds the total
Expand Down
15 changes: 15 additions & 0 deletions src/coreclr/vm/methodtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1761,6 +1761,21 @@ BOOL MethodTable::CanShareVtableChunksFrom(MethodTable *pTargetMT, Module *pCurr
return pTargetMT->GetLoaderModule() == pCurrentLoaderModule;
}

BOOL MethodTable::IsAllGCPointers()
{
if (this->ContainsPointers())
{
// check for canonical GC encoding for all-pointer types
CGCDescSeries* pSeries = CGCDesc::GetCGCDescFromMT(this)->GetHighestSeries();
return pSeries->GetSeriesCount() == 1 &&
pSeries->GetSeriesOffset() == this->GetBaseSize() - sizeof(size_t) &&
pSeries->GetSeriesSize() - this->GetBaseSize() == 0;
}

return false;
}


#ifdef _DEBUG

void
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/vm/methodtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,7 @@ class MethodTable
LIMITED_METHOD_CONTRACT;
return GetFlag(enum_flag_ContainsPointers);
}

BOOL Collectible()
{
LIMITED_METHOD_CONTRACT;
Expand All @@ -1591,6 +1592,7 @@ class MethodTable
return FALSE;
#endif
}

BOOL ContainsPointersOrCollectible()
{
LIMITED_METHOD_CONTRACT;
Expand All @@ -1602,6 +1604,8 @@ class MethodTable

BOOL IsNotTightlyPacked();

BOOL IsAllGCPointers();

void SetContainsPointers()
{
LIMITED_METHOD_CONTRACT;
Expand Down