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 4654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4665 | 4665 |
4666 // Nothing should have been collected/destructed. | 4666 // Nothing should have been collected/destructed. |
4667 EXPECT_EQ(0, CrossThreadObject::s_destructorCalls); | 4667 EXPECT_EQ(0, CrossThreadObject::s_destructorCalls); |
4668 EXPECT_EQ(0, IntWrapper::s_destructorCalls); | 4668 EXPECT_EQ(0, IntWrapper::s_destructorCalls); |
4669 | 4669 |
4670 // Put cto into a stack value. This is used to check that a conserva
tive | 4670 // Put cto into a stack value. This is used to check that a conserva
tive |
4671 // GC succeeds even though we are tracing the other thread heap afte
r | 4671 // GC succeeds even though we are tracing the other thread heap afte
r |
4672 // shutting it down. | 4672 // shutting it down. |
4673 stackPtrValue = reinterpret_cast<uintptr_t>(cto.get()); | 4673 stackPtrValue = reinterpret_cast<uintptr_t>(cto.get()); |
4674 } | 4674 } |
4675 RELEASE_ASSERT(stackPtrValue); | |
4676 | |
4677 // At this point it is "programatically" okay to shut down the worker th
read | 4675 // At this point it is "programatically" okay to shut down the worker th
read |
4678 // since the cto object should be dead. However out stackPtrValue will c
ause a | 4676 // since the cto object should be dead. However out stackPtrValue will c
ause a |
4679 // trace of the object when doing a conservative GC. | 4677 // trace of the object when doing a conservative GC. |
4680 // The worker thread's thread local GC's should just add the worker thre
ad's | 4678 // The worker thread's thread local GC's should just add the worker thre
ad's |
4681 // pages to the heap after finalizing IntWrapper. | 4679 // pages to the heap after finalizing IntWrapper. |
4682 wakeWorkerThread(); | 4680 wakeWorkerThread(); |
4683 | 4681 |
4684 // Wait for the worker to shutdown. | 4682 // Wait for the worker to shutdown. |
4685 parkMainThread(); | 4683 parkMainThread(); |
4686 | 4684 |
4687 // After the worker thread has detached it should have finalized the | 4685 // After the worker thread has detached it should have finalized the |
4688 // IntWrapper object on its heaps. Since there has been no global GC | 4686 // IntWrapper object on its heaps. Since there has been no global GC |
4689 // the cto object should not have been finalized. | 4687 // the cto object should not have been finalized. |
4690 EXPECT_EQ(0, CrossThreadObject::s_destructorCalls); | 4688 EXPECT_EQ(0, CrossThreadObject::s_destructorCalls); |
4691 EXPECT_EQ(1, IntWrapper::s_destructorCalls); | 4689 EXPECT_EQ(1, IntWrapper::s_destructorCalls); |
4692 | 4690 |
4693 // Now do a conservative GC. The stackPtrValue should keep cto alive | 4691 // Now do a conservative GC. The stackPtrValue should keep cto alive |
4694 // and will also cause the orphaned page of the other thread to be | 4692 // and will also cause the orphaned page of the other thread to be |
4695 // traced. At this point cto should still not be finalized. | 4693 // traced. At this point cto should still not be finalized. |
4696 Heap::collectGarbage(ThreadState::HeapPointersOnStack); | 4694 Heap::collectGarbage(ThreadState::HeapPointersOnStack); |
4697 EXPECT_EQ(0, CrossThreadObject::s_destructorCalls); | 4695 EXPECT_EQ(0, CrossThreadObject::s_destructorCalls); |
4698 EXPECT_EQ(1, IntWrapper::s_destructorCalls); | 4696 EXPECT_EQ(1, IntWrapper::s_destructorCalls); |
4699 | 4697 |
| 4698 // This release assert is here to ensure the stackValuePtr is not |
| 4699 // optimized away before doing the above conservative GC. If the |
| 4700 // EXPECT_EQ(0, CrossThreadObject::s_destructorCalls) call above |
| 4701 // starts failing it means we have to find a better way to ensure |
| 4702 // the stackPtrValue is not optimized away. |
| 4703 RELEASE_ASSERT(stackPtrValue); |
| 4704 |
4700 // Do a GC with no pointers on the stack to see the cto being collected. | 4705 // Do a GC with no pointers on the stack to see the cto being collected. |
4701 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | 4706 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
4702 EXPECT_EQ(1, CrossThreadObject::s_destructorCalls); | 4707 EXPECT_EQ(1, CrossThreadObject::s_destructorCalls); |
4703 EXPECT_EQ(1, IntWrapper::s_destructorCalls); | 4708 EXPECT_EQ(1, IntWrapper::s_destructorCalls); |
4704 } | 4709 } |
4705 | 4710 |
4706 private: | 4711 private: |
4707 static void workerThreadMain(void* data) | 4712 static void workerThreadMain(void* data) |
4708 { | 4713 { |
4709 MutexLocker locker(workerThreadMutex()); | 4714 MutexLocker locker(workerThreadMutex()); |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5038 { | 5043 { |
5039 TraceIfNeededTester<HeapVector<Member<SimpleObject> > >* m_vec = TraceIf
NeededTester<HeapVector<Member<SimpleObject> > >::create(); | 5044 TraceIfNeededTester<HeapVector<Member<SimpleObject> > >* m_vec = TraceIf
NeededTester<HeapVector<Member<SimpleObject> > >::create(); |
5040 m_vec->obj().append(SimpleObject::create()); | 5045 m_vec->obj().append(SimpleObject::create()); |
5041 visitor.reset(); | 5046 visitor.reset(); |
5042 m_vec->trace(&visitor); | 5047 m_vec->trace(&visitor); |
5043 EXPECT_EQ(2u, visitor.count()); | 5048 EXPECT_EQ(2u, visitor.count()); |
5044 } | 5049 } |
5045 } | 5050 } |
5046 | 5051 |
5047 } // namespace blink | 5052 } // namespace blink |
OLD | NEW |