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

Side by Side Diff: third_party/WebKit/Source/platform/heap/HeapTest.cpp

Issue 1925583003: Replace AllowCrossThreadAccess() + non-GCed pointers with crossThreadUnretained() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Kuroneko_4
Patch Set: Rebase. Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 int IntWrapper::s_destructorCalls = 0; 463 int IntWrapper::s_destructorCalls = 0;
464 int OffHeapInt::s_destructorCalls = 0; 464 int OffHeapInt::s_destructorCalls = 0;
465 465
466 class ThreadedTesterBase { 466 class ThreadedTesterBase {
467 protected: 467 protected:
468 static void test(ThreadedTesterBase* tester) 468 static void test(ThreadedTesterBase* tester)
469 { 469 {
470 Vector<std::unique_ptr<WebThread>, numberOfThreads> m_threads; 470 Vector<std::unique_ptr<WebThread>, numberOfThreads> m_threads;
471 for (int i = 0; i < numberOfThreads; i++) { 471 for (int i = 0; i < numberOfThreads; i++) {
472 m_threads.append(wrapUnique(Platform::current()->createThread("blink gc testing thread"))); 472 m_threads.append(wrapUnique(Platform::current()->createThread("blink gc testing thread")));
473 m_threads.last()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, thre adSafeBind(threadFunc, AllowCrossThreadAccess(tester))); 473 m_threads.last()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, thre adSafeBind(threadFunc, crossThreadUnretained(tester)));
474 } 474 }
475 while (tester->m_threadsToFinish) { 475 while (tester->m_threadsToFinish) {
476 SafePointScope scope(BlinkGC::NoHeapPointersOnStack); 476 SafePointScope scope(BlinkGC::NoHeapPointersOnStack);
477 testing::yieldCurrentThread(); 477 testing::yieldCurrentThread();
478 } 478 }
479 delete tester; 479 delete tester;
480 } 480 }
481 481
482 virtual void runThread() = 0; 482 virtual void runThread() = 0;
483 483
(...skipping 6190 matching lines...) Expand 10 before | Expand all | Expand 10 after
6674 // Create an object in the worker thread, have a CrossThreadWeakPersistent p ointing to it on the main thread, 6674 // Create an object in the worker thread, have a CrossThreadWeakPersistent p ointing to it on the main thread,
6675 // clear the reference in the worker thread, run a GC in the worker thread, and see if the 6675 // clear the reference in the worker thread, run a GC in the worker thread, and see if the
6676 // CrossThreadWeakPersistent is cleared. 6676 // CrossThreadWeakPersistent is cleared.
6677 6677
6678 DestructorLockingObject::s_destructorCalls = 0; 6678 DestructorLockingObject::s_destructorCalls = 0;
6679 6679
6680 // Step 1: Initiate a worker thread, and wait for |object| to get allocated on the worker thread. 6680 // Step 1: Initiate a worker thread, and wait for |object| to get allocated on the worker thread.
6681 MutexLocker mainThreadMutexLocker(mainThreadMutex()); 6681 MutexLocker mainThreadMutexLocker(mainThreadMutex());
6682 std::unique_ptr<WebThread> workerThread = wrapUnique(Platform::current()->cr eateThread("Test Worker Thread")); 6682 std::unique_ptr<WebThread> workerThread = wrapUnique(Platform::current()->cr eateThread("Test Worker Thread"));
6683 DestructorLockingObject* object = nullptr; 6683 DestructorLockingObject* object = nullptr;
6684 workerThread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(w orkerThreadMainForCrossThreadWeakPersistentTest, AllowCrossThreadAccess(&object) )); 6684 workerThread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(w orkerThreadMainForCrossThreadWeakPersistentTest, crossThreadUnretained(&object)) );
6685 parkMainThread(); 6685 parkMainThread();
6686 6686
6687 // Step 3: Set up a CrossThreadWeakPersistent. 6687 // Step 3: Set up a CrossThreadWeakPersistent.
6688 ASSERT_TRUE(object); 6688 ASSERT_TRUE(object);
6689 CrossThreadWeakPersistent<DestructorLockingObject> crossThreadWeakPersistent (object); 6689 CrossThreadWeakPersistent<DestructorLockingObject> crossThreadWeakPersistent (object);
6690 object = nullptr; 6690 object = nullptr;
6691 { 6691 {
6692 SafePointAwareMutexLocker recursiveMutexLocker(recursiveMutex()); 6692 SafePointAwareMutexLocker recursiveMutexLocker(recursiveMutex());
6693 EXPECT_EQ(0, DestructorLockingObject::s_destructorCalls); 6693 EXPECT_EQ(0, DestructorLockingObject::s_destructorCalls);
6694 } 6694 }
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
6943 static_assert(WTF::IsGarbageCollectedType<HeapLinkedHashSet<Member<IntWrappe r>>>::value, "HeapLinkedHashSet"); 6943 static_assert(WTF::IsGarbageCollectedType<HeapLinkedHashSet<Member<IntWrappe r>>>::value, "HeapLinkedHashSet");
6944 static_assert(WTF::IsGarbageCollectedType<HeapListHashSet<Member<IntWrapper> >>::value, "HeapListHashSet"); 6944 static_assert(WTF::IsGarbageCollectedType<HeapListHashSet<Member<IntWrapper> >>::value, "HeapListHashSet");
6945 static_assert(WTF::IsGarbageCollectedType<HeapHashCountedSet<Member<IntWrapp er>>>::value, "HeapHashCountedSet"); 6945 static_assert(WTF::IsGarbageCollectedType<HeapHashCountedSet<Member<IntWrapp er>>>::value, "HeapHashCountedSet");
6946 static_assert(WTF::IsGarbageCollectedType<HeapHashMap<int, Member<IntWrapper >>>::value, "HeapHashMap"); 6946 static_assert(WTF::IsGarbageCollectedType<HeapHashMap<int, Member<IntWrapper >>>::value, "HeapHashMap");
6947 static_assert(WTF::IsGarbageCollectedType<HeapVector<Member<IntWrapper>>>::v alue, "HeapVector"); 6947 static_assert(WTF::IsGarbageCollectedType<HeapVector<Member<IntWrapper>>>::v alue, "HeapVector");
6948 static_assert(WTF::IsGarbageCollectedType<HeapDeque<Member<IntWrapper>>>::va lue, "HeapDeque"); 6948 static_assert(WTF::IsGarbageCollectedType<HeapDeque<Member<IntWrapper>>>::va lue, "HeapDeque");
6949 static_assert(WTF::IsGarbageCollectedType<HeapTerminatedArray<Member<IntWrap per>>>::value, "HeapTerminatedArray"); 6949 static_assert(WTF::IsGarbageCollectedType<HeapTerminatedArray<Member<IntWrap per>>>::value, "HeapTerminatedArray");
6950 } 6950 }
6951 6951
6952 } // namespace blink 6952 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698