Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: test/unittests/heap/slot-set-unittest.cc

Issue 2440683002: [heap] Move typed slot filtering logic into sweeper. (Closed)
Patch Set: format Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/heap/slot-set.h ('K') | « test/cctest/heap/test-heap.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7
7 #include "src/globals.h" 8 #include "src/globals.h"
8 #include "src/heap/slot-set.h" 9 #include "src/heap/slot-set.h"
9 #include "src/heap/spaces.h" 10 #include "src/heap/spaces.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace v8 { 13 namespace v8 {
13 namespace internal { 14 namespace internal {
14 15
15 TEST(SlotSet, InsertAndLookup1) { 16 TEST(SlotSet, InsertAndLookup1) {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 [&iterated](SlotType type, Address host_addr, Address addr) { 180 [&iterated](SlotType type, Address host_addr, Address addr) {
180 uint32_t i = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)); 181 uint32_t i = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr));
181 EXPECT_EQ(0, i % 2); 182 EXPECT_EQ(0, i % 2);
182 ++iterated; 183 ++iterated;
183 return KEEP_SLOT; 184 return KEEP_SLOT;
184 }, 185 },
185 TypedSlotSet::KEEP_EMPTY_CHUNKS); 186 TypedSlotSet::KEEP_EMPTY_CHUNKS);
186 EXPECT_EQ(added / 2, iterated); 187 EXPECT_EQ(added / 2, iterated);
187 } 188 }
188 189
190 TEST(TypedSlotSet, RemoveInvalidSlots) {
191 TypedSlotSet set(0);
192 const int kHostDelta = 100;
193 uint32_t entries = 10;
194 uint32_t j = 0;
195 for (uint32_t i = 0; i < entries; i++) {
196 SlotType type = static_cast<SlotType>(i % CLEARED_SLOT);
197 set.Insert(type, i * kHostDelta, i * kHostDelta);
198 }
199
200 std::map<uint32_t, uint32_t> invalid_ranges;
201 for (uint32_t i = 0; i < entries; i += 2) {
202 invalid_ranges.insert(
203 std::pair<uint32_t, uint32_t>(i * kHostDelta, i * kHostDelta + 1));
204 }
205
206 set.RemoveInvaldSlots(invalid_ranges);
207 for (std::map<uint32_t, uint32_t>::iterator it = invalid_ranges.begin();
208 it != invalid_ranges.end(); ++it) {
209 uint32_t start = it->first;
210 uint32_t end = it->second;
211 set.Iterate(
212 [start, end](SlotType slot_type, Address host_addr, Address slot_addr) {
213 CHECK(reinterpret_cast<uintptr_t>(host_addr) < start ||
214 reinterpret_cast<uintptr_t>(host_addr) >= end);
215 return KEEP_SLOT;
216 },
217 TypedSlotSet::KEEP_EMPTY_CHUNKS);
218 }
219 }
220
189 } // namespace internal 221 } // namespace internal
190 } // namespace v8 222 } // namespace v8
OLDNEW
« src/heap/slot-set.h ('K') | « test/cctest/heap/test-heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698