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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 const int kHostDelta = 50001; | 145 const int kHostDelta = 50001; |
146 int added = 0; | 146 int added = 0; |
147 uint32_t j = 0; | 147 uint32_t j = 0; |
148 for (uint32_t i = 0; i < TypedSlotSet::kMaxOffset; | 148 for (uint32_t i = 0; i < TypedSlotSet::kMaxOffset; |
149 i += kDelta, j += kHostDelta) { | 149 i += kDelta, j += kHostDelta) { |
150 SlotType type = static_cast<SlotType>(i % CLEARED_SLOT); | 150 SlotType type = static_cast<SlotType>(i % CLEARED_SLOT); |
151 set.Insert(type, j, i); | 151 set.Insert(type, j, i); |
152 ++added; | 152 ++added; |
153 } | 153 } |
154 int iterated = 0; | 154 int iterated = 0; |
155 set.Iterate([&iterated, kDelta, kHostDelta](SlotType type, Address host_addr, | 155 set.Iterate( |
156 Address addr) { | 156 [&iterated, kDelta, kHostDelta](SlotType type, Address host_addr, |
157 uint32_t i = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)); | 157 Address addr) { |
158 uint32_t j = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(host_addr)); | 158 uint32_t i = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)); |
159 EXPECT_EQ(i % CLEARED_SLOT, static_cast<uint32_t>(type)); | 159 uint32_t j = |
160 EXPECT_EQ(0, i % kDelta); | 160 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(host_addr)); |
161 EXPECT_EQ(0, j % kHostDelta); | 161 EXPECT_EQ(i % CLEARED_SLOT, static_cast<uint32_t>(type)); |
162 ++iterated; | 162 EXPECT_EQ(0, i % kDelta); |
163 return i % 2 == 0 ? KEEP_SLOT : REMOVE_SLOT; | 163 EXPECT_EQ(0, j % kHostDelta); |
164 }); | 164 ++iterated; |
| 165 return i % 2 == 0 ? KEEP_SLOT : REMOVE_SLOT; |
| 166 }, |
| 167 TypedSlotSet::KEEP_EMPTY_CHUNKS); |
165 EXPECT_EQ(added, iterated); | 168 EXPECT_EQ(added, iterated); |
166 iterated = 0; | 169 iterated = 0; |
167 set.Iterate([&iterated](SlotType type, Address host_addr, Address addr) { | 170 set.Iterate( |
168 uint32_t i = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)); | 171 [&iterated](SlotType type, Address host_addr, Address addr) { |
169 EXPECT_EQ(0, i % 2); | 172 uint32_t i = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)); |
170 ++iterated; | 173 EXPECT_EQ(0, i % 2); |
171 return KEEP_SLOT; | 174 ++iterated; |
172 }); | 175 return KEEP_SLOT; |
| 176 }, |
| 177 TypedSlotSet::KEEP_EMPTY_CHUNKS); |
173 EXPECT_EQ(added / 2, iterated); | 178 EXPECT_EQ(added / 2, iterated); |
174 } | 179 } |
175 | 180 |
176 } // namespace internal | 181 } // namespace internal |
177 } // namespace v8 | 182 } // namespace v8 |
OLD | NEW |