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 1999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2010 explicit ShouldBeTraced(IntWrapper* wrapper) : m_wrapper(wrapper) { } | 2010 explicit ShouldBeTraced(IntWrapper* wrapper) : m_wrapper(wrapper) { } |
2011 void trace(Visitor* visitor) { visitor->trace(m_wrapper); } | 2011 void trace(Visitor* visitor) { visitor->trace(m_wrapper); } |
2012 Member<IntWrapper> m_wrapper; | 2012 Member<IntWrapper> m_wrapper; |
2013 }; | 2013 }; |
2014 | 2014 |
2015 class OffHeapContainer : public GarbageCollectedFinalized<OffHeapContainer> { | 2015 class OffHeapContainer : public GarbageCollectedFinalized<OffHeapContainer> { |
2016 public: | 2016 public: |
2017 static OffHeapContainer* create() { return new OffHeapContainer(); } | 2017 static OffHeapContainer* create() { return new OffHeapContainer(); } |
2018 | 2018 |
2019 static const int iterations = 300; | 2019 static const int iterations = 300; |
2020 static const int deadWrappers = 1800; | 2020 static const int deadWrappers = 1500; |
2021 | 2021 |
2022 OffHeapContainer() | 2022 OffHeapContainer() |
2023 { | 2023 { |
2024 for (int i = 0; i < iterations; i++) { | 2024 for (int i = 0; i < iterations; i++) { |
2025 m_deque1.append(ShouldBeTraced(IntWrapper::create(i))); | 2025 m_deque1.append(ShouldBeTraced(IntWrapper::create(i))); |
2026 m_vector1.append(ShouldBeTraced(IntWrapper::create(i))); | 2026 m_vector1.append(ShouldBeTraced(IntWrapper::create(i))); |
2027 m_deque2.append(IntWrapper::create(i)); | 2027 m_deque2.append(IntWrapper::create(i)); |
2028 m_vector2.append(IntWrapper::create(i)); | 2028 m_vector2.append(IntWrapper::create(i)); |
2029 m_hashMap.add(i + 103, IntWrapper::create(i)); | |
2030 m_ownedVector.append(adoptPtr(new ShouldBeTraced(IntWrapper::create(
i)))); | 2029 m_ownedVector.append(adoptPtr(new ShouldBeTraced(IntWrapper::create(
i)))); |
2031 } | 2030 } |
2032 | 2031 |
2033 Deque<ShouldBeTraced>::iterator d1Iterator(m_deque1.begin()); | 2032 Deque<ShouldBeTraced>::iterator d1Iterator(m_deque1.begin()); |
2034 Vector<ShouldBeTraced>::iterator v1Iterator(m_vector1.begin()); | 2033 Vector<ShouldBeTraced>::iterator v1Iterator(m_vector1.begin()); |
2035 Deque<Member<IntWrapper> >::iterator d2Iterator(m_deque2.begin()); | 2034 Deque<Member<IntWrapper> >::iterator d2Iterator(m_deque2.begin()); |
2036 Vector<Member<IntWrapper> >::iterator v2Iterator(m_vector2.begin()); | 2035 Vector<Member<IntWrapper> >::iterator v2Iterator(m_vector2.begin()); |
2037 HashMap<int, Member<IntWrapper> >::iterator mapIterator(m_hashMap.begin(
)); | |
2038 Vector<OwnPtr<ShouldBeTraced> >::iterator ownedVectorIterator(m_ownedVec
tor.begin()); | 2036 Vector<OwnPtr<ShouldBeTraced> >::iterator ownedVectorIterator(m_ownedVec
tor.begin()); |
2039 | 2037 |
2040 for (int i = 0; i < iterations; i++) { | 2038 for (int i = 0; i < iterations; i++) { |
2041 EXPECT_EQ(i, m_vector1[i].m_wrapper->value()); | 2039 EXPECT_EQ(i, m_vector1[i].m_wrapper->value()); |
2042 EXPECT_EQ(i, m_vector2[i]->value()); | 2040 EXPECT_EQ(i, m_vector2[i]->value()); |
2043 EXPECT_EQ(i, d1Iterator->m_wrapper->value()); | 2041 EXPECT_EQ(i, d1Iterator->m_wrapper->value()); |
2044 EXPECT_EQ(i, v1Iterator->m_wrapper->value()); | 2042 EXPECT_EQ(i, v1Iterator->m_wrapper->value()); |
2045 EXPECT_EQ(i, d2Iterator->get()->value()); | 2043 EXPECT_EQ(i, d2Iterator->get()->value()); |
2046 EXPECT_EQ(i, v2Iterator->get()->value()); | 2044 EXPECT_EQ(i, v2Iterator->get()->value()); |
2047 EXPECT_EQ(i, ownedVectorIterator->get()->m_wrapper->value()); | 2045 EXPECT_EQ(i, ownedVectorIterator->get()->m_wrapper->value()); |
2048 int value = mapIterator->value.get()->value(); | |
2049 EXPECT_LE(0, value); | |
2050 EXPECT_GT(iterations, value); | |
2051 ++d1Iterator; | 2046 ++d1Iterator; |
2052 ++v1Iterator; | 2047 ++v1Iterator; |
2053 ++d2Iterator; | 2048 ++d2Iterator; |
2054 ++v2Iterator; | 2049 ++v2Iterator; |
2055 ++mapIterator; | |
2056 ++ownedVectorIterator; | 2050 ++ownedVectorIterator; |
2057 } | 2051 } |
2058 EXPECT_EQ(d1Iterator, m_deque1.end()); | 2052 EXPECT_EQ(d1Iterator, m_deque1.end()); |
2059 EXPECT_EQ(v1Iterator, m_vector1.end()); | 2053 EXPECT_EQ(v1Iterator, m_vector1.end()); |
2060 EXPECT_EQ(d2Iterator, m_deque2.end()); | 2054 EXPECT_EQ(d2Iterator, m_deque2.end()); |
2061 EXPECT_EQ(v2Iterator, m_vector2.end()); | 2055 EXPECT_EQ(v2Iterator, m_vector2.end()); |
2062 EXPECT_EQ(mapIterator, m_hashMap.end()); | |
2063 EXPECT_EQ(ownedVectorIterator, m_ownedVector.end()); | 2056 EXPECT_EQ(ownedVectorIterator, m_ownedVector.end()); |
2064 } | 2057 } |
2065 | 2058 |
2066 void trace(Visitor* visitor) | 2059 void trace(Visitor* visitor) |
2067 { | 2060 { |
2068 visitor->trace(m_deque1); | 2061 visitor->trace(m_deque1); |
2069 visitor->trace(m_vector1); | 2062 visitor->trace(m_vector1); |
2070 visitor->trace(m_deque2); | 2063 visitor->trace(m_deque2); |
2071 visitor->trace(m_vector2); | 2064 visitor->trace(m_vector2); |
2072 visitor->trace(m_hashMap); | |
2073 visitor->trace(m_ownedVector); | 2065 visitor->trace(m_ownedVector); |
2074 } | 2066 } |
2075 | 2067 |
2076 Deque<ShouldBeTraced> m_deque1; | 2068 Deque<ShouldBeTraced> m_deque1; |
2077 Vector<ShouldBeTraced> m_vector1; | 2069 Vector<ShouldBeTraced> m_vector1; |
2078 Deque<Member<IntWrapper> > m_deque2; | 2070 Deque<Member<IntWrapper> > m_deque2; |
2079 Vector<Member<IntWrapper> > m_vector2; | 2071 Vector<Member<IntWrapper> > m_vector2; |
2080 HashMap<int, Member<IntWrapper> > m_hashMap; | |
2081 Vector<OwnPtr<ShouldBeTraced> > m_ownedVector; | 2072 Vector<OwnPtr<ShouldBeTraced> > m_ownedVector; |
2082 }; | 2073 }; |
2083 | 2074 |
2084 const int OffHeapContainer::iterations; | 2075 const int OffHeapContainer::iterations; |
2085 const int OffHeapContainer::deadWrappers; | 2076 const int OffHeapContainer::deadWrappers; |
2086 | 2077 |
2087 // These class definitions test compile-time asserts with transition | 2078 // These class definitions test compile-time asserts with transition |
2088 // types. They are therefore unused in test code and just need to | 2079 // types. They are therefore unused in test code and just need to |
2089 // compile. This is intentional; do not delete the A and B classes below. | 2080 // compile. This is intentional; do not delete the A and B classes below. |
2090 class A : public WillBeGarbageCollectedMixin { | 2081 class A : public WillBeGarbageCollectedMixin { |
(...skipping 2784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4875 // Regression test for out of bounds call through vtable. | 4866 // Regression test for out of bounds call through vtable. |
4876 // Passes if it doesn't crash. | 4867 // Passes if it doesn't crash. |
4877 TEST(HeapTest, GarbageCollectionDuringMixinConstruction) | 4868 TEST(HeapTest, GarbageCollectionDuringMixinConstruction) |
4878 { | 4869 { |
4879 ClassWithGarbageCollectingMixinConstructor* a = | 4870 ClassWithGarbageCollectingMixinConstructor* a = |
4880 new ClassWithGarbageCollectingMixinConstructor(); | 4871 new ClassWithGarbageCollectingMixinConstructor(); |
4881 a->verify(); | 4872 a->verify(); |
4882 } | 4873 } |
4883 | 4874 |
4884 } // WebCore namespace | 4875 } // WebCore namespace |
OLD | NEW |