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 4550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4561 destructorsCalledOnGC<HeapHashSet<RefPtr<RefCountedWithDestructor>>>(true); | 4561 destructorsCalledOnGC<HeapHashSet<RefPtr<RefCountedWithDestructor>>>(true); |
4562 destructorsCalledOnGC<HeapListHashSet<RefPtr<RefCountedWithDestructor>>>(tru
e); | 4562 destructorsCalledOnGC<HeapListHashSet<RefPtr<RefCountedWithDestructor>>>(tru
e); |
4563 destructorsCalledOnGC<HeapLinkedHashSet<RefPtr<RefCountedWithDestructor>>>(t
rue); | 4563 destructorsCalledOnGC<HeapLinkedHashSet<RefPtr<RefCountedWithDestructor>>>(t
rue); |
4564 } | 4564 } |
4565 | 4565 |
4566 class MixinA : public GarbageCollectedMixin { | 4566 class MixinA : public GarbageCollectedMixin { |
4567 public: | 4567 public: |
4568 MixinA() : m_obj(IntWrapper::create(100)) { } | 4568 MixinA() : m_obj(IntWrapper::create(100)) { } |
4569 DEFINE_INLINE_VIRTUAL_TRACE() | 4569 DEFINE_INLINE_VIRTUAL_TRACE() |
4570 { | 4570 { |
| 4571 s_traceCount++; |
4571 visitor->trace(m_obj); | 4572 visitor->trace(m_obj); |
4572 } | 4573 } |
| 4574 |
| 4575 static int s_traceCount; |
| 4576 |
4573 Member<IntWrapper> m_obj; | 4577 Member<IntWrapper> m_obj; |
4574 }; | 4578 }; |
4575 | 4579 |
| 4580 int MixinA::s_traceCount = 0; |
| 4581 |
4576 class MixinB : public GarbageCollectedMixin { | 4582 class MixinB : public GarbageCollectedMixin { |
4577 public: | 4583 public: |
4578 MixinB() : m_obj(IntWrapper::create(101)) { } | 4584 MixinB() : m_obj(IntWrapper::create(101)) { } |
4579 DEFINE_INLINE_VIRTUAL_TRACE() | 4585 DEFINE_INLINE_VIRTUAL_TRACE() |
4580 { | 4586 { |
4581 visitor->trace(m_obj); | 4587 visitor->trace(m_obj); |
4582 } | 4588 } |
4583 Member<IntWrapper> m_obj; | 4589 Member<IntWrapper> m_obj; |
4584 }; | 4590 }; |
4585 | 4591 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4656 { | 4662 { |
4657 Persistent<MixinB> b = obj; | 4663 Persistent<MixinB> b = obj; |
4658 preciselyCollectGarbage(); | 4664 preciselyCollectGarbage(); |
4659 EXPECT_EQ(0, IntWrapper::s_destructorCalls); | 4665 EXPECT_EQ(0, IntWrapper::s_destructorCalls); |
4660 EXPECT_EQ(2, DerivedMultipleMixins::s_traceCalled); | 4666 EXPECT_EQ(2, DerivedMultipleMixins::s_traceCalled); |
4661 } | 4667 } |
4662 preciselyCollectGarbage(); | 4668 preciselyCollectGarbage(); |
4663 EXPECT_EQ(4, IntWrapper::s_destructorCalls); | 4669 EXPECT_EQ(4, IntWrapper::s_destructorCalls); |
4664 } | 4670 } |
4665 | 4671 |
| 4672 class MixinInstanceWithoutTrace : public GarbageCollected<MixinInstanceWithoutTr
ace>, public MixinA { |
| 4673 USING_GARBAGE_COLLECTED_MIXIN(MixinInstanceWithoutTrace); |
| 4674 public: |
| 4675 MixinInstanceWithoutTrace() |
| 4676 { |
| 4677 } |
| 4678 }; |
| 4679 |
| 4680 TEST(HeapTest, MixinInstanceWithoutTrace) |
| 4681 { |
| 4682 // Verify that a mixin instance without any traceable |
| 4683 // references inherits the mixin's trace implementation. |
| 4684 clearOutOldGarbage(); |
| 4685 MixinA::s_traceCount = 0; |
| 4686 MixinInstanceWithoutTrace* obj = new MixinInstanceWithoutTrace(); |
| 4687 { |
| 4688 Persistent<MixinA> a = obj; |
| 4689 preciselyCollectGarbage(); |
| 4690 EXPECT_EQ(1, MixinA::s_traceCount); |
| 4691 } |
| 4692 { |
| 4693 Persistent<MixinInstanceWithoutTrace> b = obj; |
| 4694 preciselyCollectGarbage(); |
| 4695 EXPECT_EQ(2, MixinA::s_traceCount); |
| 4696 } |
| 4697 preciselyCollectGarbage(); |
| 4698 EXPECT_EQ(2, MixinA::s_traceCount); |
| 4699 } |
| 4700 |
4666 class GCParkingThreadTester { | 4701 class GCParkingThreadTester { |
4667 public: | 4702 public: |
4668 static void test() | 4703 static void test() |
4669 { | 4704 { |
4670 OwnPtr<WebThread> sleepingThread = adoptPtr(Platform::current()->createT
hread("SleepingThread")); | 4705 OwnPtr<WebThread> sleepingThread = adoptPtr(Platform::current()->createT
hread("SleepingThread")); |
4671 sleepingThread->taskRunner()->postTask(BLINK_FROM_HERE, new Task(threadS
afeBind(sleeperMainFunc))); | 4706 sleepingThread->taskRunner()->postTask(BLINK_FROM_HERE, new Task(threadS
afeBind(sleeperMainFunc))); |
4672 | 4707 |
4673 // Wait for the sleeper to run. | 4708 // Wait for the sleeper to run. |
4674 while (!s_sleeperRunning) { | 4709 while (!s_sleeperRunning) { |
4675 Platform::current()->yieldCurrentThread(); | 4710 Platform::current()->yieldCurrentThread(); |
(...skipping 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6490 EXPECT_EQ(1u, vector2.size()); | 6525 EXPECT_EQ(1u, vector2.size()); |
6491 // TODO(Oilpan): when Vector.h's contiguous container support no longer disables | 6526 // TODO(Oilpan): when Vector.h's contiguous container support no longer disables |
6492 // Vector<>s with inline capacity, remove. | 6527 // Vector<>s with inline capacity, remove. |
6493 #if !defined(ANNOTATE_CONTIGUOUS_CONTAINER) | 6528 #if !defined(ANNOTATE_CONTIGUOUS_CONTAINER) |
6494 EXPECT_EQ(16u, vector1.capacity()); | 6529 EXPECT_EQ(16u, vector1.capacity()); |
6495 EXPECT_EQ(16u, vector2.capacity()); | 6530 EXPECT_EQ(16u, vector2.capacity()); |
6496 #endif | 6531 #endif |
6497 } | 6532 } |
6498 | 6533 |
6499 } // namespace blink | 6534 } // namespace blink |
OLD | NEW |