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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 TEST(SlotSet, Iterate) { | 46 TEST(SlotSet, Iterate) { |
47 SlotSet set; | 47 SlotSet set; |
48 set.SetPageStart(0); | 48 set.SetPageStart(0); |
49 for (int i = 0; i < Page::kPageSize; i += kPointerSize) { | 49 for (int i = 0; i < Page::kPageSize; i += kPointerSize) { |
50 if (i % 7 == 0) { | 50 if (i % 7 == 0) { |
51 set.Insert(i); | 51 set.Insert(i); |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 set.Iterate([](Address slot_address) { | 55 set.Iterate( |
56 uintptr_t intaddr = reinterpret_cast<uintptr_t>(slot_address); | 56 [](Address slot_address) { |
57 if (intaddr % 3 == 0) { | 57 uintptr_t intaddr = reinterpret_cast<uintptr_t>(slot_address); |
58 return KEEP_SLOT; | 58 if (intaddr % 3 == 0) { |
59 } else { | 59 return KEEP_SLOT; |
60 return REMOVE_SLOT; | 60 } else { |
61 } | 61 return REMOVE_SLOT; |
62 }); | 62 } |
| 63 }, |
| 64 SlotSet::KEEP_EMPTY_BUCKETS); |
63 | 65 |
64 for (int i = 0; i < Page::kPageSize; i += kPointerSize) { | 66 for (int i = 0; i < Page::kPageSize; i += kPointerSize) { |
65 if (i % 21 == 0) { | 67 if (i % 21 == 0) { |
66 EXPECT_TRUE(set.Lookup(i)); | 68 EXPECT_TRUE(set.Lookup(i)); |
67 } else { | 69 } else { |
68 EXPECT_FALSE(set.Lookup(i)); | 70 EXPECT_FALSE(set.Lookup(i)); |
69 } | 71 } |
70 } | 72 } |
71 } | 73 } |
72 | 74 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 EXPECT_EQ(0, i % 2); | 175 EXPECT_EQ(0, i % 2); |
174 ++iterated; | 176 ++iterated; |
175 return KEEP_SLOT; | 177 return KEEP_SLOT; |
176 }, | 178 }, |
177 TypedSlotSet::KEEP_EMPTY_CHUNKS); | 179 TypedSlotSet::KEEP_EMPTY_CHUNKS); |
178 EXPECT_EQ(added / 2, iterated); | 180 EXPECT_EQ(added / 2, iterated); |
179 } | 181 } |
180 | 182 |
181 } // namespace internal | 183 } // namespace internal |
182 } // namespace v8 | 184 } // namespace v8 |
OLD | NEW |