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

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

Issue 1962513002: Upon clearing, release PersistentNode of cross-thread-persistent also. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tidy Created 4 years, 7 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/HeapTest.cpp
diff --git a/third_party/WebKit/Source/platform/heap/HeapTest.cpp b/third_party/WebKit/Source/platform/heap/HeapTest.cpp
index 9810e94dc593b50d24f60b1a1341b44bae7693d1..95e7bb98119eadaae5e3c70311bf21ee291567db 100644
--- a/third_party/WebKit/Source/platform/heap/HeapTest.cpp
+++ b/third_party/WebKit/Source/platform/heap/HeapTest.cpp
@@ -514,20 +514,42 @@ public:
ThreadedTesterBase::test(new ThreadedHeapTester);
}
+ ~ThreadedHeapTester() override
+ {
+ // Verify that the threads cleared their CTPs when
+ // terminating, preventing access to a finalized heap.
+ for (auto& globalIntWrapper : m_crossPersistents) {
+ ASSERT(globalIntWrapper.get());
+ EXPECT_FALSE(globalIntWrapper.get()->get());
+ }
+ }
+
protected:
using GlobalIntWrapperPersistent = CrossThreadPersistent<IntWrapper>;
+ Mutex m_mutex;
+ Vector<OwnPtr<GlobalIntWrapperPersistent>> m_crossPersistents;
+
PassOwnPtr<GlobalIntWrapperPersistent> createGlobalPersistent(int value)
{
return adoptPtr(new GlobalIntWrapperPersistent(IntWrapper::create(value)));
}
+ void addGlobalPersistent()
+ {
+ MutexLocker lock(m_mutex);
+ m_crossPersistents.append(createGlobalPersistent(0x2a2a2a2a));
+ }
+
void runThread() override
{
- OwnPtr<GlobalIntWrapperPersistent> longLivingPersistent;
ThreadState::attachCurrentThread(false);
- longLivingPersistent = createGlobalPersistent(0x2a2a2a2a);
+ // Add a cross-thread persistent from this thread; the test object
+ // verifies that it will have been cleared out after the threads
+ // have all detached, running their termination GCs while doing so.
+ addGlobalPersistent();
+
int gcCount = 0;
while (!done()) {
ThreadState::current()->safePoint(BlinkGC::NoHeapPointersOnStack);
@@ -563,12 +585,6 @@ protected:
testing::yieldCurrentThread();
}
- // Intentionally leak the cross-thread persistent so as to verify
- // that later GCs correctly handle cross-thread persistents that
- // refer to finalized objects after their heaps have been detached
- // and freed.
- EXPECT_TRUE(longLivingPersistent.leakPtr());
-
ThreadState::detachCurrentThread();
atomicDecrement(&m_threadsToFinish);
}
« no previous file with comments | « third_party/WebKit/Source/platform/heap/Handle.h ('k') | third_party/WebKit/Source/platform/heap/PersistentNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698