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

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

Issue 1881933005: Oilpan: Add ThreadState cleanup callbacks for static thread-specific persistent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unit test Created 4 years, 8 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/ThreadState.cpp
diff --git a/third_party/WebKit/Source/platform/heap/ThreadState.cpp b/third_party/WebKit/Source/platform/heap/ThreadState.cpp
index 873baa3c94e48d340e093e52178b17933042dc4d..b26c3ea8315a6962b8d9be03a8cbc9e3d4ad4b60 100644
--- a/third_party/WebKit/Source/platform/heap/ThreadState.cpp
+++ b/third_party/WebKit/Source/platform/heap/ThreadState.cpp
@@ -292,6 +292,12 @@ void ThreadState::cleanup()
// pointers into the heap owned by this thread.
m_isTerminating = true;
+ // Invoke the cleanup hooks. This gives an opportunity to release any
+ // persistent handles that may exist, e.g. in thread-specific static
+ // locals.
+ for (const OwnPtr<SameThreadClosure>& hook : m_cleanupHooks)
+ (*hook)();
+
// Set the terminate flag on all heap pages of this thread. This is used to
// ensure we don't trace pages on other threads that are not part of the
// thread local GC.
@@ -1359,6 +1365,13 @@ void ThreadState::addInterruptor(PassOwnPtr<BlinkGCInterruptor> interruptor)
}
}
+void ThreadState::registerCleanupHook(PassOwnPtr<SameThreadClosure> hook)
+{
+ ASSERT(checkThread());
+ ASSERT(!isTerminating());
+ m_cleanupHooks.append(hook);
+}
+
#if defined(LEAK_SANITIZER)
void ThreadState::registerStaticPersistentNode(PersistentNode* node)
{

Powered by Google App Engine
This is Rietveld 408576698