Chromium Code Reviews| Index: src/heap/spaces.h |
| diff --git a/src/heap/spaces.h b/src/heap/spaces.h |
| index b8fc9b7efe0845d4852b6660c8465abdda18f115..3558b325fc64137600ca631998a038443ae65ed6 100644 |
| --- a/src/heap/spaces.h |
| +++ b/src/heap/spaces.h |
| @@ -1694,6 +1694,8 @@ class FreeList { |
| PagedSpace* owner() { return owner_; } |
| private: |
| + enum FreeListCat { kSmall, kMedium, kLarge, kHuge }; |
|
Hannes Payer (out of office)
2015/09/23 12:00:43
FreeListCategoryType?
Michael Lippautz
2015/09/23 12:03:58
Done.
|
| + |
| // The size range of blocks, in bytes. |
| static const int kMinBlockSize = 3 * kPointerSize; |
| static const int kMaxBlockSize = Page::kMaxRegularHeapObjectSize; |
| @@ -1707,6 +1709,27 @@ class FreeList { |
| static const int kLargeAllocationMax = kMediumListMax; |
| FreeSpace* FindNodeFor(int size_in_bytes, int* node_size); |
| + FreeSpace* FindNodeIn(FreeListCat category, int* node_size); |
| + |
| + FreeListCategory* GetFreeListCategory(FreeListCat category) { |
| + switch (category) { |
| + case kSmall: |
| + return &small_list_; |
| + case kMedium: |
| + return &medium_list_; |
| + case kLarge: |
| + return &large_list_; |
| + case kHuge: |
| + return &huge_list_; |
| + default: |
| + UNREACHABLE(); |
| + } |
| + UNREACHABLE(); |
| + return nullptr; |
| + } |
| + |
| + void UpdateFragmentationStats(FreeListCat category, Address address, |
| + int size); |
| PagedSpace* owner_; |
| Heap* heap_; |
| @@ -1715,6 +1738,8 @@ class FreeList { |
| FreeListCategory large_list_; |
| FreeListCategory huge_list_; |
| + friend class PagedSpace; |
| + |
| DISALLOW_IMPLICIT_CONSTRUCTORS(FreeList); |
| }; |
| @@ -1997,6 +2022,22 @@ class PagedSpace : public Space { |
| virtual bool is_local() { return false; } |
| + // Divide {this} free lists up among {other_free_lists} up to some certain |
| + // {limit} of bytes. Note that this operation eventually needs to iterate |
| + // over nodes one-by-one, making it a potentially slow operation. |
| + void DivideFreeLists(FreeList** other_free_lists, int num, intptr_t limit); |
| + |
| + // Adds memory starting at {start} of {size_in_bytes} to the space. |
| + void AddMemory(Address start, int size_in_bytes) { |
| + IncreaseCapacity(size_in_bytes); |
| + Free(start, size_in_bytes); |
| + } |
| + |
| + // Tries to remove some memory from {this} free lists. We try to remove |
| + // as much memory as possible, i.e., we check the free lists from huge |
| + // to small. |
| + FreeSpace* TryRemoveMemory(); |
| + |
| protected: |
| // PagedSpaces that should be included in snapshots have different, i.e., |
| // smaller, initial pages. |
| @@ -2744,12 +2785,6 @@ class CompactionSpace : public PagedSpace { |
| CompactionSpace(Heap* heap, AllocationSpace id, Executability executable) |
| : PagedSpace(heap, id, executable) {} |
| - // Adds external memory starting at {start} of {size_in_bytes} to the space. |
| - void AddExternalMemory(Address start, int size_in_bytes) { |
| - IncreaseCapacity(size_in_bytes); |
| - Free(start, size_in_bytes); |
| - } |
| - |
| virtual bool is_local() { return true; } |
| protected: |