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 4642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4653 | 4653 |
4654 // Nothing should have been collected/destructed. | 4654 // Nothing should have been collected/destructed. |
4655 EXPECT_EQ(0, CrossThreadObject::s_destructorCalls); | 4655 EXPECT_EQ(0, CrossThreadObject::s_destructorCalls); |
4656 EXPECT_EQ(0, IntWrapper::s_destructorCalls); | 4656 EXPECT_EQ(0, IntWrapper::s_destructorCalls); |
4657 | 4657 |
4658 // Put cto into a stack value. This is used to check that a conserva
tive | 4658 // Put cto into a stack value. This is used to check that a conserva
tive |
4659 // GC succeeds even though we are tracing the other thread heap afte
r | 4659 // GC succeeds even though we are tracing the other thread heap afte
r |
4660 // shutting it down. | 4660 // shutting it down. |
4661 stackPtrValue = reinterpret_cast<uintptr_t>(cto.get()); | 4661 stackPtrValue = reinterpret_cast<uintptr_t>(cto.get()); |
4662 } | 4662 } |
| 4663 RELEASE_ASSERT(stackPtrValue); |
| 4664 |
4663 // At this point it is "programatically" okay to shut down the worker th
read | 4665 // At this point it is "programatically" okay to shut down the worker th
read |
4664 // since the cto object should be dead. However out stackPtrValue will c
ause a | 4666 // since the cto object should be dead. However out stackPtrValue will c
ause a |
4665 // trace of the object when doing a conservative GC. | 4667 // trace of the object when doing a conservative GC. |
4666 // The worker thread's thread local GC's should just add the worker thre
ad's | 4668 // The worker thread's thread local GC's should just add the worker thre
ad's |
4667 // pages to the heap after finalizing IntWrapper. | 4669 // pages to the heap after finalizing IntWrapper. |
4668 wakeWorkerThread(); | 4670 wakeWorkerThread(); |
4669 | 4671 |
4670 // Wait for the worker to shutdown. | 4672 // Wait for the worker to shutdown. |
4671 parkMainThread(); | 4673 parkMainThread(); |
4672 | 4674 |
4673 // After the worker thread has detached it should have finalized the | 4675 // After the worker thread has detached it should have finalized the |
4674 // IntWrapper object on its heaps. Since there has been no global GC | 4676 // IntWrapper object on its heaps. Since there has been no global GC |
4675 // the cto object should not have been finalized. | 4677 // the cto object should not have been finalized. |
4676 EXPECT_EQ(0, CrossThreadObject::s_destructorCalls); | 4678 EXPECT_EQ(0, CrossThreadObject::s_destructorCalls); |
4677 EXPECT_EQ(1, IntWrapper::s_destructorCalls); | 4679 EXPECT_EQ(1, IntWrapper::s_destructorCalls); |
4678 | 4680 |
4679 // Now do a conservative GC. The stackPtrValue should keep cto alive | 4681 // Now do a conservative GC. The stackPtrValue should keep cto alive |
4680 // and will also cause the orphaned page of the other thread to be | 4682 // and will also cause the orphaned page of the other thread to be |
4681 // traced. At this point cto should still not be finalized. | 4683 // traced. At this point cto should still not be finalized. |
4682 Heap::collectGarbage(ThreadState::HeapPointersOnStack); | 4684 Heap::collectGarbage(ThreadState::HeapPointersOnStack); |
4683 EXPECT_EQ(0, CrossThreadObject::s_destructorCalls); | 4685 EXPECT_EQ(0, CrossThreadObject::s_destructorCalls); |
4684 EXPECT_EQ(1, IntWrapper::s_destructorCalls); | 4686 EXPECT_EQ(1, IntWrapper::s_destructorCalls); |
4685 | 4687 |
4686 // This release assert is here to ensure the stackValuePtr is not | |
4687 // optimized away before doing the above conservative GC. If the | |
4688 // EXPECT_EQ(0, CrossThreadObject::s_destructorCalls) call above | |
4689 // starts failing it means we have to find a better way to ensure | |
4690 // the stackPtrValue is not optimized away. | |
4691 RELEASE_ASSERT(stackPtrValue); | |
4692 | |
4693 // Do a GC with no pointers on the stack to see the cto being collected. | 4688 // Do a GC with no pointers on the stack to see the cto being collected. |
4694 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | 4689 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
4695 EXPECT_EQ(1, CrossThreadObject::s_destructorCalls); | 4690 EXPECT_EQ(1, CrossThreadObject::s_destructorCalls); |
4696 EXPECT_EQ(1, IntWrapper::s_destructorCalls); | 4691 EXPECT_EQ(1, IntWrapper::s_destructorCalls); |
4697 } | 4692 } |
4698 | 4693 |
4699 private: | 4694 private: |
4700 static void workerThreadMain(void* data) | 4695 static void workerThreadMain(void* data) |
4701 { | 4696 { |
4702 MutexLocker locker(workerThreadMutex()); | 4697 MutexLocker locker(workerThreadMutex()); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4871 // Regression test for out of bounds call through vtable. | 4866 // Regression test for out of bounds call through vtable. |
4872 // Passes if it doesn't crash. | 4867 // Passes if it doesn't crash. |
4873 TEST(HeapTest, GarbageCollectionDuringMixinConstruction) | 4868 TEST(HeapTest, GarbageCollectionDuringMixinConstruction) |
4874 { | 4869 { |
4875 ClassWithGarbageCollectingMixinConstructor* a = | 4870 ClassWithGarbageCollectingMixinConstructor* a = |
4876 new ClassWithGarbageCollectingMixinConstructor(); | 4871 new ClassWithGarbageCollectingMixinConstructor(); |
4877 a->verify(); | 4872 a->verify(); |
4878 } | 4873 } |
4879 | 4874 |
4880 } // WebCore namespace | 4875 } // WebCore namespace |
OLD | NEW |