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

Unified Diff: third_party/WebKit/Source/platform/heap/PageMemory.h

Issue 1804863002: Refactor RegionTree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed 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
Index: third_party/WebKit/Source/platform/heap/PageMemory.h
diff --git a/third_party/WebKit/Source/platform/heap/PageMemory.h b/third_party/WebKit/Source/platform/heap/PageMemory.h
index 7a372a43b539e78b4fa43fca56848dcd1f2ca7f5..ba2a5b72a7276a8b21d223dde779ab90521e714f 100644
--- a/third_party/WebKit/Source/platform/heap/PageMemory.h
+++ b/third_party/WebKit/Source/platform/heap/PageMemory.h
@@ -17,6 +17,9 @@
namespace blink {
+class RegionTree;
+class RegionTreeNode;
+
class MemoryRegion {
USING_FAST_MALLOC(MemoryRegion);
public:
@@ -72,14 +75,14 @@ public:
m_inUse[index(page)] = false;
}
- static PageMemoryRegion* allocateLargePage(size_t size)
+ static PageMemoryRegion* allocateLargePage(size_t size, RegionTree* regionTree)
{
- return allocate(size, 1);
+ return allocate(size, 1, regionTree);
}
- static PageMemoryRegion* allocateNormalPages()
+ static PageMemoryRegion* allocateNormalPages(RegionTree* regionTree)
{
- return allocate(blinkPageSize * blinkPagesPerRegion, blinkPagesPerRegion);
+ return allocate(blinkPageSize * blinkPagesPerRegion, blinkPagesPerRegion, regionTree);
}
BasePage* pageFromAddress(Address address)
@@ -93,7 +96,7 @@ public:
}
private:
- PageMemoryRegion(Address base, size_t, unsigned numPages);
+ PageMemoryRegion(Address base, size_t, unsigned numPages, RegionTree*);
unsigned index(Address address) const
{
@@ -105,13 +108,14 @@ private:
return offset / blinkPageSize;
}
- static PageMemoryRegion* allocate(size_t, unsigned numPages);
+ static PageMemoryRegion* allocate(size_t, unsigned numPages, RegionTree*);
const bool m_isLargePage;
// A thread owns a page, but not a region. Represent the in-use
// bitmap such that thread non-interference comes for free.
bool m_inUse[blinkPagesPerRegion];
int m_numPages;
+ RegionTree* m_regionTree;
};
// A RegionTree is a simple binary search tree of PageMemoryRegions sorted
@@ -119,29 +123,41 @@ private:
class RegionTree {
USING_FAST_MALLOC(RegionTree);
public:
- explicit RegionTree(PageMemoryRegion* region)
+ RegionTree() : m_root(nullptr) { }
+
+ void add(PageMemoryRegion*);
+ void remove(PageMemoryRegion*);
+ PageMemoryRegion* lookup(Address);
+
+private:
+ Mutex m_mutex;
+ RegionTreeNode* m_root;
+};
+
+class RegionTreeNode {
+ USING_FAST_MALLOC(RegionTreeNode);
+public:
+ explicit RegionTreeNode(PageMemoryRegion* region)
: m_region(region)
, m_left(nullptr)
, m_right(nullptr)
{
}
- ~RegionTree()
+ ~RegionTreeNode()
{
delete m_left;
delete m_right;
}
- PageMemoryRegion* lookup(Address);
- static void add(RegionTree*, RegionTree**);
- static void remove(PageMemoryRegion*, RegionTree**);
+ void addTo(RegionTreeNode** context);
private:
PageMemoryRegion* m_region;
- RegionTree* m_left;
- RegionTree* m_right;
+ RegionTreeNode* m_left;
+ RegionTreeNode* m_right;
- static RegionTree* s_regionTree;
+ friend RegionTree;
};
// Representation of the memory used for a Blink heap page.
@@ -196,7 +212,7 @@ public:
//
// The returned page memory region will be zeroed.
//
- static PageMemory* allocate(size_t payloadSize);
+ static PageMemory* allocate(size_t payloadSize, RegionTree*);
private:
PageMemory(PageMemoryRegion* reserved, const MemoryRegion& writable);
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapPage.cpp ('k') | third_party/WebKit/Source/platform/heap/PageMemory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698