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

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

Issue 2428493003: [heap] Reland move slot filtering logic into sweeper. (Closed)
Patch Set: comments 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
« no previous file with comments | « src/heap/slot-set.h ('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 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 EXPECT_FALSE(set.Lookup(i)); 94 EXPECT_FALSE(set.Lookup(i));
95 } 95 }
96 } 96 }
97 } 97 }
98 98
99 void CheckRemoveRangeOn(uint32_t start, uint32_t end) { 99 void CheckRemoveRangeOn(uint32_t start, uint32_t end) {
100 SlotSet set; 100 SlotSet set;
101 set.SetPageStart(0); 101 set.SetPageStart(0);
102 uint32_t first = start == 0 ? 0 : start - kPointerSize; 102 uint32_t first = start == 0 ? 0 : start - kPointerSize;
103 uint32_t last = end == Page::kPageSize ? end - kPointerSize : end; 103 uint32_t last = end == Page::kPageSize ? end - kPointerSize : end;
104 for (uint32_t i = first; i <= last; i += kPointerSize) { 104 for (const auto mode :
105 set.Insert(i); 105 {SlotSet::FREE_EMPTY_BUCKETS, SlotSet::KEEP_EMPTY_BUCKETS}) {
106 } 106 for (uint32_t i = first; i <= last; i += kPointerSize) {
107 set.RemoveRange(start, end, SlotSet::FREE_EMPTY_BUCKETS); 107 set.Insert(i);
108 if (first != start) { 108 }
109 EXPECT_TRUE(set.Lookup(first)); 109 set.RemoveRange(start, end, mode);
110 } 110 if (first != start) {
111 if (last == end) { 111 EXPECT_TRUE(set.Lookup(first));
112 EXPECT_TRUE(set.Lookup(last)); 112 }
113 } 113 if (last == end) {
114 for (uint32_t i = start; i < end; i += kPointerSize) { 114 EXPECT_TRUE(set.Lookup(last));
115 EXPECT_FALSE(set.Lookup(i)); 115 }
116 for (uint32_t i = start; i < end; i += kPointerSize) {
117 EXPECT_FALSE(set.Lookup(i));
118 }
116 } 119 }
117 } 120 }
118 121
119 TEST(SlotSet, RemoveRange) { 122 TEST(SlotSet, RemoveRange) {
120 CheckRemoveRangeOn(0, Page::kPageSize); 123 CheckRemoveRangeOn(0, Page::kPageSize);
121 CheckRemoveRangeOn(1 * kPointerSize, 1023 * kPointerSize); 124 CheckRemoveRangeOn(1 * kPointerSize, 1023 * kPointerSize);
122 for (uint32_t start = 0; start <= 32; start++) { 125 for (uint32_t start = 0; start <= 32; start++) {
123 CheckRemoveRangeOn(start * kPointerSize, (start + 1) * kPointerSize); 126 CheckRemoveRangeOn(start * kPointerSize, (start + 1) * kPointerSize);
124 CheckRemoveRangeOn(start * kPointerSize, (start + 2) * kPointerSize); 127 CheckRemoveRangeOn(start * kPointerSize, (start + 2) * kPointerSize);
125 const uint32_t kEnds[] = {32, 64, 100, 128, 1024, 1500, 2048}; 128 const uint32_t kEnds[] = {32, 64, 100, 128, 1024, 1500, 2048};
126 for (int i = 0; i < sizeof(kEnds) / sizeof(uint32_t); i++) { 129 for (int i = 0; i < sizeof(kEnds) / sizeof(uint32_t); i++) {
127 for (int k = -3; k <= 3; k++) { 130 for (int k = -3; k <= 3; k++) {
128 uint32_t end = (kEnds[i] + k); 131 uint32_t end = (kEnds[i] + k);
129 if (start < end) { 132 if (start < end) {
130 CheckRemoveRangeOn(start * kPointerSize, end * kPointerSize); 133 CheckRemoveRangeOn(start * kPointerSize, end * kPointerSize);
131 } 134 }
132 } 135 }
133 } 136 }
134 } 137 }
135 SlotSet set; 138 SlotSet set;
136 set.SetPageStart(0); 139 set.SetPageStart(0);
137 set.Insert(Page::kPageSize / 2); 140 for (const auto mode :
138 set.RemoveRange(0, Page::kPageSize, SlotSet::FREE_EMPTY_BUCKETS); 141 {SlotSet::FREE_EMPTY_BUCKETS, SlotSet::KEEP_EMPTY_BUCKETS}) {
139 for (uint32_t i = 0; i < Page::kPageSize; i += kPointerSize) { 142 set.Insert(Page::kPageSize / 2);
140 EXPECT_FALSE(set.Lookup(i)); 143 set.RemoveRange(0, Page::kPageSize, mode);
144 for (uint32_t i = 0; i < Page::kPageSize; i += kPointerSize) {
145 EXPECT_FALSE(set.Lookup(i));
146 }
141 } 147 }
142 } 148 }
143 149
144 TEST(TypedSlotSet, Iterate) { 150 TEST(TypedSlotSet, Iterate) {
145 TypedSlotSet set(0); 151 TypedSlotSet set(0);
146 const int kDelta = 10000001; 152 const int kDelta = 10000001;
147 const int kHostDelta = 50001; 153 const int kHostDelta = 50001;
148 int added = 0; 154 int added = 0;
149 uint32_t j = 0; 155 uint32_t j = 0;
150 for (uint32_t i = 0; i < TypedSlotSet::kMaxOffset; 156 for (uint32_t i = 0; i < TypedSlotSet::kMaxOffset;
(...skipping 24 matching lines...) Expand all
175 EXPECT_EQ(0, i % 2); 181 EXPECT_EQ(0, i % 2);
176 ++iterated; 182 ++iterated;
177 return KEEP_SLOT; 183 return KEEP_SLOT;
178 }, 184 },
179 TypedSlotSet::KEEP_EMPTY_CHUNKS); 185 TypedSlotSet::KEEP_EMPTY_CHUNKS);
180 EXPECT_EQ(added / 2, iterated); 186 EXPECT_EQ(added / 2, iterated);
181 } 187 }
182 188
183 } // namespace internal 189 } // namespace internal
184 } // namespace v8 190 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/slot-set.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698