OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits> | 5 #include <limits> |
6 | 6 |
7 #include "src/globals.h" | 7 #include "src/globals.h" |
8 #include "src/heap/slot-set.h" | 8 #include "src/heap/slot-set.h" |
9 #include "src/heap/spaces.h" | 9 #include "src/heap/spaces.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 97 } |
98 | 98 |
99 void CheckRemoveRangeOn(uint32_t start, uint32_t end) { | 99 void CheckRemoveRangeOn(uint32_t start, uint32_t end) { |
100 SlotSet set; | 100 SlotSet set; |
101 set.SetPageStart(0); | 101 set.SetPageStart(0); |
102 uint32_t first = start == 0 ? 0 : start - kPointerSize; | 102 uint32_t first = start == 0 ? 0 : start - kPointerSize; |
103 uint32_t last = end == Page::kPageSize ? end - kPointerSize : end; | 103 uint32_t last = end == Page::kPageSize ? end - kPointerSize : end; |
104 for (uint32_t i = first; i <= last; i += kPointerSize) { | 104 for (uint32_t i = first; i <= last; i += kPointerSize) { |
105 set.Insert(i); | 105 set.Insert(i); |
106 } | 106 } |
107 set.RemoveRange(start, end); | 107 set.RemoveRange(start, end, SlotSet::FREE_EMPTY_BUCKETS); |
108 if (first != start) { | 108 if (first != start) { |
109 EXPECT_TRUE(set.Lookup(first)); | 109 EXPECT_TRUE(set.Lookup(first)); |
110 } | 110 } |
111 if (last == end) { | 111 if (last == end) { |
112 EXPECT_TRUE(set.Lookup(last)); | 112 EXPECT_TRUE(set.Lookup(last)); |
113 } | 113 } |
114 for (uint32_t i = start; i < end; i += kPointerSize) { | 114 for (uint32_t i = start; i < end; i += kPointerSize) { |
115 EXPECT_FALSE(set.Lookup(i)); | 115 EXPECT_FALSE(set.Lookup(i)); |
116 } | 116 } |
117 } | 117 } |
(...skipping 10 matching lines...) Expand all Loading... |
128 uint32_t end = (kEnds[i] + k); | 128 uint32_t end = (kEnds[i] + k); |
129 if (start < end) { | 129 if (start < end) { |
130 CheckRemoveRangeOn(start * kPointerSize, end * kPointerSize); | 130 CheckRemoveRangeOn(start * kPointerSize, end * kPointerSize); |
131 } | 131 } |
132 } | 132 } |
133 } | 133 } |
134 } | 134 } |
135 SlotSet set; | 135 SlotSet set; |
136 set.SetPageStart(0); | 136 set.SetPageStart(0); |
137 set.Insert(Page::kPageSize / 2); | 137 set.Insert(Page::kPageSize / 2); |
138 set.RemoveRange(0, Page::kPageSize); | 138 set.RemoveRange(0, Page::kPageSize, SlotSet::FREE_EMPTY_BUCKETS); |
139 for (uint32_t i = 0; i < Page::kPageSize; i += kPointerSize) { | 139 for (uint32_t i = 0; i < Page::kPageSize; i += kPointerSize) { |
140 EXPECT_FALSE(set.Lookup(i)); | 140 EXPECT_FALSE(set.Lookup(i)); |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 TEST(TypedSlotSet, Iterate) { | 144 TEST(TypedSlotSet, Iterate) { |
145 TypedSlotSet set(0); | 145 TypedSlotSet set(0); |
146 const int kDelta = 10000001; | 146 const int kDelta = 10000001; |
147 const int kHostDelta = 50001; | 147 const int kHostDelta = 50001; |
148 int added = 0; | 148 int added = 0; |
(...skipping 26 matching lines...) Expand all Loading... |
175 EXPECT_EQ(0, i % 2); | 175 EXPECT_EQ(0, i % 2); |
176 ++iterated; | 176 ++iterated; |
177 return KEEP_SLOT; | 177 return KEEP_SLOT; |
178 }, | 178 }, |
179 TypedSlotSet::KEEP_EMPTY_CHUNKS); | 179 TypedSlotSet::KEEP_EMPTY_CHUNKS); |
180 EXPECT_EQ(added / 2, iterated); | 180 EXPECT_EQ(added / 2, iterated); |
181 } | 181 } |
182 | 182 |
183 } // namespace internal | 183 } // namespace internal |
184 } // namespace v8 | 184 } // namespace v8 |
OLD | NEW |