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

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

Issue 1265103003: Invalidate cross-thread persistents on heap termination. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: simplify the invalidation as ref-clearing Created 5 years, 4 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
« no previous file with comments | « no previous file | Source/platform/heap/PersistentNode.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/HeapTest.cpp
diff --git a/Source/platform/heap/HeapTest.cpp b/Source/platform/heap/HeapTest.cpp
index 59488cfd8b619426ec40ff8bbc4fa4fa38c8cfe6..c6ee3764ff84963918c0963c102d14a9d473f0d0 100644
--- a/Source/platform/heap/HeapTest.cpp
+++ b/Source/platform/heap/HeapTest.cpp
@@ -499,23 +499,31 @@ public:
}
protected:
+ using GlobalIntWrapperPersistent = CrossThreadPersistent<IntWrapper>;
+
+ PassOwnPtr<GlobalIntWrapperPersistent> createGlobalPersistent(int value)
+ {
+ return adoptPtr(new GlobalIntWrapperPersistent(IntWrapper::create(value)));
+ }
+
void runThread() override
{
+ OwnPtr<GlobalIntWrapperPersistent> longLivingPersistent;
ThreadState::attach();
+ longLivingPersistent = createGlobalPersistent(0x2a2a2a2a);
int gcCount = 0;
while (!done()) {
ThreadState::current()->safePoint(ThreadState::NoHeapPointersOnStack);
{
Persistent<IntWrapper> wrapper;
- typedef CrossThreadPersistent<IntWrapper> GlobalIntWrapperPersistent;
- OwnPtr<GlobalIntWrapperPersistent> globalPersistent = adoptPtr(new GlobalIntWrapperPersistent(IntWrapper::create(0x0ed0cabb)));
+ OwnPtr<GlobalIntWrapperPersistent> globalPersistent = createGlobalPersistent(0x0ed0cabb);
for (int i = 0; i < numberOfAllocations; i++) {
wrapper = IntWrapper::create(0x0bbac0de);
if (!(i % 10)) {
- globalPersistent = adoptPtr(new GlobalIntWrapperPersistent(IntWrapper::create(0x0ed0cabb)));
+ globalPersistent = createGlobalPersistent(0x0ed0cabb);
}
SafePointScope scope(ThreadState::NoHeapPointersOnStack);
Platform::current()->yieldCurrentThread();
@@ -538,6 +546,13 @@ protected:
SafePointScope scope(ThreadState::NoHeapPointersOnStack);
Platform::current()->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::detach();
atomicDecrement(&m_threadsToFinish);
}
« no previous file with comments | « no previous file | Source/platform/heap/PersistentNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698