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

Unified Diff: src/heap/spaces.h

Issue 1774953003: [heap] Add two tiny free list categories. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | src/heap/spaces.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/spaces.h
diff --git a/src/heap/spaces.h b/src/heap/spaces.h
index b940a21f4ecf4c1e23c8ff3f395086bda8d7a248..06639366f5f70cf53fd1abdc257b9d3c93b3c678 100644
--- a/src/heap/spaces.h
+++ b/src/heap/spaces.h
@@ -724,12 +724,14 @@ class MemoryChunk {
};
enum FreeListCategoryType {
+ kTiniest,
+ kTiny,
kSmall,
kMedium,
kLarge,
kHuge,
- kFirstCategory = kSmall,
+ kFirstCategory = kTiniest,
kLastCategory = kHuge,
kNumberOfCategories = kLastCategory + 1
};
@@ -1650,9 +1652,10 @@ class FreeListCategory {
// categories would scatter allocation more.
// The free list is organized in categories as follows:
-// 1-31 words (too small): Such small free areas are discarded for efficiency
-// reasons. They can be reclaimed by the compactor. However the distance
-// between top and limit may be this small.
+// kMinBlockSize-10 words (tiniest): The tiniest blocks are only used for
+// allocation, when categories >= small do not have entries anymore.
+// 11-31 words (tiny): The tiny blocks are only used for allocation, when
+// categories >= small do not have entries anymore.
// 32-255 words (small): Used for allocating free space between 1-31 words in
// size.
// 256-2047 words (medium): Used for allocating free space between 32-255 words
@@ -1666,8 +1669,12 @@ class FreeList {
// This method returns how much memory can be allocated after freeing
// maximum_freed memory.
static inline int GuaranteedAllocatable(int maximum_freed) {
- if (maximum_freed <= kSmallListMin) {
+ if (maximum_freed <= kTiniestListMax) {
+ // Since we are not iterating over all list entries, we cannot guarantee
+ // that we can find the maximum freed block in that free list.
return 0;
+ } else if (maximum_freed <= kTinyListMax) {
+ return kTinyAllocationMax;
} else if (maximum_freed <= kSmallListMax) {
return kSmallAllocationMax;
} else if (maximum_freed <= kMediumListMax) {
@@ -1749,11 +1756,13 @@ class FreeList {
static const int kMinBlockSize = 3 * kPointerSize;
static const int kMaxBlockSize = Page::kAllocatableMemory;
- static const int kSmallListMin = 0x1f * kPointerSize;
+ static const int kTiniestListMax = 0xa * kPointerSize;
+ static const int kTinyListMax = 0x1f * kPointerSize;
static const int kSmallListMax = 0xff * kPointerSize;
static const int kMediumListMax = 0x7ff * kPointerSize;
static const int kLargeListMax = 0x3fff * kPointerSize;
- static const int kSmallAllocationMax = kSmallListMin;
+ static const int kTinyAllocationMax = kTiniestListMax;
+ static const int kSmallAllocationMax = kTinyListMax;
static const int kMediumAllocationMax = kSmallListMax;
static const int kLargeAllocationMax = kMediumListMax;
@@ -1765,7 +1774,11 @@ class FreeList {
}
FreeListCategoryType SelectFreeListCategoryType(size_t size_in_bytes) {
- if (size_in_bytes <= kSmallListMax) {
+ if (size_in_bytes <= kTiniestListMax) {
+ return kTiniest;
+ } else if (size_in_bytes <= kTinyListMax) {
+ return kTiny;
+ } else if (size_in_bytes <= kSmallListMax) {
return kSmall;
} else if (size_in_bytes <= kMediumListMax) {
return kMedium;
@@ -1775,6 +1788,7 @@ class FreeList {
return kHuge;
}
+ // The tiny categories are not used for fast allocation.
FreeListCategoryType SelectFastAllocationFreeListCategoryType(
size_t size_in_bytes) {
if (size_in_bytes <= kSmallAllocationMax) {
« no previous file with comments | « no previous file | src/heap/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698