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

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: short copyright header Created 6 years, 3 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: Source/platform/heap/ThreadState.cpp
diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp
index 7dc044028e5de8affae544cb3b1ff6a89ce59461..407bd2a22dad3ff7e20ae69e2d5b51ca14f4084e 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_liveWrapperPersistents(new WrapperPersistentRegion())
+ , m_pooledWrapperPersistents(0)
+ , m_numPooledWrapperPersistentRegions(0)
, m_persistents(adoptPtr(new PersistentAnchor()))
, m_startOfStack(reinterpret_cast<intptr_t*>(getStackStart()))
, m_endOfStack(reinterpret_cast<intptr_t*>(getStackStart()))
@@ -330,6 +332,14 @@ ThreadState::~ThreadState()
for (int i = 0; i < NumberOfHeaps; i++)
delete m_heaps[i];
deleteAllValues(m_interruptors);
+ while (m_liveWrapperPersistents) {
+ WrapperPersistentRegion* region = WrapperPersistentRegion::removeHead(&m_liveWrapperPersistents);
+ delete region;
+ }
+ while (m_pooledWrapperPersistents) {
+ WrapperPersistentRegion* region = WrapperPersistentRegion::removeHead(&m_pooledWrapperPersistents);
+ delete region;
+ }
**s_threadSpecific = 0;
}
@@ -561,6 +571,7 @@ void ThreadState::visitStack(Visitor* visitor)
void ThreadState::visitPersistents(Visitor* visitor)
{
m_persistents->trace(visitor);
+ WrapperPersistentRegion::trace(m_liveWrapperPersistents, visitor);
}
bool ThreadState::checkAndMarkPointer(Visitor* visitor, Address address)
@@ -680,6 +691,34 @@ bool ThreadState::popAndInvokeWeakPointerCallback(Visitor* visitor)
return m_weakCallbackStack->popAndInvokeCallback<WeaknessProcessing>(&m_weakCallbackStack, visitor);
}
+WrapperPersistentRegion* ThreadState::addWrapperPersistentRegion()
+{
+ WrapperPersistentRegion* region;
+ if (m_numPooledWrapperPersistentRegions) {
+ region = WrapperPersistentRegion::removeHead(&m_pooledWrapperPersistents);
+ m_numPooledWrapperPersistentRegions--;
+ } else {
+ region = new WrapperPersistentRegion();
+ }
+ ASSERT(region);
+ WrapperPersistentRegion::insertHead(&m_liveWrapperPersistents, region);
+ return region;
+}
+
+void ThreadState::removeWrapperPersistentRegion(WrapperPersistentRegion* region)
+{
+ if (!region->removeIfNotLast(&m_liveWrapperPersistents))
haraken 2014/09/02 13:00:37 Can we avoid introducing removeIfNotLast and clean
wibling-chromium 2014/09/02 13:55:33 No, I did try having an anchor and it doesn't simp
+ return;
+
+ // Region was removed, ie. it was not the last region in the list.
+ if (m_numPooledWrapperPersistentRegions < 2) {
haraken 2014/09/02 13:00:37 Add a comment about '< 2' or use a static constant
wibling-chromium 2014/09/02 13:55:33 Added a constant.
+ WrapperPersistentRegion::insertHead(&m_pooledWrapperPersistents, region);
+ m_numPooledWrapperPersistentRegions++;
+ } else {
+ delete region;
+ }
+}
+
PersistentNode* ThreadState::globalRoots()
{
AtomicallyInitializedStatic(PersistentNode*, anchor = new PersistentAnchor);

Powered by Google App Engine
This is Rietveld 408576698