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

Unified Diff: Source/platform/heap/Heap.h

Issue 711053002: Prepare for incremental sweep by making the FreeList independent of the ThreadHeap (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month 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 | Source/platform/heap/Heap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/Heap.h
diff --git a/Source/platform/heap/Heap.h b/Source/platform/heap/Heap.h
index 072f140719e6d1e038f150aa9980b55557286bca..6f38a90997ad30bd1efd29abdf37d81e07780860 100644
--- a/Source/platform/heap/Heap.h
+++ b/Source/platform/heap/Heap.h
@@ -723,11 +723,29 @@ public:
virtual PassOwnPtr<BaseHeap> split(int normalPages) = 0;
virtual void merge(PassOwnPtr<BaseHeap> other) = 0;
+};
+
+template<typename Header>
+class FreeList {
+public:
+ FreeList();
+
+ void addToFreeList(Address, size_t);
+ void clear();
+private:
// Returns a bucket number for inserting a FreeListEntry of a
// given size. All FreeListEntries in the given bucket, n, have
// size >= 2^n.
static int bucketIndexForSize(size_t);
+
+ int m_biggestFreeListIndex;
+
+ // All FreeListEntries in the nth list have size >= 2^n.
+ FreeListEntry* m_freeLists[blinkPageSizeLog2];
+ FreeListEntry* m_lastFreeListEntries[blinkPageSizeLog2];
+
+ friend class ThreadHeap<Header>;
};
// Thread heaps represent a part of the per-thread Blink heap.
@@ -772,8 +790,14 @@ public:
ThreadState* threadState() { return m_threadState; }
HeapStats& stats() { return m_threadState->stats(); }
+ void addToFreeList(Address address, size_t size)
+ {
+ ASSERT(heapPageFromAddress(address));
+ ASSERT(heapPageFromAddress(address + size - 1));
+ m_freeList.addToFreeList(address, size);
+ }
+
inline Address allocate(size_t, const GCInfo*);
- void addToFreeList(Address, size_t);
inline static size_t roundedAllocationSize(size_t size)
{
return allocationSizeFromSize(size) - sizeof(Header);
@@ -834,13 +858,9 @@ private:
// Merge point for parallel sweep.
HeapPage<Header>* m_mergePoint;
- int m_biggestFreeListIndex;
-
ThreadState* m_threadState;
- // All FreeListEntries in the nth list have size >= 2^n.
- FreeListEntry* m_freeLists[blinkPageSizeLog2];
- FreeListEntry* m_lastFreeListEntries[blinkPageSizeLog2];
+ FreeList<Header> m_freeList;
// Index into the page pools. This is used to ensure that the pages of the
// same type go into the correct page pool and thus avoid type confusion.
« no previous file with comments | « no previous file | Source/platform/heap/Heap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698