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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/heap/slot-set-unittest.cc
diff --git a/test/unittests/heap/slot-set-unittest.cc b/test/unittests/heap/slot-set-unittest.cc
index c9b1464d670b48615407aaa7001669030ef342fd..063b7ce2e76cb88a63996a06e440cc906120b39d 100644
--- a/test/unittests/heap/slot-set-unittest.cc
+++ b/test/unittests/heap/slot-set-unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <limits>
+#include <map>
#include "src/globals.h"
#include "src/heap/slot-set.h"
@@ -186,5 +187,35 @@ TEST(TypedSlotSet, Iterate) {
EXPECT_EQ(added / 2, iterated);
}
+TEST(TypedSlotSet, RemoveInvalidSlots) {
+ TypedSlotSet set(0);
+ const int kHostDelta = 100;
+ uint32_t entries = 10;
+ for (uint32_t i = 0; i < entries; i++) {
+ SlotType type = static_cast<SlotType>(i % CLEARED_SLOT);
+ set.Insert(type, i * kHostDelta, i * kHostDelta);
+ }
+
+ std::map<uint32_t, uint32_t> invalid_ranges;
+ for (uint32_t i = 1; i < entries; i += 2) {
+ invalid_ranges.insert(
+ std::pair<uint32_t, uint32_t>(i * kHostDelta, i * kHostDelta + 1));
+ }
+
+ set.RemoveInvaldSlots(invalid_ranges);
+ for (std::map<uint32_t, uint32_t>::iterator it = invalid_ranges.begin();
+ it != invalid_ranges.end(); ++it) {
+ uint32_t start = it->first;
+ uint32_t end = it->second;
+ set.Iterate(
+ [start, end](SlotType slot_type, Address host_addr, Address slot_addr) {
+ CHECK(reinterpret_cast<uintptr_t>(host_addr) < start ||
+ reinterpret_cast<uintptr_t>(host_addr) >= end);
+ return KEEP_SLOT;
+ },
+ TypedSlotSet::KEEP_EMPTY_CHUNKS);
+ }
+}
+
} // namespace internal
} // namespace v8
« 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