Lines Matching refs:Chunk
69 class Chunk;
82 void MoveToFullList(Chunk* chunk, int bucket_);
83 void MoveToFreeList(Chunk* chunk, int bucket_);
88 LinkedList<Chunk*> free_chunks_[kNumBuckets];
89 LinkedList<Chunk*> full_chunks_[kNumBuckets];
91 void MoveToList(Chunk* chunk, LinkedList<Chunk*>* head);
168 class Chunk {
172 Chunk(HeapImpl* heap, int bucket);
173 ~Chunk() {}
180 static Chunk* ptr_to_chunk(void* ptr) {
181 return reinterpret_cast<Chunk*>(reinterpret_cast<uintptr_t>(ptr)
194 LinkedList<Chunk*> node_; // linked list sorted by minimum free count
197 DISALLOW_COPY_AND_ASSIGN(Chunk);
200 unsigned int allocation_size_; // size of allocations in chunk, min 8 bytes
201 unsigned int max_allocations_; // maximum number of allocations in the chunk
223 static_assert(sizeof(Chunk) <= kPageSize, "header must fit in page");
225 // Override new operator on chunk to use mmap to allocate kChunkSize
226 void* Chunk::operator new(std::size_t count __attribute__((unused))) noexcept {
227 assert(count == sizeof(Chunk));
236 // Override new operator on chunk to use mmap to allocate kChunkSize
237 void Chunk::operator delete(void *ptr) {
238 assert(reinterpret_cast<Chunk*>(ptr) == ptr_to_chunk(ptr));
242 Chunk::Chunk(HeapImpl* heap, int bucket) :
251 bool Chunk::Empty() {
255 void* Chunk::Alloc() {
280 void Chunk::Free(void* ptr) {
308 void Chunk::Purge() {
337 for (LinkedList<Chunk*> *it = free_chunks_[i].next(); it->data() != NULL; it = it->next()) {
342 for (LinkedList<Chunk*> *it = full_chunks_[i].next(); it->data() != NULL; it = it->next()) {
355 Chunk *chunk = free_chunks_[i].next()->data();
356 chunk->node_.remove();
357 delete chunk;
360 Chunk *chunk = full_chunks_[i].next()->data();
361 chunk->node_.remove();
362 delete chunk;
378 Chunk *chunk = new Chunk(this, bucket);
379 free_chunks_[bucket].insert(chunk->node_);
390 if (!Chunk::is_chunk(ptr)) {
393 Chunk* chunk = Chunk::ptr_to_chunk(ptr);
394 assert(chunk->heap() == this);
395 chunk->Free(ptr);
430 void HeapImpl::MoveToFreeList(Chunk *chunk, int bucket) {
431 MoveToList(chunk, &free_chunks_[bucket]);
434 void HeapImpl::MoveToFullList(Chunk *chunk, int bucket) {
435 MoveToList(chunk, &full_chunks_[bucket]);
438 void HeapImpl::MoveToList(Chunk *chunk, LinkedList<Chunk*>* head) {
440 chunk->node_.remove();
442 LinkedList<Chunk*> *node = head;
445 && node->data()->free_count() < chunk->free_count())
448 node->insert(chunk->node_);