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 #include <map> | 6 #include <map> |
7 | 7 |
8 #include "src/globals.h" | 8 #include "src/globals.h" |
9 #include "src/heap/slot-set.h" | 9 #include "src/heap/slot-set.h" |
10 #include "src/heap/spaces.h" | 10 #include "src/heap/spaces.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 set.Insert(Page::kPageSize / 2); | 143 set.Insert(Page::kPageSize / 2); |
144 set.RemoveRange(0, Page::kPageSize, mode); | 144 set.RemoveRange(0, Page::kPageSize, mode); |
145 for (uint32_t i = 0; i < Page::kPageSize; i += kPointerSize) { | 145 for (uint32_t i = 0; i < Page::kPageSize; i += kPointerSize) { |
146 EXPECT_FALSE(set.Lookup(i)); | 146 EXPECT_FALSE(set.Lookup(i)); |
147 } | 147 } |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 TEST(TypedSlotSet, Iterate) { | 151 TEST(TypedSlotSet, Iterate) { |
152 TypedSlotSet set(0); | 152 TypedSlotSet set(0); |
153 const int kDelta = 10000001; | 153 // These two constants must be static as a workaround |
154 const int kHostDelta = 50001; | 154 // for a MSVC++ bug about lambda captures, see the discussion at |
| 155 // https://social.msdn.microsoft.com/Forums/SqlServer/4abf18bd-4ae4-4c72-ba3e-
3b13e7909d5f |
| 156 static const int kDelta = 10000001; |
| 157 static const int kHostDelta = 50001; |
155 int added = 0; | 158 int added = 0; |
156 uint32_t j = 0; | 159 uint32_t j = 0; |
157 for (uint32_t i = 0; i < TypedSlotSet::kMaxOffset; | 160 for (uint32_t i = 0; i < TypedSlotSet::kMaxOffset; |
158 i += kDelta, j += kHostDelta) { | 161 i += kDelta, j += kHostDelta) { |
159 SlotType type = static_cast<SlotType>(i % CLEARED_SLOT); | 162 SlotType type = static_cast<SlotType>(i % CLEARED_SLOT); |
160 set.Insert(type, j, i); | 163 set.Insert(type, j, i); |
161 ++added; | 164 ++added; |
162 } | 165 } |
163 int iterated = 0; | 166 int iterated = 0; |
164 set.Iterate( | 167 set.Iterate( |
165 [&iterated, kDelta, kHostDelta](SlotType type, Address host_addr, | 168 [&iterated](SlotType type, Address host_addr, |
166 Address addr) { | 169 Address addr) { |
167 uint32_t i = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)); | 170 uint32_t i = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)); |
168 uint32_t j = | 171 uint32_t j = |
169 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(host_addr)); | 172 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(host_addr)); |
170 EXPECT_EQ(i % CLEARED_SLOT, static_cast<uint32_t>(type)); | 173 EXPECT_EQ(i % CLEARED_SLOT, static_cast<uint32_t>(type)); |
171 EXPECT_EQ(0u, i % kDelta); | 174 EXPECT_EQ(0u, i % kDelta); |
172 EXPECT_EQ(0u, j % kHostDelta); | 175 EXPECT_EQ(0u, j % kHostDelta); |
173 ++iterated; | 176 ++iterated; |
174 return i % 2 == 0 ? KEEP_SLOT : REMOVE_SLOT; | 177 return i % 2 == 0 ? KEEP_SLOT : REMOVE_SLOT; |
175 }, | 178 }, |
176 TypedSlotSet::KEEP_EMPTY_CHUNKS); | 179 TypedSlotSet::KEEP_EMPTY_CHUNKS); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 CHECK(reinterpret_cast<uintptr_t>(host_addr) < start || | 215 CHECK(reinterpret_cast<uintptr_t>(host_addr) < start || |
213 reinterpret_cast<uintptr_t>(host_addr) >= end); | 216 reinterpret_cast<uintptr_t>(host_addr) >= end); |
214 return KEEP_SLOT; | 217 return KEEP_SLOT; |
215 }, | 218 }, |
216 TypedSlotSet::KEEP_EMPTY_CHUNKS); | 219 TypedSlotSet::KEEP_EMPTY_CHUNKS); |
217 } | 220 } |
218 } | 221 } |
219 | 222 |
220 } // namespace internal | 223 } // namespace internal |
221 } // namespace v8 | 224 } // namespace v8 |
OLD | NEW |