@@ -463,9 +463,7 @@ void CacheAllocator<CacheTrait>::addChainedItem(WriteHandle& parent,
463
463
// Parent will decrement the refcount upon release. Since this is an
464
464
// internal refcount, we dont include it in active handle tracking.
465
465
child->incRef ();
466
- auto ref = child->getRefCount ();
467
- // ref == 3 if child is moving
468
- XDCHECK (ref == 2u || ref == 3 );
466
+ XDCHECK_EQ (2u , child->getRefCount ());
469
467
470
468
invalidateNvm (*parent);
471
469
if (auto eventTracker = getEventTracker ()) {
@@ -555,10 +553,7 @@ void CacheAllocator<CacheTrait>::transferChainLocked(WriteHandle& parent,
555
553
ChainedItem* curr = &headHandle->asChainedItem ();
556
554
const auto newParentPtr = compressor_.compress (newParent.get ());
557
555
while (curr) {
558
- if (!curr->isMoving ())
559
- XDCHECK_EQ (curr == headHandle.get () ? 2u : 1u , curr->getRefCount ());
560
- else
561
- XDCHECK_EQ (curr == headHandle.get () ? 3u : 2u , curr->getRefCount ());
556
+ XDCHECK_EQ (curr == headHandle.get () ? 2u : 1u , curr->getRefCount ());
562
557
XDCHECK (curr->isInMMContainer ());
563
558
curr->changeKey (newParentPtr);
564
559
curr = curr->getNext (compressor_);
@@ -654,7 +649,7 @@ CacheAllocator<CacheTrait>::replaceChainedItemLocked(Item& oldItem,
654
649
WriteHandle newItemHdl,
655
650
const Item& parent) {
656
651
XDCHECK (newItemHdl != nullptr );
657
- XDCHECK_GE (2u , oldItem.getRefCount ());
652
+ XDCHECK_GE (1u , oldItem.getRefCount ());
658
653
659
654
// grab the handle to the old item so that we can return this. Also, we need
660
655
// to drop the refcount the parent holds on oldItem by manually calling
@@ -1157,7 +1152,7 @@ bool CacheAllocator<CacheTrait>::moveRegularItem(Item& oldItem,
1157
1152
1158
1153
// no one can add or remove chained items at this point
1159
1154
if (oldItem.hasChainedItem ()) {
1160
- auto oldItemHdl = WriteHandle{ &oldItem, * this } ;
1155
+ auto oldItemHdl = acquire ( &oldItem) ;
1161
1156
XDCHECK_EQ (1u , oldItemHdl->getRefCount ()) << oldItemHdl->toString ();
1162
1157
XDCHECK (!newItemHdl->hasChainedItem ()) << newItemHdl->toString ();
1163
1158
try {
@@ -1171,10 +1166,6 @@ bool CacheAllocator<CacheTrait>::moveRegularItem(Item& oldItem,
1171
1166
1172
1167
XDCHECK (!oldItem.hasChainedItem ());
1173
1168
XDCHECK (newItemHdl->hasChainedItem ());
1174
-
1175
- // drop the handle, no need to decRef since we relied on
1176
- // item being moved
1177
- oldItemHdl.release ();
1178
1169
}
1179
1170
newItemHdl.unmarkNascent ();
1180
1171
return true ;
0 commit comments