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

Unified Diff: Source/platform/heap/ThreadState.cpp

Issue 525353002: [oilpan]: optimize the way we allocate persistent handles in wrappers. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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
« Source/platform/heap/ThreadState.h ('K') | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/ThreadState.cpp
diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp
index 7dc044028e5de8affae544cb3b1ff6a89ce59461..103d16c05fb44cb9aedd1383e50780e35e415511 100644
--- a/Source/platform/heap/ThreadState.cpp
+++ b/Source/platform/heap/ThreadState.cpp
@@ -265,7 +265,6 @@ private:
ThreadCondition m_resume;
};
-
BaseHeapPage::BaseHeapPage(PageMemory* storage, const GCInfo* gcInfo, ThreadState* state)
: m_storage(storage)
, m_gcInfo(gcInfo)
@@ -292,6 +291,9 @@ template<> struct InitializeHeaps<0> {
ThreadState::ThreadState()
: m_thread(currentThread())
+ , m_wrapperPersistents(new WrapperPersistentRegion())
+ , m_wrapperPersistentRegionPool(0)
+ , m_wrapperPersistentRegionPoolSize(0)
, m_persistents(adoptPtr(new PersistentAnchor()))
, m_startOfStack(reinterpret_cast<intptr_t*>(getStackStart()))
, m_endOfStack(reinterpret_cast<intptr_t*>(getStackStart()))
@@ -330,6 +332,10 @@ ThreadState::~ThreadState()
for (int i = 0; i < NumberOfHeaps; i++)
delete m_heaps[i];
deleteAllValues(m_interruptors);
+ while (m_wrapperPersistents) {
Mads Ager (chromium) 2014/09/01 13:52:46 How about regions that are in the pool? Should we
wibling-chromium 2014/09/02 11:19:38 That seems like a good idea:) Fixed.
+ WrapperPersistentRegion* region = WrapperPersistentRegion::removeHead(&m_wrapperPersistents);
+ delete region;
+ }
**s_threadSpecific = 0;
}
@@ -561,6 +567,7 @@ void ThreadState::visitStack(Visitor* visitor)
void ThreadState::visitPersistents(Visitor* visitor)
{
m_persistents->trace(visitor);
+ m_wrapperPersistents->trace(visitor);
}
bool ThreadState::checkAndMarkPointer(Visitor* visitor, Address address)
@@ -680,6 +687,35 @@ bool ThreadState::popAndInvokeWeakPointerCallback(Visitor* visitor)
return m_weakCallbackStack->popAndInvokeCallback<WeaknessProcessing>(&m_weakCallbackStack, visitor);
}
+WrapperPersistentRegion* ThreadState::addWrapperPersistentRegion()
+{
+ WrapperPersistentRegion* region;
+ if (m_wrapperPersistentRegionPoolSize) {
+ region = WrapperPersistentRegion::removeHead(&m_wrapperPersistentRegionPool);
+ m_wrapperPersistentRegionPoolSize--;
+ } else {
+ region = new WrapperPersistentRegion();
+ }
+ ASSERT(region);
+ WrapperPersistentRegion::insertHead(&m_wrapperPersistents, region);
+ return region;
+}
+
+void ThreadState::removeWrapperPersistentRegion(WrapperPersistentRegion* region)
+{
+ ASSERT(!region->count());
+ if (!region->removeIfNotLast(&m_wrapperPersistents))
+ return;
+
+ // Region was removed, ie. it is was not the last region in the list.
haraken 2014/09/02 05:22:06 it is was => it was
wibling-chromium 2014/09/02 11:19:38 Done.
+ if (m_wrapperPersistentRegionPoolSize < 2) {
haraken 2014/09/02 05:22:06 What does the '< 2' check mean?
wibling-chromium 2014/09/02 11:19:38 It means we will only keep at most two regions in
+ WrapperPersistentRegion::insertHead(&m_wrapperPersistentRegionPool, region);
+ m_wrapperPersistentRegionPoolSize++;
+ } else {
+ delete region;
+ }
+}
+
PersistentNode* ThreadState::globalRoots()
{
AtomicallyInitializedStatic(PersistentNode*, anchor = new PersistentAnchor);
« Source/platform/heap/ThreadState.h ('K') | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698