Chromium Code Reviews| Index: src/spaces.h |
| diff --git a/src/spaces.h b/src/spaces.h |
| index e7e4d529fcbe5a82b5dbb79a606d904339dc5d5e..1b010f6f3c82bf8abb0146ccd9012d680e4c9e08 100644 |
| --- a/src/spaces.h |
| +++ b/src/spaces.h |
| @@ -1526,6 +1526,11 @@ class FreeList BASE_EMBEDDED { |
| large_list_.available() + huge_list_.available(); |
| } |
| + enum AllocationStrategy { |
| + BEST_FIT, |
| + WORST_FIT |
| + }; |
| + |
| // Place a node on the free list. The block of size 'size_in_bytes' |
| // starting at 'start' is placed on the free list. The return value is the |
| // number of bytes that have been lost due to internal fragmentation by |
| @@ -1538,6 +1543,7 @@ class FreeList BASE_EMBEDDED { |
| // is unitialized. A failure is returned if no block is available. The |
| // number of bytes lost to fragmentation is returned in the output parameter |
| // 'wasted_bytes'. The size should be a non-zero multiple of the word size. |
| + template<AllocationStrategy strategy> |
| MUST_USE_RESULT HeapObject* Allocate(int size_in_bytes); |
| #ifdef DEBUG |
| @@ -1561,7 +1567,14 @@ class FreeList BASE_EMBEDDED { |
| static const int kMinBlockSize = 3 * kPointerSize; |
| static const int kMaxBlockSize = Page::kMaxNonCodeHeapObjectSize; |
| - FreeListNode* FindNodeFor(int size_in_bytes, int* node_size); |
| + FreeListNode* FindNodeInHugeList(int size_in_bytes, int* node_size); |
| + |
| + // Finds a node in the free-list using the best-fit allocation strategy. |
| + FreeListNode* FindNodeForBestFit(int size_in_bytes, int* node_size); |
| + |
| + // Finds a node in the free-list using the worst-fit allocation strategy |
| + // and it ignores the smalles category. |
|
Michael Starzinger
2013/04/16 13:29:27
nit: s/smalles/smallest/
Hannes Payer (out of office)
2013/04/16 13:41:04
Done.
|
| + FreeListNode* FindNodeForWorstFit(int size_in_bytes, int* node_size); |
| PagedSpace* owner_; |
| Heap* heap_; |
| @@ -1692,6 +1705,7 @@ class PagedSpace : public Space { |
| // Allocate the requested number of bytes in the space if possible, return a |
| // failure object if not. |
| + template<FreeList::AllocationStrategy strategy> |
| MUST_USE_RESULT inline MaybeObject* AllocateRaw(int size_in_bytes); |
| virtual bool ReserveSpace(int bytes); |
| @@ -1869,7 +1883,8 @@ class PagedSpace : public Space { |
| inline HeapObject* AllocateLinearly(int size_in_bytes); |
| // Slow path of AllocateRaw. This function is space-dependent. |
| - MUST_USE_RESULT virtual HeapObject* SlowAllocateRaw(int size_in_bytes); |
| + template<FreeList::AllocationStrategy strategy> |
| + MUST_USE_RESULT HeapObject* SlowAllocateRaw(int size_in_bytes); |
| friend class PageIterator; |
| friend class SweeperThread; |