| 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);
|
| }
|
|
|