| 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 2408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2419 memberPrimitive->insert(three, 4); | 2419 memberPrimitive->insert(three, 4); |
| 2420 memberPrimitive->insert(four, 1); | 2420 memberPrimitive->insert(four, 1); |
| 2421 set2->insert(one); | 2421 set2->insert(one); |
| 2422 set2->insert(two); | 2422 set2->insert(two); |
| 2423 set2->insert(three); | 2423 set2->insert(three); |
| 2424 set2->insert(four); | 2424 set2->insert(four); |
| 2425 set->insert(oneB); | 2425 set->insert(oneB); |
| 2426 set3->add(oneB); | 2426 set3->add(oneB); |
| 2427 set3->add(oneB); | 2427 set3->add(oneB); |
| 2428 vector->push_back(oneB); | 2428 vector->push_back(oneB); |
| 2429 deque->append(oneB); | 2429 deque->push_back(oneB); |
| 2430 vector2->push_back(threeB); | 2430 vector2->push_back(threeB); |
| 2431 vector2->push_back(fourB); | 2431 vector2->push_back(fourB); |
| 2432 deque2->append(threeE); | 2432 deque2->push_back(threeE); |
| 2433 deque2->append(fourE); | 2433 deque2->push_back(fourE); |
| 2434 vectorWU->push_back(PairWrappedUnwrapped(&*oneC, 42)); | 2434 vectorWU->push_back(PairWrappedUnwrapped(&*oneC, 42)); |
| 2435 dequeWU->append(PairWrappedUnwrapped(&*oneE, 42)); | 2435 dequeWU->push_back(PairWrappedUnwrapped(&*oneE, 42)); |
| 2436 vectorWU2->push_back(PairWrappedUnwrapped(&*threeC, 43)); | 2436 vectorWU2->push_back(PairWrappedUnwrapped(&*threeC, 43)); |
| 2437 vectorWU2->push_back(PairWrappedUnwrapped(&*fourC, 44)); | 2437 vectorWU2->push_back(PairWrappedUnwrapped(&*fourC, 44)); |
| 2438 vectorWU2->push_back(PairWrappedUnwrapped(&*fiveC, 45)); | 2438 vectorWU2->push_back(PairWrappedUnwrapped(&*fiveC, 45)); |
| 2439 dequeWU2->append(PairWrappedUnwrapped(&*threeE, 43)); | 2439 dequeWU2->push_back(PairWrappedUnwrapped(&*threeE, 43)); |
| 2440 dequeWU2->append(PairWrappedUnwrapped(&*fourE, 44)); | 2440 dequeWU2->push_back(PairWrappedUnwrapped(&*fourE, 44)); |
| 2441 dequeWU2->append(PairWrappedUnwrapped(&*fiveE, 45)); | 2441 dequeWU2->push_back(PairWrappedUnwrapped(&*fiveE, 45)); |
| 2442 vectorUW->push_back(PairUnwrappedWrapped(1, &*oneD)); | 2442 vectorUW->push_back(PairUnwrappedWrapped(1, &*oneD)); |
| 2443 vectorUW2->push_back(PairUnwrappedWrapped(103, &*threeD)); | 2443 vectorUW2->push_back(PairUnwrappedWrapped(103, &*threeD)); |
| 2444 vectorUW2->push_back(PairUnwrappedWrapped(104, &*fourD)); | 2444 vectorUW2->push_back(PairUnwrappedWrapped(104, &*fourD)); |
| 2445 vectorUW2->push_back(PairUnwrappedWrapped(105, &*fiveD)); | 2445 vectorUW2->push_back(PairUnwrappedWrapped(105, &*fiveD)); |
| 2446 dequeUW->append(PairUnwrappedWrapped(1, &*oneF)); | 2446 dequeUW->push_back(PairUnwrappedWrapped(1, &*oneF)); |
| 2447 dequeUW2->append(PairUnwrappedWrapped(103, &*threeF)); | 2447 dequeUW2->push_back(PairUnwrappedWrapped(103, &*threeF)); |
| 2448 dequeUW2->append(PairUnwrappedWrapped(104, &*fourF)); | 2448 dequeUW2->push_back(PairUnwrappedWrapped(104, &*fourF)); |
| 2449 dequeUW2->append(PairUnwrappedWrapped(105, &*fiveF)); | 2449 dequeUW2->push_back(PairUnwrappedWrapped(105, &*fiveF)); |
| 2450 | 2450 |
| 2451 EXPECT_TRUE(dequeContains(*deque, oneB)); | 2451 EXPECT_TRUE(dequeContains(*deque, oneB)); |
| 2452 | 2452 |
| 2453 // Collect garbage. This should change nothing since we are keeping | 2453 // Collect garbage. This should change nothing since we are keeping |
| 2454 // alive the IntWrapper objects with on-stack pointers. | 2454 // alive the IntWrapper objects with on-stack pointers. |
| 2455 conservativelyCollectGarbage(); | 2455 conservativelyCollectGarbage(); |
| 2456 | 2456 |
| 2457 EXPECT_TRUE(dequeContains(*deque, oneB)); | 2457 EXPECT_TRUE(dequeContains(*deque, oneB)); |
| 2458 | 2458 |
| 2459 EXPECT_EQ(0u, memberMember->size()); | 2459 EXPECT_EQ(0u, memberMember->size()); |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2865 EXPECT_TRUE(set2.contains(one2)); | 2865 EXPECT_TRUE(set2.contains(one2)); |
| 2866 } | 2866 } |
| 2867 } | 2867 } |
| 2868 | 2868 |
| 2869 class NonTrivialObject final { | 2869 class NonTrivialObject final { |
| 2870 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 2870 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 2871 | 2871 |
| 2872 public: | 2872 public: |
| 2873 NonTrivialObject() {} | 2873 NonTrivialObject() {} |
| 2874 explicit NonTrivialObject(int num) { | 2874 explicit NonTrivialObject(int num) { |
| 2875 m_deque.append(IntWrapper::create(num)); | 2875 m_deque.push_back(IntWrapper::create(num)); |
| 2876 m_vector.push_back(IntWrapper::create(num)); | 2876 m_vector.push_back(IntWrapper::create(num)); |
| 2877 } | 2877 } |
| 2878 DEFINE_INLINE_TRACE() { | 2878 DEFINE_INLINE_TRACE() { |
| 2879 visitor->trace(m_deque); | 2879 visitor->trace(m_deque); |
| 2880 visitor->trace(m_vector); | 2880 visitor->trace(m_vector); |
| 2881 } | 2881 } |
| 2882 | 2882 |
| 2883 private: | 2883 private: |
| 2884 HeapDeque<Member<IntWrapper>> m_deque; | 2884 HeapDeque<Member<IntWrapper>> m_deque; |
| 2885 HeapVector<Member<IntWrapper>> m_vector; | 2885 HeapVector<Member<IntWrapper>> m_vector; |
| (...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3847 IntWrapper* six(IntWrapper::create(6)); | 3847 IntWrapper* six(IntWrapper::create(6)); |
| 3848 IntWrapper* seven(IntWrapper::create(7)); | 3848 IntWrapper* seven(IntWrapper::create(7)); |
| 3849 IntWrapper* eight(IntWrapper::create(8)); | 3849 IntWrapper* eight(IntWrapper::create(8)); |
| 3850 IntWrapper* nine(IntWrapper::create(9)); | 3850 IntWrapper* nine(IntWrapper::create(9)); |
| 3851 Persistent<IntWrapper> ten(IntWrapper::create(10)); | 3851 Persistent<IntWrapper> ten(IntWrapper::create(10)); |
| 3852 IntWrapper* eleven(IntWrapper::create(11)); | 3852 IntWrapper* eleven(IntWrapper::create(11)); |
| 3853 | 3853 |
| 3854 pVec.push_back(one); | 3854 pVec.push_back(one); |
| 3855 pVec.push_back(two); | 3855 pVec.push_back(two); |
| 3856 | 3856 |
| 3857 pDeque.append(seven); | 3857 pDeque.push_back(seven); |
| 3858 pDeque.append(two); | 3858 pDeque.push_back(two); |
| 3859 | 3859 |
| 3860 Vec* vec = new Vec(); | 3860 Vec* vec = new Vec(); |
| 3861 vec->swap(pVec); | 3861 vec->swap(pVec); |
| 3862 | 3862 |
| 3863 pVec.push_back(two); | 3863 pVec.push_back(two); |
| 3864 pVec.push_back(three); | 3864 pVec.push_back(three); |
| 3865 | 3865 |
| 3866 pSet.insert(four); | 3866 pSet.insert(four); |
| 3867 pListSet.insert(eight); | 3867 pListSet.insert(eight); |
| 3868 pLinkedSet.insert(nine); | 3868 pLinkedSet.insert(nine); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3927 | 3927 |
| 3928 HeapHashMap<void*, IntVector>::iterator it = map->find(key); | 3928 HeapHashMap<void*, IntVector>::iterator it = map->find(key); |
| 3929 EXPECT_EQ(0u, map->at(key).size()); | 3929 EXPECT_EQ(0u, map->at(key).size()); |
| 3930 | 3930 |
| 3931 HeapHashMap<void*, IntDeque>::iterator it2 = map2->find(key); | 3931 HeapHashMap<void*, IntDeque>::iterator it2 = map2->find(key); |
| 3932 EXPECT_EQ(0u, map2->at(key).size()); | 3932 EXPECT_EQ(0u, map2->at(key).size()); |
| 3933 | 3933 |
| 3934 it->value.push_back(IntWrapper::create(42)); | 3934 it->value.push_back(IntWrapper::create(42)); |
| 3935 EXPECT_EQ(1u, map->at(key).size()); | 3935 EXPECT_EQ(1u, map->at(key).size()); |
| 3936 | 3936 |
| 3937 it2->value.append(IntWrapper::create(42)); | 3937 it2->value.push_back(IntWrapper::create(42)); |
| 3938 EXPECT_EQ(1u, map2->at(key).size()); | 3938 EXPECT_EQ(1u, map2->at(key).size()); |
| 3939 | 3939 |
| 3940 Persistent<HeapHashMap<void*, IntVector>> keepAlive(map); | 3940 Persistent<HeapHashMap<void*, IntVector>> keepAlive(map); |
| 3941 Persistent<HeapHashMap<void*, IntDeque>> keepAlive2(map2); | 3941 Persistent<HeapHashMap<void*, IntDeque>> keepAlive2(map2); |
| 3942 | 3942 |
| 3943 for (int i = 0; i < 100; i++) { | 3943 for (int i = 0; i < 100; i++) { |
| 3944 map->insert(key + 1 + i, IntVector()); | 3944 map->insert(key + 1 + i, IntVector()); |
| 3945 map2->insert(key + 1 + i, IntDeque()); | 3945 map2->insert(key + 1 + i, IntDeque()); |
| 3946 } | 3946 } |
| 3947 | 3947 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3998 | 3998 |
| 3999 TEST(HeapTest, CollectionNesting3) { | 3999 TEST(HeapTest, CollectionNesting3) { |
| 4000 clearOutOldGarbage(); | 4000 clearOutOldGarbage(); |
| 4001 IntWrapper::s_destructorCalls = 0; | 4001 IntWrapper::s_destructorCalls = 0; |
| 4002 typedef HeapVector<Member<IntWrapper>> IntVector; | 4002 typedef HeapVector<Member<IntWrapper>> IntVector; |
| 4003 typedef HeapDeque<Member<IntWrapper>> IntDeque; | 4003 typedef HeapDeque<Member<IntWrapper>> IntDeque; |
| 4004 HeapVector<IntVector>* vector = new HeapVector<IntVector>(); | 4004 HeapVector<IntVector>* vector = new HeapVector<IntVector>(); |
| 4005 HeapDeque<IntDeque>* deque = new HeapDeque<IntDeque>(); | 4005 HeapDeque<IntDeque>* deque = new HeapDeque<IntDeque>(); |
| 4006 | 4006 |
| 4007 vector->push_back(IntVector()); | 4007 vector->push_back(IntVector()); |
| 4008 deque->append(IntDeque()); | 4008 deque->push_back(IntDeque()); |
| 4009 | 4009 |
| 4010 HeapVector<IntVector>::iterator it = vector->begin(); | 4010 HeapVector<IntVector>::iterator it = vector->begin(); |
| 4011 HeapDeque<IntDeque>::iterator it2 = deque->begin(); | 4011 HeapDeque<IntDeque>::iterator it2 = deque->begin(); |
| 4012 EXPECT_EQ(0u, it->size()); | 4012 EXPECT_EQ(0u, it->size()); |
| 4013 EXPECT_EQ(0u, it2->size()); | 4013 EXPECT_EQ(0u, it2->size()); |
| 4014 | 4014 |
| 4015 it->push_back(IntWrapper::create(42)); | 4015 it->push_back(IntWrapper::create(42)); |
| 4016 it2->append(IntWrapper::create(42)); | 4016 it2->push_back(IntWrapper::create(42)); |
| 4017 EXPECT_EQ(1u, it->size()); | 4017 EXPECT_EQ(1u, it->size()); |
| 4018 EXPECT_EQ(1u, it2->size()); | 4018 EXPECT_EQ(1u, it2->size()); |
| 4019 | 4019 |
| 4020 Persistent<HeapVector<IntVector>> keepAlive(vector); | 4020 Persistent<HeapVector<IntVector>> keepAlive(vector); |
| 4021 Persistent<HeapDeque<IntDeque>> keepAlive2(deque); | 4021 Persistent<HeapDeque<IntDeque>> keepAlive2(deque); |
| 4022 preciselyCollectGarbage(); | 4022 preciselyCollectGarbage(); |
| 4023 EXPECT_EQ(1u, it->size()); | 4023 EXPECT_EQ(1u, it->size()); |
| 4024 EXPECT_EQ(1u, it2->size()); | 4024 EXPECT_EQ(1u, it2->size()); |
| 4025 EXPECT_EQ(0, IntWrapper::s_destructorCalls); | 4025 EXPECT_EQ(0, IntWrapper::s_destructorCalls); |
| 4026 } | 4026 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4051 EXPECT_EQ(6, SimpleFinalizedObject::s_destructorCalls); | 4051 EXPECT_EQ(6, SimpleFinalizedObject::s_destructorCalls); |
| 4052 } | 4052 } |
| 4053 | 4053 |
| 4054 TEST(HeapTest, EmbeddedInDeque) { | 4054 TEST(HeapTest, EmbeddedInDeque) { |
| 4055 clearOutOldGarbage(); | 4055 clearOutOldGarbage(); |
| 4056 SimpleFinalizedObject::s_destructorCalls = 0; | 4056 SimpleFinalizedObject::s_destructorCalls = 0; |
| 4057 { | 4057 { |
| 4058 PersistentHeapDeque<VectorObject, 2> inlineDeque; | 4058 PersistentHeapDeque<VectorObject, 2> inlineDeque; |
| 4059 PersistentHeapDeque<VectorObject> outlineDeque; | 4059 PersistentHeapDeque<VectorObject> outlineDeque; |
| 4060 VectorObject i1, i2; | 4060 VectorObject i1, i2; |
| 4061 inlineDeque.append(i1); | 4061 inlineDeque.push_back(i1); |
| 4062 inlineDeque.append(i2); | 4062 inlineDeque.push_back(i2); |
| 4063 | 4063 |
| 4064 VectorObject o1, o2; | 4064 VectorObject o1, o2; |
| 4065 outlineDeque.append(o1); | 4065 outlineDeque.push_back(o1); |
| 4066 outlineDeque.append(o2); | 4066 outlineDeque.push_back(o2); |
| 4067 | 4067 |
| 4068 PersistentHeapDeque<VectorObjectInheritedTrace> dequeInheritedTrace; | 4068 PersistentHeapDeque<VectorObjectInheritedTrace> dequeInheritedTrace; |
| 4069 VectorObjectInheritedTrace it1, it2; | 4069 VectorObjectInheritedTrace it1, it2; |
| 4070 dequeInheritedTrace.append(it1); | 4070 dequeInheritedTrace.push_back(it1); |
| 4071 dequeInheritedTrace.append(it2); | 4071 dequeInheritedTrace.push_back(it2); |
| 4072 | 4072 |
| 4073 preciselyCollectGarbage(); | 4073 preciselyCollectGarbage(); |
| 4074 EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls); | 4074 EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls); |
| 4075 } | 4075 } |
| 4076 preciselyCollectGarbage(); | 4076 preciselyCollectGarbage(); |
| 4077 EXPECT_EQ(6, SimpleFinalizedObject::s_destructorCalls); | 4077 EXPECT_EQ(6, SimpleFinalizedObject::s_destructorCalls); |
| 4078 } | 4078 } |
| 4079 | 4079 |
| 4080 class InlinedVectorObject { | 4080 class InlinedVectorObject { |
| 4081 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 4081 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| (...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5704 // Test expansion of a HeapDeque<>'s buffer. | 5704 // Test expansion of a HeapDeque<>'s buffer. |
| 5705 | 5705 |
| 5706 typedef HeapDeque<Member<IntWrapper>> IntDeque; | 5706 typedef HeapDeque<Member<IntWrapper>> IntDeque; |
| 5707 | 5707 |
| 5708 Persistent<IntDeque> deque = new IntDeque(); | 5708 Persistent<IntDeque> deque = new IntDeque(); |
| 5709 | 5709 |
| 5710 // Append a sequence, bringing about repeated expansions of the | 5710 // Append a sequence, bringing about repeated expansions of the |
| 5711 // deque's buffer. | 5711 // deque's buffer. |
| 5712 int i = 0; | 5712 int i = 0; |
| 5713 for (; i < 60; ++i) | 5713 for (; i < 60; ++i) |
| 5714 deque->append(IntWrapper::create(i)); | 5714 deque->push_back(IntWrapper::create(i)); |
| 5715 | 5715 |
| 5716 EXPECT_EQ(60u, deque->size()); | 5716 EXPECT_EQ(60u, deque->size()); |
| 5717 i = 0; | 5717 i = 0; |
| 5718 for (const auto& intWrapper : *deque) { | 5718 for (const auto& intWrapper : *deque) { |
| 5719 EXPECT_EQ(i, intWrapper->value()); | 5719 EXPECT_EQ(i, intWrapper->value()); |
| 5720 i++; | 5720 i++; |
| 5721 } | 5721 } |
| 5722 | 5722 |
| 5723 // Remove most of the queued objects and have the buffer's start index | 5723 // Remove most of the queued objects and have the buffer's start index |
| 5724 // 'point' somewhere into the buffer, just behind the end index. | 5724 // 'point' somewhere into the buffer, just behind the end index. |
| 5725 for (i = 0; i < 50; ++i) | 5725 for (i = 0; i < 50; ++i) |
| 5726 deque->takeFirst(); | 5726 deque->takeFirst(); |
| 5727 | 5727 |
| 5728 EXPECT_EQ(10u, deque->size()); | 5728 EXPECT_EQ(10u, deque->size()); |
| 5729 i = 0; | 5729 i = 0; |
| 5730 for (const auto& intWrapper : *deque) { | 5730 for (const auto& intWrapper : *deque) { |
| 5731 EXPECT_EQ(50 + i, intWrapper->value()); | 5731 EXPECT_EQ(50 + i, intWrapper->value()); |
| 5732 i++; | 5732 i++; |
| 5733 } | 5733 } |
| 5734 | 5734 |
| 5735 // Append even more, eventually causing an expansion of the underlying | 5735 // Append even more, eventually causing an expansion of the underlying |
| 5736 // buffer once the end index wraps around and reaches the start index. | 5736 // buffer once the end index wraps around and reaches the start index. |
| 5737 for (i = 0; i < 70; ++i) | 5737 for (i = 0; i < 70; ++i) |
| 5738 deque->append(IntWrapper::create(60 + i)); | 5738 deque->push_back(IntWrapper::create(60 + i)); |
| 5739 | 5739 |
| 5740 // Verify that the final buffer expansion copied the start and end segments | 5740 // Verify that the final buffer expansion copied the start and end segments |
| 5741 // of the old buffer to both ends of the expanded buffer, along with | 5741 // of the old buffer to both ends of the expanded buffer, along with |
| 5742 // re-adjusting both start&end indices in terms of that expanded buffer. | 5742 // re-adjusting both start&end indices in terms of that expanded buffer. |
| 5743 EXPECT_EQ(80u, deque->size()); | 5743 EXPECT_EQ(80u, deque->size()); |
| 5744 i = 0; | 5744 i = 0; |
| 5745 for (const auto& intWrapper : *deque) { | 5745 for (const auto& intWrapper : *deque) { |
| 5746 EXPECT_EQ(i + 50, intWrapper->value()); | 5746 EXPECT_EQ(i + 50, intWrapper->value()); |
| 5747 i++; | 5747 i++; |
| 5748 } | 5748 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5788 using PartDeque = HeapDeque<PartObjectWithRef>; | 5788 using PartDeque = HeapDeque<PartObjectWithRef>; |
| 5789 | 5789 |
| 5790 Persistent<PartDeque> deque = new PartDeque(); | 5790 Persistent<PartDeque> deque = new PartDeque(); |
| 5791 // Auxillary Deque used to prevent 'inline' buffer expansion. | 5791 // Auxillary Deque used to prevent 'inline' buffer expansion. |
| 5792 Persistent<PartDeque> dequeUnused = new PartDeque(); | 5792 Persistent<PartDeque> dequeUnused = new PartDeque(); |
| 5793 | 5793 |
| 5794 // Append a sequence, bringing about repeated expansions of the | 5794 // Append a sequence, bringing about repeated expansions of the |
| 5795 // deque's buffer. | 5795 // deque's buffer. |
| 5796 int i = 0; | 5796 int i = 0; |
| 5797 for (; i < 60; ++i) { | 5797 for (; i < 60; ++i) { |
| 5798 deque->append(PartObjectWithRef(i)); | 5798 deque->push_back(PartObjectWithRef(i)); |
| 5799 dequeUnused->append(PartObjectWithRef(i)); | 5799 dequeUnused->push_back(PartObjectWithRef(i)); |
| 5800 } | 5800 } |
| 5801 | 5801 |
| 5802 EXPECT_EQ(60u, deque->size()); | 5802 EXPECT_EQ(60u, deque->size()); |
| 5803 i = 0; | 5803 i = 0; |
| 5804 for (const PartObjectWithRef& part : *deque) { | 5804 for (const PartObjectWithRef& part : *deque) { |
| 5805 EXPECT_EQ(i, part.value()); | 5805 EXPECT_EQ(i, part.value()); |
| 5806 i++; | 5806 i++; |
| 5807 } | 5807 } |
| 5808 | 5808 |
| 5809 // Remove most of the queued objects and have the buffer's start index | 5809 // Remove most of the queued objects and have the buffer's start index |
| 5810 // 'point' somewhere into the buffer, just behind the end index. | 5810 // 'point' somewhere into the buffer, just behind the end index. |
| 5811 for (i = 0; i < 50; ++i) | 5811 for (i = 0; i < 50; ++i) |
| 5812 deque->takeFirst(); | 5812 deque->takeFirst(); |
| 5813 | 5813 |
| 5814 EXPECT_EQ(10u, deque->size()); | 5814 EXPECT_EQ(10u, deque->size()); |
| 5815 i = 0; | 5815 i = 0; |
| 5816 for (const PartObjectWithRef& part : *deque) { | 5816 for (const PartObjectWithRef& part : *deque) { |
| 5817 EXPECT_EQ(50 + i, part.value()); | 5817 EXPECT_EQ(50 + i, part.value()); |
| 5818 i++; | 5818 i++; |
| 5819 } | 5819 } |
| 5820 | 5820 |
| 5821 // Append even more, eventually causing an expansion of the underlying | 5821 // Append even more, eventually causing an expansion of the underlying |
| 5822 // buffer once the end index wraps around and reaches the start index. | 5822 // buffer once the end index wraps around and reaches the start index. |
| 5823 for (i = 0; i < 70; ++i) | 5823 for (i = 0; i < 70; ++i) |
| 5824 deque->append(PartObjectWithRef(60 + i)); | 5824 deque->push_back(PartObjectWithRef(60 + i)); |
| 5825 | 5825 |
| 5826 // Verify that the final buffer expansion copied the start and end segments | 5826 // Verify that the final buffer expansion copied the start and end segments |
| 5827 // of the old buffer to both ends of the expanded buffer, along with | 5827 // of the old buffer to both ends of the expanded buffer, along with |
| 5828 // re-adjusting both start&end indices in terms of that expanded buffer. | 5828 // re-adjusting both start&end indices in terms of that expanded buffer. |
| 5829 EXPECT_EQ(80u, deque->size()); | 5829 EXPECT_EQ(80u, deque->size()); |
| 5830 i = 0; | 5830 i = 0; |
| 5831 for (const PartObjectWithRef& part : *deque) { | 5831 for (const PartObjectWithRef& part : *deque) { |
| 5832 EXPECT_EQ(i + 50, part.value()); | 5832 EXPECT_EQ(i + 50, part.value()); |
| 5833 i++; | 5833 i++; |
| 5834 } | 5834 } |
| 5835 | 5835 |
| 5836 for (i = 0; i < 70; ++i) | 5836 for (i = 0; i < 70; ++i) |
| 5837 deque->append(PartObjectWithRef(130 + i)); | 5837 deque->push_back(PartObjectWithRef(130 + i)); |
| 5838 | 5838 |
| 5839 EXPECT_EQ(150u, deque->size()); | 5839 EXPECT_EQ(150u, deque->size()); |
| 5840 i = 0; | 5840 i = 0; |
| 5841 for (const PartObjectWithRef& part : *deque) { | 5841 for (const PartObjectWithRef& part : *deque) { |
| 5842 EXPECT_EQ(i + 50, part.value()); | 5842 EXPECT_EQ(i + 50, part.value()); |
| 5843 i++; | 5843 i++; |
| 5844 } | 5844 } |
| 5845 } | 5845 } |
| 5846 | 5846 |
| 5847 TEST(HeapTest, HeapVectorPartObjects) { | 5847 TEST(HeapTest, HeapVectorPartObjects) { |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6345 "HeapVector"); | 6345 "HeapVector"); |
| 6346 static_assert( | 6346 static_assert( |
| 6347 WTF::IsGarbageCollectedType<HeapDeque<Member<IntWrapper>>>::value, | 6347 WTF::IsGarbageCollectedType<HeapDeque<Member<IntWrapper>>>::value, |
| 6348 "HeapDeque"); | 6348 "HeapDeque"); |
| 6349 static_assert(WTF::IsGarbageCollectedType< | 6349 static_assert(WTF::IsGarbageCollectedType< |
| 6350 HeapTerminatedArray<Member<IntWrapper>>>::value, | 6350 HeapTerminatedArray<Member<IntWrapper>>>::value, |
| 6351 "HeapTerminatedArray"); | 6351 "HeapTerminatedArray"); |
| 6352 } | 6352 } |
| 6353 | 6353 |
| 6354 } // namespace blink | 6354 } // namespace blink |
| OLD | NEW |