[asan] implement AsanChunkFifoList via IntrusiveList<AsanChunk>

llvm-svn: 170313
This commit is contained in:
Kostya Serebryany 2012-12-17 07:54:29 +00:00
parent 3e70c45fa8
commit 41ffe3db59
2 changed files with 8 additions and 35 deletions

View File

@ -188,34 +188,13 @@ static AsanChunk *PtrToChunk(uptr ptr) {
void AsanChunkFifoList::PushList(AsanChunkFifoList *q) {
CHECK(q->size() > 0);
if (last_) {
CHECK(first_);
CHECK(!last_->next);
last_->next = q->first_;
last_ = q->last_;
} else {
CHECK(!first_);
last_ = q->last_;
first_ = q->first_;
CHECK(first_);
}
CHECK(last_);
CHECK(!last_->next);
size_ += q->size();
append_back(q);
q->clear();
}
void AsanChunkFifoList::Push(AsanChunk *n) {
CHECK(n->next == 0);
if (last_) {
CHECK(first_);
CHECK(!last_->next);
last_->next = n;
last_ = n;
} else {
CHECK(!first_);
last_ = first_ = n;
}
push_back(n);
size_ += n->Size();
}
@ -224,15 +203,9 @@ void AsanChunkFifoList::Push(AsanChunk *n) {
// ago. Not sure if we can or want to do anything with this.
AsanChunk *AsanChunkFifoList::Pop() {
CHECK(first_);
AsanChunk *res = first_;
first_ = first_->next;
if (first_ == 0)
last_ = 0;
CHECK(size_ >= res->Size());
AsanChunk *res = front();
size_ -= res->Size();
if (last_) {
CHECK(!last_->next);
}
pop_front();
return res;
}

View File

@ -17,6 +17,7 @@
#include "asan_internal.h"
#include "asan_interceptors.h"
#include "sanitizer_common/sanitizer_list.h"
// We are in the process of transitioning from the old allocator (version 1)
// to a new one (version 2). The change is quite intrusive so both allocators
@ -72,7 +73,8 @@ class AsanChunkView {
AsanChunkView FindHeapChunkByAddress(uptr address);
class AsanChunkFifoList {
// List of AsanChunks with total size.
class AsanChunkFifoList: public IntrusiveList<AsanChunk> {
public:
explicit AsanChunkFifoList(LinkerInitialized) { }
AsanChunkFifoList() { clear(); }
@ -81,12 +83,10 @@ class AsanChunkFifoList {
AsanChunk *Pop();
uptr size() { return size_; }
void clear() {
first_ = last_ = 0;
IntrusiveList<AsanChunk>::clear();
size_ = 0;
}
private:
AsanChunk *first_;
AsanChunk *last_;
uptr size_;
};