| OLD | NEW |
| 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 5351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5362 // Setting an object created on the worker thread to a Member allocated on | 5362 // Setting an object created on the worker thread to a Member allocated on |
| 5363 // the main thread is not allowed. | 5363 // the main thread is not allowed. |
| 5364 m_wrapper = IntWrapper::create(42); | 5364 m_wrapper = IntWrapper::create(42); |
| 5365 | 5365 |
| 5366 wakeMainThread(); | 5366 wakeMainThread(); |
| 5367 ThreadState::detachCurrentThread(); | 5367 ThreadState::detachCurrentThread(); |
| 5368 } | 5368 } |
| 5369 }; | 5369 }; |
| 5370 | 5370 |
| 5371 #if DCHECK_IS_ON() | 5371 #if DCHECK_IS_ON() |
| 5372 TEST(HeapTest, MemberSameThreadCheck) { | 5372 TEST(HeapDeathTest, MemberSameThreadCheck) { |
| 5373 EXPECT_DEATH(MemberSameThreadCheckTester().test(), ""); | 5373 EXPECT_DEATH(MemberSameThreadCheckTester().test(), ""); |
| 5374 } | 5374 } |
| 5375 #endif | 5375 #endif |
| 5376 | 5376 |
| 5377 class PersistentSameThreadCheckTester { | 5377 class PersistentSameThreadCheckTester { |
| 5378 public: | 5378 public: |
| 5379 void test() { | 5379 void test() { |
| 5380 IntWrapper::s_destructorCalls = 0; | 5380 IntWrapper::s_destructorCalls = 0; |
| 5381 | 5381 |
| 5382 MutexLocker locker(mainThreadMutex()); | 5382 MutexLocker locker(mainThreadMutex()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 5401 // Setting an object created on the worker thread to a Persistent allocated | 5401 // Setting an object created on the worker thread to a Persistent allocated |
| 5402 // on the main thread is not allowed. | 5402 // on the main thread is not allowed. |
| 5403 m_wrapper = IntWrapper::create(42); | 5403 m_wrapper = IntWrapper::create(42); |
| 5404 | 5404 |
| 5405 wakeMainThread(); | 5405 wakeMainThread(); |
| 5406 ThreadState::detachCurrentThread(); | 5406 ThreadState::detachCurrentThread(); |
| 5407 } | 5407 } |
| 5408 }; | 5408 }; |
| 5409 | 5409 |
| 5410 #if DCHECK_IS_ON() | 5410 #if DCHECK_IS_ON() |
| 5411 TEST(HeapTest, PersistentSameThreadCheck) { | 5411 TEST(HeapDeathTest, PersistentSameThreadCheck) { |
| 5412 EXPECT_DEATH(PersistentSameThreadCheckTester().test(), ""); | 5412 EXPECT_DEATH(PersistentSameThreadCheckTester().test(), ""); |
| 5413 } | 5413 } |
| 5414 #endif | 5414 #endif |
| 5415 | 5415 |
| 5416 class MarkingSameThreadCheckTester { | 5416 class MarkingSameThreadCheckTester { |
| 5417 public: | 5417 public: |
| 5418 void test() { | 5418 void test() { |
| 5419 IntWrapper::s_destructorCalls = 0; | 5419 IntWrapper::s_destructorCalls = 0; |
| 5420 | 5420 |
| 5421 MutexLocker locker(mainThreadMutex()); | 5421 MutexLocker locker(mainThreadMutex()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 5451 // Adding a reference to an object created on the worker thread to a | 5451 // Adding a reference to an object created on the worker thread to a |
| 5452 // HeapHashMap created on the main thread is not allowed. | 5452 // HeapHashMap created on the main thread is not allowed. |
| 5453 mainThreadObject->addToSet(IntWrapper::create(42)); | 5453 mainThreadObject->addToSet(IntWrapper::create(42)); |
| 5454 | 5454 |
| 5455 wakeMainThread(); | 5455 wakeMainThread(); |
| 5456 ThreadState::detachCurrentThread(); | 5456 ThreadState::detachCurrentThread(); |
| 5457 } | 5457 } |
| 5458 }; | 5458 }; |
| 5459 | 5459 |
| 5460 #if DCHECK_IS_ON() | 5460 #if DCHECK_IS_ON() |
| 5461 TEST(HeapTest, MarkingSameThreadCheck) { | 5461 TEST(HeapDeathTest, MarkingSameThreadCheck) { |
| 5462 // This will crash during marking, at the DCHECK in Visitor::markHeader() or | 5462 // This will crash during marking, at the DCHECK in Visitor::markHeader() or |
| 5463 // earlier. | 5463 // earlier. |
| 5464 EXPECT_DEATH(MarkingSameThreadCheckTester().test(), ""); | 5464 EXPECT_DEATH(MarkingSameThreadCheckTester().test(), ""); |
| 5465 } | 5465 } |
| 5466 #endif | 5466 #endif |
| 5467 | 5467 |
| 5468 static bool allocateAndReturnBool() { | 5468 static bool allocateAndReturnBool() { |
| 5469 conservativelyCollectGarbage(); | 5469 conservativelyCollectGarbage(); |
| 5470 return true; | 5470 return true; |
| 5471 } | 5471 } |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6475 "HeapVector"); | 6475 "HeapVector"); |
| 6476 static_assert( | 6476 static_assert( |
| 6477 WTF::IsGarbageCollectedType<HeapDeque<Member<IntWrapper>>>::value, | 6477 WTF::IsGarbageCollectedType<HeapDeque<Member<IntWrapper>>>::value, |
| 6478 "HeapDeque"); | 6478 "HeapDeque"); |
| 6479 static_assert(WTF::IsGarbageCollectedType< | 6479 static_assert(WTF::IsGarbageCollectedType< |
| 6480 HeapTerminatedArray<Member<IntWrapper>>>::value, | 6480 HeapTerminatedArray<Member<IntWrapper>>>::value, |
| 6481 "HeapTerminatedArray"); | 6481 "HeapTerminatedArray"); |
| 6482 } | 6482 } |
| 6483 | 6483 |
| 6484 } // namespace blink | 6484 } // namespace blink |
| OLD | NEW |