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

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

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