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

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

Issue 1477023003: Refactor the Heap into ThreadHeap to prepare for per thread heaps Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactored Created 4 years, 11 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.cpp
diff --git a/third_party/WebKit/Source/platform/heap/PageMemory.cpp b/third_party/WebKit/Source/platform/heap/PageMemory.cpp
index 5efe1fcede7eb3036afbf20179a5dcfb76e7911d..9089b9258438da0f6b3c715764f2c93eee9d571c 100644
--- a/third_party/WebKit/Source/platform/heap/PageMemory.cpp
+++ b/third_party/WebKit/Source/platform/heap/PageMemory.cpp
@@ -5,6 +5,7 @@
#include "platform/heap/PageMemory.h"
#include "platform/heap/Heap.h"
+#include "platform/heap/ThreadState.h"
#include "wtf/Assertions.h"
#include "wtf/PageAllocator.h"
@@ -28,19 +29,20 @@ void MemoryRegion::decommit()
}
-PageMemoryRegion::PageMemoryRegion(Address base, size_t size, unsigned numPages)
+PageMemoryRegion::PageMemoryRegion(Address base, size_t size, unsigned numPages, GCGroup* gcGroup)
: MemoryRegion(base, size)
, m_isLargePage(numPages == 1)
, m_numPages(numPages)
+ , m_gcGroup(gcGroup)
{
- Heap::addPageMemoryRegion(this);
for (size_t i = 0; i < blinkPagesPerRegion; ++i)
m_inUse[i] = false;
+ m_gcGroup->addPageMemoryRegion(this);
}
PageMemoryRegion::~PageMemoryRegion()
{
- Heap::removePageMemoryRegion(this);
+ m_gcGroup->removePageMemoryRegion(this);
release();
}
@@ -52,14 +54,14 @@ static NEVER_INLINE void blinkGCOutOfMemory()
IMMEDIATE_CRASH();
}
-PageMemoryRegion* PageMemoryRegion::allocate(size_t size, unsigned numPages)
+PageMemoryRegion* PageMemoryRegion::allocate(size_t size, unsigned numPages, GCGroup* gcGroup)
{
// Round size up to the allocation granularity.
size = (size + WTF::kPageAllocationGranularityOffsetMask) & WTF::kPageAllocationGranularityBaseMask;
Address base = static_cast<Address>(WTF::allocPages(nullptr, size, blinkPageSize, WTF::PageInaccessible));
if (!base)
blinkGCOutOfMemory();
- return new PageMemoryRegion(base, size, numPages);
+ return new PageMemoryRegion(base, size, numPages, gcGroup);
}
PageMemoryRegion* RegionTree::lookup(Address address)
@@ -145,7 +147,7 @@ static size_t roundToOsPageSize(size_t size)
return (size + WTF::kSystemPageSize - 1) & ~(WTF::kSystemPageSize - 1);
}
-PageMemory* PageMemory::allocate(size_t payloadSize)
+PageMemory* PageMemory::allocate(size_t payloadSize, GCGroup* gcGroup)
{
ASSERT(payloadSize > 0);
@@ -156,7 +158,7 @@ PageMemory* PageMemory::allocate(size_t payloadSize)
// Overallocate by 2 times OS page size to have space for a
// guard page at the beginning and end of blink heap page.
size_t allocationSize = payloadSize + 2 * blinkGuardPageSize;
- PageMemoryRegion* pageMemoryRegion = PageMemoryRegion::allocateLargePage(allocationSize);
+ PageMemoryRegion* pageMemoryRegion = PageMemoryRegion::allocateLargePage(allocationSize, gcGroup);
PageMemory* storage = setupPageMemoryInRegion(pageMemoryRegion, 0, payloadSize);
RELEASE_ASSERT(storage->commit());
return storage;

Powered by Google App Engine
This is Rietveld 408576698