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

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

Issue 802593004: WebAudio: Fix AudioNode leak in a case that AudioNode is not disconnected from the graph explicitly. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 5 years, 10 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 a552cc3bcace888a7640d578698db16cd19550bd..0ae8284286368653772f4242475dd2bbe5d75e9d 100644
--- a/Source/platform/heap/ThreadState.cpp
+++ b/Source/platform/heap/ThreadState.cpp
@@ -918,6 +918,7 @@ void ThreadState::preGC()
flushHeapDoesNotContainCacheIfNeeded();
if (isMainThread())
m_allocatedObjectSizeBeforeGC = Heap::allocatedObjectSize() + Heap::markedObjectSize();
+ invokePreMarkingTasks();
}
void ThreadState::postGC(GCType gcType)
@@ -942,11 +943,42 @@ void ThreadState::postGC(GCType gcType)
}
#endif
+ invokePostMarkingTasks();
setGCState(gcType == GCWithSweep ? EagerSweepScheduled : LazySweepScheduled);
for (int i = 0; i < NumberOfHeaps; i++)
m_heaps[i]->prepareForSweep();
}
+void ThreadState::invokePreMarkingTasks()
+{
+ ASSERT(isInGC());
+ for (MarkingTask* task : m_markingTasks)
+ task->willStartMarking(*this);
+}
+
+void ThreadState::invokePostMarkingTasks()
+{
+ ASSERT(isInGC());
+ for (size_t i = m_markingTasks.size(); i > 0; --i)
+ m_markingTasks[i - 1]->didFinishMarking(*this);
+}
+
+void ThreadState::addMarkingTask(MarkingTask* task)
+{
+ ASSERT(!isInGC());
+ checkThread();
+ m_markingTasks.append(task);
+}
+
+void ThreadState::removeMarkingTask(MarkingTask* task)
+{
+ ASSERT(!isInGC());
+ checkThread();
+ size_t position = m_markingTasks.find(task);
+ ASSERT(position != kNotFound);
+ m_markingTasks.remove(position);
+}
+
void ThreadState::prepareHeapForTermination()
{
checkThread();
@@ -1101,6 +1133,19 @@ void ThreadState::postGCProcessing()
}
}
+ if (!m_zombies.isEmpty()) {
+ TRACE_EVENT0("blink_gc", "Heap::visitObjects");
+ // The following marking should not run in multiple threads because
+ // it uses global resources such as s_markingStack.
+ SafePointAwareMutexLocker locker(threadAttachMutex(), NoHeapPointersOnStack);
+ GCState originalState = gcState();
+ setGCState(GCRunning);
+ invokePreMarkingTasks();
+ Heap::visitObjects(this, m_zombies);
+ invokePostMarkingTasks();
+ setGCState(originalState);
+ }
+
if (isMainThread())
ScriptForbiddenScope::exit();
}
@@ -1184,6 +1229,19 @@ void ThreadState::invokePreFinalizers(Visitor& visitor)
m_preFinalizers.removeAll(deadObjects);
}
+void ThreadState::markAsZombie(void* object)
+{
+ ASSERT(!isInGC());
+ checkThread();
+ ASSERT(!m_zombies.contains(object));
+ m_zombies.add(object);
+}
+
+void ThreadState::purifyZombies()
+{
+ m_zombies.clear();
+}
+
#if ENABLE(GC_PROFILING)
const GCInfo* ThreadState::findGCInfoFromAllThreads(Address address)
{
« 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