| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 { | 120 { |
| 121 return a == b; | 121 return a == b; |
| 122 } | 122 } |
| 123 | 123 |
| 124 static const bool safeToCompareToEmptyOrDeleted = false; | 124 static const bool safeToCompareToEmptyOrDeleted = false; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 typedef std::pair<Member<IntWrapper>, WeakMember<IntWrapper>> StrongWeakPair; | 127 typedef std::pair<Member<IntWrapper>, WeakMember<IntWrapper>> StrongWeakPair; |
| 128 | 128 |
| 129 struct PairWithWeakHandling : public StrongWeakPair { | 129 struct PairWithWeakHandling : public StrongWeakPair { |
| 130 ALLOW_ONLY_INLINE_ALLOCATION(); | 130 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 131 | 131 |
| 132 public: | 132 public: |
| 133 // Regular constructor. | 133 // Regular constructor. |
| 134 PairWithWeakHandling(IntWrapper* one, IntWrapper* two) | 134 PairWithWeakHandling(IntWrapper* one, IntWrapper* two) |
| 135 : StrongWeakPair(one, two) | 135 : StrongWeakPair(one, two) |
| 136 { | 136 { |
| 137 ASSERT(one); // We use null first field to indicate empty slots in the h
ash table. | 137 ASSERT(one); // We use null first field to indicate empty slots in the h
ash table. |
| 138 } | 138 } |
| 139 | 139 |
| 140 // The HashTable (via the HashTrait) calls this constructor with a | 140 // The HashTable (via the HashTrait) calls this constructor with a |
| (...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1539 private: | 1539 private: |
| 1540 UseMixin() | 1540 UseMixin() |
| 1541 { | 1541 { |
| 1542 s_traceCount = 0; | 1542 s_traceCount = 0; |
| 1543 } | 1543 } |
| 1544 }; | 1544 }; |
| 1545 | 1545 |
| 1546 int UseMixin::s_traceCount = 0; | 1546 int UseMixin::s_traceCount = 0; |
| 1547 | 1547 |
| 1548 class VectorObject { | 1548 class VectorObject { |
| 1549 ALLOW_ONLY_INLINE_ALLOCATION(); | 1549 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 1550 public: | 1550 public: |
| 1551 VectorObject() | 1551 VectorObject() |
| 1552 { | 1552 { |
| 1553 m_value = SimpleFinalizedObject::create(); | 1553 m_value = SimpleFinalizedObject::create(); |
| 1554 } | 1554 } |
| 1555 | 1555 |
| 1556 DEFINE_INLINE_TRACE() | 1556 DEFINE_INLINE_TRACE() |
| 1557 { | 1557 { |
| 1558 visitor->trace(m_value); | 1558 visitor->trace(m_value); |
| 1559 } | 1559 } |
| 1560 | 1560 |
| 1561 private: | 1561 private: |
| 1562 Member<SimpleFinalizedObject> m_value; | 1562 Member<SimpleFinalizedObject> m_value; |
| 1563 }; | 1563 }; |
| 1564 | 1564 |
| 1565 class VectorObjectInheritedTrace : public VectorObject { }; | 1565 class VectorObjectInheritedTrace : public VectorObject { }; |
| 1566 | 1566 |
| 1567 class VectorObjectNoTrace { | 1567 class VectorObjectNoTrace { |
| 1568 ALLOW_ONLY_INLINE_ALLOCATION(); | 1568 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 1569 public: | 1569 public: |
| 1570 VectorObjectNoTrace() | 1570 VectorObjectNoTrace() |
| 1571 { | 1571 { |
| 1572 m_value = SimpleFinalizedObject::create(); | 1572 m_value = SimpleFinalizedObject::create(); |
| 1573 } | 1573 } |
| 1574 | 1574 |
| 1575 private: | 1575 private: |
| 1576 Member<SimpleFinalizedObject> m_value; | 1576 Member<SimpleFinalizedObject> m_value; |
| 1577 }; | 1577 }; |
| 1578 | 1578 |
| 1579 class TerminatedArrayItem { | 1579 class TerminatedArrayItem { |
| 1580 ALLOW_ONLY_INLINE_ALLOCATION(); | 1580 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 1581 public: | 1581 public: |
| 1582 TerminatedArrayItem(IntWrapper* payload) : m_payload(payload), m_isLast(fals
e) { } | 1582 TerminatedArrayItem(IntWrapper* payload) : m_payload(payload), m_isLast(fals
e) { } |
| 1583 | 1583 |
| 1584 DEFINE_INLINE_TRACE() { visitor->trace(m_payload); } | 1584 DEFINE_INLINE_TRACE() { visitor->trace(m_payload); } |
| 1585 | 1585 |
| 1586 bool isLastInArray() const { return m_isLast; } | 1586 bool isLastInArray() const { return m_isLast; } |
| 1587 void setLastInArray(bool value) { m_isLast = value; } | 1587 void setLastInArray(bool value) { m_isLast = value; } |
| 1588 | 1588 |
| 1589 IntWrapper* payload() const { return m_payload; } | 1589 IntWrapper* payload() const { return m_payload; } |
| 1590 | 1590 |
| (...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2851 EXPECT_EQ(1u, vectorUW2->size()); | 2851 EXPECT_EQ(1u, vectorUW2->size()); |
| 2852 EXPECT_EQ(2u, deque->size()); | 2852 EXPECT_EQ(2u, deque->size()); |
| 2853 EXPECT_EQ(1u, deque2->size()); | 2853 EXPECT_EQ(1u, deque2->size()); |
| 2854 EXPECT_EQ(3u, dequeWU->size()); | 2854 EXPECT_EQ(3u, dequeWU->size()); |
| 2855 EXPECT_EQ(1u, dequeWU2->size()); | 2855 EXPECT_EQ(1u, dequeWU2->size()); |
| 2856 EXPECT_EQ(3u, dequeUW->size()); | 2856 EXPECT_EQ(3u, dequeUW->size()); |
| 2857 EXPECT_EQ(1u, dequeUW2->size()); | 2857 EXPECT_EQ(1u, dequeUW2->size()); |
| 2858 } | 2858 } |
| 2859 | 2859 |
| 2860 class NonTrivialObject final { | 2860 class NonTrivialObject final { |
| 2861 ALLOW_ONLY_INLINE_ALLOCATION(); | 2861 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 2862 public: | 2862 public: |
| 2863 NonTrivialObject() | 2863 NonTrivialObject() |
| 2864 { | 2864 { |
| 2865 } | 2865 } |
| 2866 explicit NonTrivialObject(int num) | 2866 explicit NonTrivialObject(int num) |
| 2867 { | 2867 { |
| 2868 m_deque.append(IntWrapper::create(num)); | 2868 m_deque.append(IntWrapper::create(num)); |
| 2869 m_vector.append(IntWrapper::create(num)); | 2869 m_vector.append(IntWrapper::create(num)); |
| 2870 } | 2870 } |
| 2871 DEFINE_INLINE_TRACE() | 2871 DEFINE_INLINE_TRACE() |
| (...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4116 dequeNoTrace.append(n1); | 4116 dequeNoTrace.append(n1); |
| 4117 dequeNoTrace.append(n2); | 4117 dequeNoTrace.append(n2); |
| 4118 preciselyCollectGarbage(); | 4118 preciselyCollectGarbage(); |
| 4119 EXPECT_EQ(2, SimpleFinalizedObject::s_destructorCalls); | 4119 EXPECT_EQ(2, SimpleFinalizedObject::s_destructorCalls); |
| 4120 } | 4120 } |
| 4121 preciselyCollectGarbage(); | 4121 preciselyCollectGarbage(); |
| 4122 EXPECT_EQ(8, SimpleFinalizedObject::s_destructorCalls); | 4122 EXPECT_EQ(8, SimpleFinalizedObject::s_destructorCalls); |
| 4123 } | 4123 } |
| 4124 | 4124 |
| 4125 class InlinedVectorObject { | 4125 class InlinedVectorObject { |
| 4126 ALLOW_ONLY_INLINE_ALLOCATION(); | 4126 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 4127 public: | 4127 public: |
| 4128 InlinedVectorObject() | 4128 InlinedVectorObject() |
| 4129 { | 4129 { |
| 4130 } | 4130 } |
| 4131 ~InlinedVectorObject() | 4131 ~InlinedVectorObject() |
| 4132 { | 4132 { |
| 4133 s_destructorCalls++; | 4133 s_destructorCalls++; |
| 4134 } | 4134 } |
| 4135 DEFINE_INLINE_TRACE() | 4135 DEFINE_INLINE_TRACE() |
| 4136 { | 4136 { |
| 4137 } | 4137 } |
| 4138 | 4138 |
| 4139 static int s_destructorCalls; | 4139 static int s_destructorCalls; |
| 4140 }; | 4140 }; |
| 4141 | 4141 |
| 4142 int InlinedVectorObject::s_destructorCalls = 0; | 4142 int InlinedVectorObject::s_destructorCalls = 0; |
| 4143 | 4143 |
| 4144 class InlinedVectorObjectWithVtable { | 4144 class InlinedVectorObjectWithVtable { |
| 4145 ALLOW_ONLY_INLINE_ALLOCATION(); | 4145 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 4146 public: | 4146 public: |
| 4147 InlinedVectorObjectWithVtable() | 4147 InlinedVectorObjectWithVtable() |
| 4148 { | 4148 { |
| 4149 } | 4149 } |
| 4150 ~InlinedVectorObjectWithVtable() | 4150 ~InlinedVectorObjectWithVtable() |
| 4151 { | 4151 { |
| 4152 s_destructorCalls++; | 4152 s_destructorCalls++; |
| 4153 } | 4153 } |
| 4154 virtual void virtualMethod() { } | 4154 virtual void virtualMethod() { } |
| 4155 DEFINE_INLINE_TRACE() | 4155 DEFINE_INLINE_TRACE() |
| (...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5727 DEFINE_INLINE_TRACE() { TraceIfNeeded<T>::trace(visitor, m_obj); } | 5727 DEFINE_INLINE_TRACE() { TraceIfNeeded<T>::trace(visitor, m_obj); } |
| 5728 T& obj() { return m_obj; } | 5728 T& obj() { return m_obj; } |
| 5729 ~TraceIfNeededTester() { } | 5729 ~TraceIfNeededTester() { } |
| 5730 private: | 5730 private: |
| 5731 TraceIfNeededTester() { } | 5731 TraceIfNeededTester() { } |
| 5732 explicit TraceIfNeededTester(const T& obj) : m_obj(obj) { } | 5732 explicit TraceIfNeededTester(const T& obj) : m_obj(obj) { } |
| 5733 T m_obj; | 5733 T m_obj; |
| 5734 }; | 5734 }; |
| 5735 | 5735 |
| 5736 class PartObject { | 5736 class PartObject { |
| 5737 DISALLOW_ALLOCATION(); | 5737 DISALLOW_NEW(); |
| 5738 public: | 5738 public: |
| 5739 PartObject() : m_obj(SimpleObject::create()) { } | 5739 PartObject() : m_obj(SimpleObject::create()) { } |
| 5740 DEFINE_INLINE_TRACE() { visitor->trace(m_obj); } | 5740 DEFINE_INLINE_TRACE() { visitor->trace(m_obj); } |
| 5741 private: | 5741 private: |
| 5742 Member<SimpleObject> m_obj; | 5742 Member<SimpleObject> m_obj; |
| 5743 }; | 5743 }; |
| 5744 | 5744 |
| 5745 TEST(HeapTest, TraceIfNeeded) | 5745 TEST(HeapTest, TraceIfNeeded) |
| 5746 { | 5746 { |
| 5747 CountingVisitor visitor; | 5747 CountingVisitor visitor; |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6077 private: | 6077 private: |
| 6078 explicit SimpleRefValue(int value) | 6078 explicit SimpleRefValue(int value) |
| 6079 : m_value(value) | 6079 : m_value(value) |
| 6080 { | 6080 { |
| 6081 } | 6081 } |
| 6082 | 6082 |
| 6083 int m_value; | 6083 int m_value; |
| 6084 }; | 6084 }; |
| 6085 | 6085 |
| 6086 class PartObjectWithRef { | 6086 class PartObjectWithRef { |
| 6087 ALLOW_ONLY_INLINE_ALLOCATION(); | 6087 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 6088 public: | 6088 public: |
| 6089 PartObjectWithRef(int i) | 6089 PartObjectWithRef(int i) |
| 6090 : m_value(SimpleRefValue::create(i)) | 6090 : m_value(SimpleRefValue::create(i)) |
| 6091 { | 6091 { |
| 6092 } | 6092 } |
| 6093 | 6093 |
| 6094 int value() const { return m_value->value(); } | 6094 int value() const { return m_value->value(); } |
| 6095 | 6095 |
| 6096 private: | 6096 private: |
| 6097 RefPtr<SimpleRefValue> m_value; | 6097 RefPtr<SimpleRefValue> m_value; |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6449 EXPECT_EQ(1u, vector2.size()); | 6449 EXPECT_EQ(1u, vector2.size()); |
| 6450 // TODO(Oilpan): when Vector.h's contiguous container support no longer disables | 6450 // TODO(Oilpan): when Vector.h's contiguous container support no longer disables |
| 6451 // Vector<>s with inline capacity, remove. | 6451 // Vector<>s with inline capacity, remove. |
| 6452 #if !defined(ANNOTATE_CONTIGUOUS_CONTAINER) | 6452 #if !defined(ANNOTATE_CONTIGUOUS_CONTAINER) |
| 6453 EXPECT_EQ(16u, vector1.capacity()); | 6453 EXPECT_EQ(16u, vector1.capacity()); |
| 6454 EXPECT_EQ(16u, vector2.capacity()); | 6454 EXPECT_EQ(16u, vector2.capacity()); |
| 6455 #endif | 6455 #endif |
| 6456 } | 6456 } |
| 6457 | 6457 |
| 6458 } // namespace blink | 6458 } // namespace blink |
| OLD | NEW |