Lines Matching defs:Allocator

53 void checkMemoryTaggingMaybe(AllocatorT *Allocator, void *P, scudo::uptr Size,
57 if (Allocator->useMemoryTaggingTestOnly())
65 ? Allocator->useMemoryTaggingTestOnly()
76 template <typename Config> struct TestAllocator : scudo::Allocator<Config> {
90 alignof(scudo::Allocator<scudo::DefaultConfig>),
92 alignof(scudo::Allocator<scudo::FuchsiaConfig>),
94 alignof(scudo::Allocator<scudo::AndroidConfig>)
103 sizeof(scudo::Allocator<scudo::DefaultConfig>),
105 sizeof(scudo::Allocator<scudo::FuchsiaConfig>),
107 sizeof(scudo::Allocator<scudo::AndroidConfig>)
153 Allocator = std::make_unique<AllocatorT>();
156 Allocator->releaseToOS(scudo::ReleaseToOS::Force);
165 std::unique_ptr<AllocatorT> Allocator;
252 auto *Allocator = this->Allocator.get();
255 Allocator->isOwned(&StaticBuffer[scudo::Chunk::getHeaderSize()]));
260 EXPECT_FALSE(Allocator->isOwned(&StackBuffer[scudo::Chunk::getHeaderSize()]));
267 auto *Allocator = this->Allocator.get();
279 void *P = Allocator->allocate(Size, Origin, Align);
281 EXPECT_TRUE(Allocator->isOwned(P));
283 EXPECT_LE(Size, Allocator->getUsableSize(P));
285 checkMemoryTaggingMaybe(Allocator, P, Size, Align);
286 Allocator->deallocate(P, Origin, Size);
290 Allocator->printStats();
291 Allocator->printFragmentationInfo();
322 auto *Allocator = this->Allocator.get();
328 void *P = Allocator->allocate(Size, Origin, 1U << MinAlignLog, true);
333 Allocator->deallocate(P, Origin, Size);
339 auto *Allocator = this->Allocator.get();
342 Allocator->setFillContents(scudo::ZeroFill);
346 void *P = Allocator->allocate(Size, Origin, 1U << MinAlignLog, false);
351 Allocator->deallocate(P, Origin, Size);
357 auto *Allocator = this->Allocator.get();
362 Allocator->setFillContents(scudo::PatternOrZeroFill);
366 void *P = Allocator->allocate(Size, Origin, 1U << MinAlignLog, false);
372 !Allocator->useMemoryTaggingTestOnly())
378 Allocator->deallocate(P, Origin, Size);
384 auto *Allocator = this->Allocator.get();
388 void *NeedleP = Allocator->allocate(NeedleSize, Origin);
389 Allocator->deallocate(NeedleP, Origin);
392 void *P = Allocator->allocate(NeedleSize, Origin);
393 if (Allocator->getHeaderTaggedPointer(P) ==
394 Allocator->getHeaderTaggedPointer(NeedleP))
396 Allocator->deallocate(P, Origin);
402 auto *Allocator = this->Allocator.get();
407 void *P = Allocator->allocate(Size, Origin);
411 void *NewP = Allocator->reallocate(P, Size * 2);
419 Allocator->deallocate(P, Origin);
423 auto *Allocator = this->Allocator.get();
429 void *P = Allocator->allocate(Size, Origin);
434 void *NewP = Allocator->reallocate(P, Size);
440 Allocator->deallocate(P, Origin);
444 auto *Allocator = this->Allocator.get();
453 Allocator->setFillContents(scudo::PatternOrZeroFill);
455 void *P = Allocator->allocate(InitialSize, Origin);
461 void *NewP = Allocator->reallocate(P, NewSize);
474 checkMemoryTaggingMaybe(Allocator, NewP, NewSize, 0);
477 Allocator->deallocate(P, Origin);
481 auto *Allocator = this->Allocator.get();
491 V.push_back(Allocator->allocate(
495 Allocator->disable();
496 Allocator->iterateOverChunks(
504 Allocator->enable();
506 Allocator->deallocate(P, Origin);
511 auto *Allocator = this->Allocator.get();
516 if (!Allocator->useMemoryTaggingTestOnly())
521 void *P = Allocator->allocate(Size, Origin);
522 Allocator->deallocate(P, Origin);
529 void *P = Allocator->allocate(Size, Origin);
530 Allocator->deallocate(P, Origin);
538 auto *Allocator = this->Allocator.get();
549 void *P = Allocator->allocate(Size, Origin);
551 Allocator->deallocate(P, Origin);
552 Allocator->deallocate(P, Origin);
559 auto *Allocator = this->Allocator.get();
561 if (Allocator->useMemoryTaggingTestOnly()) {
563 void *P = Allocator->allocate(2048, Origin);
566 Allocator->disableMemoryTagging();
568 Allocator->deallocate(P, Origin);
570 P = Allocator->allocate(2048, Origin);
573 Allocator->deallocate(P, Origin);
575 Allocator->releaseToOS(scudo::ReleaseToOS::Force);
580 auto *Allocator = this->Allocator.get();
584 scudo::uptr ActualSize = Allocator->getStats(Buffer.data(), BufferSize);
588 ActualSize = Allocator->getStats(Buffer.data(), BufferSize);
600 auto *Allocator = this->Allocator.get();
604 V.push_back(Allocator->allocate(
609 Allocator->deallocate(P, Origin);
612 *Allocator->getTSDRegistry());
620 auto *Allocator = this->Allocator.get();
624 V.push_back(Allocator->allocate(
629 Allocator->deallocate(P, Origin);
632 Allocator->releaseToOS(scudo::ReleaseToOS::ForceAll);
635 *Allocator->getTSDRegistry());
638 EXPECT_TRUE(Allocator->getQuarantine()->isEmpty());
645 auto *Allocator = this->Allocator.get();
657 void *P = Allocator->allocate(Size, Origin);
664 Allocator->releaseToOS(scudo::ReleaseToOS::Force);
668 Allocator->deallocate(Pair.first, Origin, Pair.second);
679 Allocator->releaseToOS(scudo::ReleaseToOS::Force);
734 auto Allocator = std::unique_ptr<AllocatorT>(new AllocatorT());
737 void *P = Allocator->allocate(Size, Origin);
741 EXPECT_DEATH(Allocator->deallocate(P, Origin, Size + 8U), "");
746 EXPECT_DEATH(Allocator->deallocate(MisalignedP, Origin, Size), "");
747 EXPECT_DEATH(Allocator->reallocate(MisalignedP, Size * 2U), "");
753 EXPECT_DEATH(Allocator->deallocate(P, Origin, Size), "");
755 EXPECT_DEATH(Allocator->deallocate(P, Origin, Size), "");
759 Allocator->deallocate(P, Origin, Size);
760 EXPECT_DEATH(Allocator->deallocate(P, Origin, Size), "");
761 EXPECT_DEATH(Allocator->reallocate(P, Size * 2U), "");
762 EXPECT_DEATH(Allocator->getUsableSize(P), "");
769 auto Allocator = std::unique_ptr<AllocatorT>(new AllocatorT());
784 P = Allocator->allocate(Size - 64U, Origin);
791 Allocator->deallocate(V.back(), Origin);
801 auto *Allocator = this->Allocator.get();
802 Allocator->releaseToOS(scudo::ReleaseToOS::Force);
806 auto *Allocator = this->Allocator.get();
807 Allocator->setOption(scudo::Option::MemtagTuning, M_MEMTAG_TUNING_BUFFER_OVERFLOW);
809 if (!Allocator->useMemoryTaggingTestOnly())
827 Allocator->allocate(Size - scudo::Chunk::getHeaderSize(), Origin)));
845 auto *Allocator = this->Allocator.get();
849 Allocator->setOption(scudo::Option::ThreadDisableMemInit, 1);
863 Ptrs[I] = Allocator->allocate(Size, Origin);
867 Allocator->deallocate(Ptrs[I], Origin, Size);
869 Ptrs[I] = Allocator->allocate(Size - 8, Origin);
873 Allocator->deallocate(Ptrs[I], Origin, Size - 8);
875 Ptrs[I] = Allocator->allocate(Size, Origin, 1U << MinAlignLog, true);
881 Allocator->setOption(scudo::Option::ThreadDisableMemInit, 0);
885 auto *Allocator = this->Allocator.get();
894 void *P = Allocator->allocate(Size, Origin);
895 P = Allocator->reallocate(P, Size + 1);
900 Allocator->deallocate(Ptrs[i], Origin);
907 auto *Allocator = this->Allocator.get();
908 EXPECT_EQ(0u, Allocator->getRingBufferSize());
909 EXPECT_EQ(nullptr, Allocator->getRingBufferAddress());
913 auto *Allocator = this->Allocator.get();
914 Allocator->setTrackAllocationStacks(true);
916 auto RingBufferSize = Allocator->getRingBufferSize();
918 auto *RingBufferAddress = Allocator->getRingBufferAddress();
922 Allocator->setTrackAllocationStacks(true);
923 ASSERT_EQ(RingBufferSize, Allocator->getRingBufferSize());
924 EXPECT_EQ(RingBufferAddress, Allocator->getRingBufferAddress());
928 auto *Allocator = this->Allocator.get();
929 Allocator->setTrackAllocationStacks(true);
931 auto RingBufferSize = Allocator->getRingBufferSize();
933 EXPECT_EQ(Allocator->getRingBufferAddress()[RingBufferSize - 1], '\0');
937 auto *Allocator = this->Allocator.get();
938 Allocator->setTrackAllocationStacks(true);
940 auto *RingBufferAddress = Allocator->getRingBufferAddress();
942 EXPECT_EQ(RingBufferAddress, Allocator->getRingBufferAddress());
948 auto *Allocator = this->Allocator.get();
949 EXPECT_EQ(0u, Allocator->getStackDepotSize());
950 EXPECT_EQ(nullptr, Allocator->getStackDepotAddress());
954 auto *Allocator = this->Allocator.get();
955 Allocator->setTrackAllocationStacks(true);
957 auto StackDepotSize = Allocator->getStackDepotSize();
959 auto *StackDepotAddress = Allocator->getStackDepotAddress();
963 Allocator->setTrackAllocationStacks(true);
964 EXPECT_EQ(StackDepotSize, Allocator->getStackDepotSize());
965 EXPECT_EQ(StackDepotAddress, Allocator->getStackDepotAddress());
969 auto *Allocator = this->Allocator.get();
970 Allocator->setTrackAllocationStacks(true);
972 auto StackDepotSize = Allocator->getStackDepotSize();
974 EXPECT_EQ(Allocator->getStackDepotAddress()[StackDepotSize - 1], '\0');
978 auto *Allocator = this->Allocator.get();
979 Allocator->setTrackAllocationStacks(true);
981 auto *StackDepotAddress = Allocator->getStackDepotAddress();
983 EXPECT_EQ(StackDepotAddress, Allocator->getStackDepotAddress());
1012 using AllocatorT = scudo::Allocator<scudo::TrustyConfig>;
1013 auto Allocator = std::unique_ptr<AllocatorT>(new AllocatorT());
1020 void *p = Allocator->allocate(Size - scudo::Chunk::getHeaderSize(), Origin);
1027 *Allocator->getTSDRegistry());
1030 Allocator->releaseToOS(scudo::ReleaseToOS::Force);