Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: src/spaces.h

Issue 14208005: Use worst-fit allocation in old space for prentured objects. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.cc ('k') | src/spaces.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/spaces.h
diff --git a/src/spaces.h b/src/spaces.h
index e7e4d529fcbe5a82b5dbb79a606d904339dc5d5e..353aa2c955f1233d75af59dda4a77548d369fab6 100644
--- a/src/spaces.h
+++ b/src/spaces.h
@@ -1327,11 +1327,13 @@ class AllocationStats BASE_EMBEDDED {
capacity_ = 0;
size_ = 0;
waste_ = 0;
+ pretenure_ = 0;
}
void ClearSizeWaste() {
size_ = capacity_;
waste_ = 0;
+ pretenure_ = 0;
}
// Reset the allocation statistics (i.e., available = capacity with no
@@ -1339,12 +1341,14 @@ class AllocationStats BASE_EMBEDDED {
void Reset() {
size_ = 0;
waste_ = 0;
+ pretenure_ = 0;
}
// Accessors for the allocation statistics.
intptr_t Capacity() { return capacity_; }
intptr_t Size() { return size_; }
intptr_t Waste() { return waste_; }
+ intptr_t Pretenure() { return pretenure_; }
// Grow the space by adding available bytes. They are initially marked as
// being in use (part of the size), but will normally be immediately freed,
@@ -1370,6 +1374,11 @@ class AllocationStats BASE_EMBEDDED {
ASSERT(size_ >= 0);
}
+ void AllocatePretenureBytes(intptr_t size_in_bytes) {
+ pretenure_ += size_in_bytes;
+ ASSERT(pretenure_ >= 0);
+ }
+
// Free allocated bytes, making them available (size -> available).
void DeallocateBytes(intptr_t size_in_bytes) {
size_ -= size_in_bytes;
@@ -1387,6 +1396,9 @@ class AllocationStats BASE_EMBEDDED {
intptr_t capacity_;
intptr_t size_;
intptr_t waste_;
+ // TODO(hpayer): We can remove the bookkeeping of pretenured objects when
+ // we provide pretenuring support for all kinds of objects.
+ intptr_t pretenure_;
};
@@ -1526,6 +1538,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 +1555,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 +1579,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 smallest category.
+ FreeListNode* FindNodeForWorstFit(int size_in_bytes, int* node_size);
PagedSpace* owner_;
Heap* heap_;
@@ -1673,6 +1698,8 @@ class PagedSpace : public Space {
// linear allocation area (between top and limit) are also counted here.
virtual intptr_t Size() { return accounting_stats_.Size(); }
+ intptr_t Pretenure() { return accounting_stats_.Pretenure(); }
+
// As size, but the bytes in lazily swept pages are estimated and the bytes
// in the current linear allocation area are not included.
virtual intptr_t SizeOfObjects();
@@ -1692,6 +1719,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);
@@ -1723,6 +1751,10 @@ class PagedSpace : public Space {
accounting_stats_.AllocateBytes(bytes);
}
+ void AllocatePretenure(int bytes) {
+ accounting_stats_.AllocatePretenureBytes(bytes);
+ }
+
void IncreaseCapacity(int size) {
accounting_stats_.ExpandSpace(size);
}
@@ -1869,7 +1901,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;
« no previous file with comments | « src/runtime.cc ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698