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 4578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4589 MultipleMixins() : m_obj(IntWrapper::create(102)) { } | 4589 MultipleMixins() : m_obj(IntWrapper::create(102)) { } |
4590 DEFINE_INLINE_VIRTUAL_TRACE() | 4590 DEFINE_INLINE_VIRTUAL_TRACE() |
4591 { | 4591 { |
4592 visitor->trace(m_obj); | 4592 visitor->trace(m_obj); |
4593 MixinA::trace(visitor); | 4593 MixinA::trace(visitor); |
4594 MixinB::trace(visitor); | 4594 MixinB::trace(visitor); |
4595 } | 4595 } |
4596 Member<IntWrapper> m_obj; | 4596 Member<IntWrapper> m_obj; |
4597 }; | 4597 }; |
4598 | 4598 |
| 4599 class DerivedMultipleMixins : public MultipleMixins { |
| 4600 public: |
| 4601 DerivedMultipleMixins() : m_obj(IntWrapper::create(103)) { } |
| 4602 |
| 4603 DEFINE_INLINE_VIRTUAL_TRACE() |
| 4604 { |
| 4605 s_traceCalled++; |
| 4606 visitor->trace(m_obj); |
| 4607 MultipleMixins::trace(visitor); |
| 4608 } |
| 4609 |
| 4610 static int s_traceCalled; |
| 4611 |
| 4612 private: |
| 4613 Member<IntWrapper> m_obj; |
| 4614 }; |
| 4615 |
| 4616 int DerivedMultipleMixins::s_traceCalled = 0; |
| 4617 |
4599 static const bool s_isMixinTrue = IsGarbageCollectedMixin<MultipleMixins>::value
; | 4618 static const bool s_isMixinTrue = IsGarbageCollectedMixin<MultipleMixins>::value
; |
4600 static const bool s_isMixinFalse = IsGarbageCollectedMixin<IntWrapper>::value; | 4619 static const bool s_isMixinFalse = IsGarbageCollectedMixin<IntWrapper>::value; |
4601 | 4620 |
4602 TEST(HeapTest, MultipleMixins) | 4621 TEST(HeapTest, MultipleMixins) |
4603 { | 4622 { |
4604 EXPECT_TRUE(s_isMixinTrue); | 4623 EXPECT_TRUE(s_isMixinTrue); |
4605 EXPECT_FALSE(s_isMixinFalse); | 4624 EXPECT_FALSE(s_isMixinFalse); |
4606 | 4625 |
4607 clearOutOldGarbage(); | 4626 clearOutOldGarbage(); |
4608 IntWrapper::s_destructorCalls = 0; | 4627 IntWrapper::s_destructorCalls = 0; |
4609 MultipleMixins* obj = new MultipleMixins(); | 4628 MultipleMixins* obj = new MultipleMixins(); |
4610 { | 4629 { |
4611 Persistent<MixinA> a = obj; | 4630 Persistent<MixinA> a = obj; |
4612 preciselyCollectGarbage(); | 4631 preciselyCollectGarbage(); |
4613 EXPECT_EQ(0, IntWrapper::s_destructorCalls); | 4632 EXPECT_EQ(0, IntWrapper::s_destructorCalls); |
4614 } | 4633 } |
4615 { | 4634 { |
4616 Persistent<MixinB> b = obj; | 4635 Persistent<MixinB> b = obj; |
4617 preciselyCollectGarbage(); | 4636 preciselyCollectGarbage(); |
4618 EXPECT_EQ(0, IntWrapper::s_destructorCalls); | 4637 EXPECT_EQ(0, IntWrapper::s_destructorCalls); |
4619 } | 4638 } |
4620 preciselyCollectGarbage(); | 4639 preciselyCollectGarbage(); |
4621 EXPECT_EQ(3, IntWrapper::s_destructorCalls); | 4640 EXPECT_EQ(3, IntWrapper::s_destructorCalls); |
4622 } | 4641 } |
4623 | 4642 |
| 4643 TEST(HeapTest, DerivedMultipleMixins) |
| 4644 { |
| 4645 clearOutOldGarbage(); |
| 4646 IntWrapper::s_destructorCalls = 0; |
| 4647 DerivedMultipleMixins::s_traceCalled = 0; |
| 4648 |
| 4649 DerivedMultipleMixins* obj = new DerivedMultipleMixins(); |
| 4650 { |
| 4651 Persistent<MixinA> a = obj; |
| 4652 preciselyCollectGarbage(); |
| 4653 EXPECT_EQ(0, IntWrapper::s_destructorCalls); |
| 4654 EXPECT_EQ(1, DerivedMultipleMixins::s_traceCalled); |
| 4655 } |
| 4656 { |
| 4657 Persistent<MixinB> b = obj; |
| 4658 preciselyCollectGarbage(); |
| 4659 EXPECT_EQ(0, IntWrapper::s_destructorCalls); |
| 4660 EXPECT_EQ(2, DerivedMultipleMixins::s_traceCalled); |
| 4661 } |
| 4662 preciselyCollectGarbage(); |
| 4663 EXPECT_EQ(4, IntWrapper::s_destructorCalls); |
| 4664 } |
| 4665 |
4624 class GCParkingThreadTester { | 4666 class GCParkingThreadTester { |
4625 public: | 4667 public: |
4626 static void test() | 4668 static void test() |
4627 { | 4669 { |
4628 OwnPtr<WebThread> sleepingThread = adoptPtr(Platform::current()->createT
hread("SleepingThread")); | 4670 OwnPtr<WebThread> sleepingThread = adoptPtr(Platform::current()->createT
hread("SleepingThread")); |
4629 sleepingThread->taskRunner()->postTask(BLINK_FROM_HERE, new Task(threadS
afeBind(sleeperMainFunc))); | 4671 sleepingThread->taskRunner()->postTask(BLINK_FROM_HERE, new Task(threadS
afeBind(sleeperMainFunc))); |
4630 | 4672 |
4631 // Wait for the sleeper to run. | 4673 // Wait for the sleeper to run. |
4632 while (!s_sleeperRunning) { | 4674 while (!s_sleeperRunning) { |
4633 Platform::current()->yieldCurrentThread(); | 4675 Platform::current()->yieldCurrentThread(); |
(...skipping 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6448 EXPECT_EQ(1u, vector2.size()); | 6490 EXPECT_EQ(1u, vector2.size()); |
6449 // TODO(Oilpan): when Vector.h's contiguous container support no longer disables | 6491 // TODO(Oilpan): when Vector.h's contiguous container support no longer disables |
6450 // Vector<>s with inline capacity, remove. | 6492 // Vector<>s with inline capacity, remove. |
6451 #if !defined(ANNOTATE_CONTIGUOUS_CONTAINER) | 6493 #if !defined(ANNOTATE_CONTIGUOUS_CONTAINER) |
6452 EXPECT_EQ(16u, vector1.capacity()); | 6494 EXPECT_EQ(16u, vector1.capacity()); |
6453 EXPECT_EQ(16u, vector2.capacity()); | 6495 EXPECT_EQ(16u, vector2.capacity()); |
6454 #endif | 6496 #endif |
6455 } | 6497 } |
6456 | 6498 |
6457 } // namespace blink | 6499 } // namespace blink |
OLD | NEW |