Chromium Code Reviews| 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); |