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

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

Issue 2440683002: [heap] Move typed slot filtering logic into sweeper. (Closed)
Patch Set: fix test Created 4 years, 1 month 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
« no previous file with comments | « 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 for (uint32_t i = 0; i < entries; i++) {
195 SlotType type = static_cast<SlotType>(i % CLEARED_SLOT);
196 set.Insert(type, i * kHostDelta, i * kHostDelta);
197 }
198
199 std::map<uint32_t, uint32_t> invalid_ranges;
200 for (uint32_t i = 1; i < entries; i += 2) {
201 invalid_ranges.insert(
202 std::pair<uint32_t, uint32_t>(i * kHostDelta, i * kHostDelta + 1));
203 }
204
205 set.RemoveInvaldSlots(invalid_ranges);
206 for (std::map<uint32_t, uint32_t>::iterator it = invalid_ranges.begin();
207 it != invalid_ranges.end(); ++it) {
208 uint32_t start = it->first;
209 uint32_t end = it->second;
210 set.Iterate(
211 [start, end](SlotType slot_type, Address host_addr, Address slot_addr) {
212 CHECK(reinterpret_cast<uintptr_t>(host_addr) < start ||
213 reinterpret_cast<uintptr_t>(host_addr) >= end);
214 return KEEP_SLOT;
215 },
216 TypedSlotSet::KEEP_EMPTY_CHUNKS);
217 }
218 }
219
189 } // namespace internal 220 } // namespace internal
190 } // namespace v8 221 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698