It leaved few blocks in PerClassArray[0].
Reviewed By: cryptoad
Differential Revision: https://reviews.llvm.org/D99763
Stats.add(StatFree, ClassSize);
}
+ bool isEmpty() const {
+ for (uptr I = 0; I < NumClasses; ++I)
+ if (PerClassArray[I].Count)
+ return false;
+ return true;
+ }
+
void drain() {
- for (uptr I = 0; I < NumClasses; I++) {
+ // Drain BatchClassId (0) the last as createBatch can refill it.
+ for (uptr I = NumClasses; I;) {
+ --I;
PerClass *C = &PerClassArray[I];
while (C->Count > 0)
drain(C, I);
}
+ DCHECK(isEmpty());
}
TransferBatch *createBatch(uptr ClassId, void *B) {
EXPECT_NE(Stats.find("Stats: SizeClassAllocator"), std::string::npos);
EXPECT_NE(Stats.find("Stats: MapAllocator"), std::string::npos);
EXPECT_NE(Stats.find("Stats: Quarantine"), std::string::npos);
+
+ bool UnlockRequired;
+ auto *TSD = Allocator->getTSDRegistry()->getTSDAndLock(&UnlockRequired);
+ EXPECT_TRUE(!TSD->Cache.isEmpty());
+ TSD->Cache.drain();
+ EXPECT_TRUE(TSD->Cache.isEmpty());
+ if (UnlockRequired)
+ TSD->unlock();
}
// Test that multiple instantiations of the allocator have not messed up the