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

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

Issue 1701963003: Filter invalid slots after array trimming. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compile Created 4 years, 10 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 ac784e43ce09b73e410b9533b03bf0a664eca902..376188915a4b4004034c67087ad8029b0602f584 100644
--- a/test/unittests/heap/slot-set-unittest.cc
+++ b/test/unittests/heap/slot-set-unittest.cc
@@ -94,36 +94,49 @@ TEST(SlotSet, Remove) {
}
}
-TEST(SlotSet, RemoveRange) {
+void CheckRemoveRangeOn(uint32_t start, uint32_t end) {
SlotSet set;
set.SetPageStart(0);
- for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
+ uint32_t first = start == 0 ? 0 : start - kPointerSize;
+ uint32_t last = end == Page::kPageSize ? end - kPointerSize : end;
+ for (uint32_t i = first; i <= last; i += kPointerSize) {
set.Insert(i);
}
-
- set.RemoveRange(0, Page::kPageSize);
-
- for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
- EXPECT_FALSE(set.Lookup(i));
+ set.RemoveRange(start, end);
+ if (first != start) {
+ EXPECT_TRUE(set.Lookup(first));
}
-
- for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
- set.Insert(i);
+ if (last == end) {
+ EXPECT_TRUE(set.Lookup(last));
}
+ for (uint32_t i = start; i < end; i += kPointerSize) {
+ EXPECT_FALSE(set.Lookup(i));
+ }
+}
- set.RemoveRange(10 * kPointerSize, 10 * kPointerSize);
- EXPECT_TRUE(set.Lookup(9 * kPointerSize));
- EXPECT_TRUE(set.Lookup(10 * kPointerSize));
- EXPECT_TRUE(set.Lookup(11 * kPointerSize));
-
- set.RemoveRange(10 * kPointerSize, 1000 * kPointerSize);
- for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
- if (10 * kPointerSize <= i && i < 1000 * kPointerSize) {
- EXPECT_FALSE(set.Lookup(i));
- } else {
- EXPECT_TRUE(set.Lookup(i));
+TEST(SlotSet, RemoveRange) {
+ CheckRemoveRangeOn(0, Page::kPageSize);
+ CheckRemoveRangeOn(1 * kPointerSize, 1023 * kPointerSize);
+ for (uint32_t start = 0; start <= 32; start++) {
+ CheckRemoveRangeOn(start * kPointerSize, (start + 1) * kPointerSize);
+ CheckRemoveRangeOn(start * kPointerSize, (start + 2) * kPointerSize);
+ const uint32_t kEnds[] = {32, 64, 100, 128, 1024, 1500, 2048};
+ for (int i = 0; i < sizeof(kEnds) / sizeof(uint32_t); i++) {
+ for (int k = -3; k <= 3; k++) {
+ uint32_t end = (kEnds[i] + k);
+ if (start < end) {
+ CheckRemoveRangeOn(start * kPointerSize, end * kPointerSize);
+ }
+ }
}
}
+ SlotSet set;
+ set.SetPageStart(0);
+ set.Insert(Page::kPageSize / 2);
+ set.RemoveRange(0, Page::kPageSize);
+ for (uint32_t i = 0; i < Page::kPageSize; i += kPointerSize) {
+ EXPECT_FALSE(set.Lookup(i));
+ }
}
} // namespace internal
« 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