diff options
author | Jan Kotas <jkotas@microsoft.com> | 2021-03-20 06:10:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-20 06:10:31 +0300 |
commit | ff492e1f82387e64dcfa7c4aa61823a8a3a10ec3 (patch) | |
tree | c7d5abbff3679519bfdce7369335a43f4281abbf /src/coreclr/gc | |
parent | c5ec2386c9fda4fc6fb5a47559d8a570154d4a2d (diff) |
Fix and simplify GCDescs for collectible types (#49791)
Fixes #49684
Diffstat (limited to 'src/coreclr/gc')
-rw-r--r-- | src/coreclr/gc/gcdesc.h | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/src/coreclr/gc/gcdesc.h b/src/coreclr/gc/gcdesc.h index 8e58e2f7ce7..9bc21410abc 100644 --- a/src/coreclr/gc/gcdesc.h +++ b/src/coreclr/gc/gcdesc.h @@ -161,7 +161,7 @@ public: // If it doesn't contain pointers, there isn't a GCDesc PTR_MethodTable mt(pMT); - _ASSERTE(mt->ContainsPointersOrCollectible()); + _ASSERTE(mt->ContainsPointers()); return PTR_CGCDesc(mt); } @@ -192,28 +192,38 @@ public: static size_t GetNumPointers (MethodTable* pMT, size_t ObjectSize, size_t NumComponents) { size_t NumOfPointers = 0; - CGCDesc* map = GetCGCDescFromMT(pMT); - CGCDescSeries* cur = map->GetHighestSeries(); - ptrdiff_t cnt = (ptrdiff_t) map->GetNumSeries(); - if (cnt > 0) + if (pMT->ContainsPointers()) { - CGCDescSeries* last = map->GetLowestSeries(); - while (cur >= last) + CGCDesc* map = GetCGCDescFromMT(pMT); + CGCDescSeries* cur = map->GetHighestSeries(); + ptrdiff_t cnt = (ptrdiff_t)map->GetNumSeries(); + + if (cnt >= 0) { - NumOfPointers += (cur->GetSeriesSize() + ObjectSize) / sizeof(JSlot); - cur--; + CGCDescSeries* last = map->GetLowestSeries(); + do + { + NumOfPointers += (cur->GetSeriesSize() + ObjectSize) / sizeof(JSlot); + cur--; + } + while (cur >= last); } - } - else - { - /* Handle the repeating case - array of valuetypes */ - for (ptrdiff_t __i = 0; __i > cnt; __i--) + else { - NumOfPointers += cur->val_serie[__i].nptrs; + /* Handle the repeating case - array of valuetypes */ + for (ptrdiff_t __i = 0; __i > cnt; __i--) + { + NumOfPointers += cur->val_serie[__i].nptrs; + } + + NumOfPointers *= NumComponents; } + } - NumOfPointers *= NumComponents; + if (pMT->Collectible()) + { + NumOfPointers += 1; } return NumOfPointers; |