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

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

Issue 1725073003: Revert of Replace slots buffer with remembered set. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « test/unittests/heap/remembered-set-unittest.cc ('k') | test/unittests/unittests.gyp » ('j') | 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 set.SetPageStart(0); 48 set.SetPageStart(0);
49 for (int i = 0; i < Page::kPageSize; i += kPointerSize) { 49 for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
50 if (i % 7 == 0) { 50 if (i % 7 == 0) {
51 set.Insert(i); 51 set.Insert(i);
52 } 52 }
53 } 53 }
54 54
55 set.Iterate([](Address slot_address) { 55 set.Iterate([](Address slot_address) {
56 uintptr_t intaddr = reinterpret_cast<uintptr_t>(slot_address); 56 uintptr_t intaddr = reinterpret_cast<uintptr_t>(slot_address);
57 if (intaddr % 3 == 0) { 57 if (intaddr % 3 == 0) {
58 return KEEP_SLOT; 58 return SlotSet::KEEP_SLOT;
59 } else { 59 } else {
60 return REMOVE_SLOT; 60 return SlotSet::REMOVE_SLOT;
61 } 61 }
62 }); 62 });
63 63
64 for (int i = 0; i < Page::kPageSize; i += kPointerSize) { 64 for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
65 if (i % 21 == 0) { 65 if (i % 21 == 0) {
66 EXPECT_TRUE(set.Lookup(i)); 66 EXPECT_TRUE(set.Lookup(i));
67 } else { 67 } else {
68 EXPECT_FALSE(set.Lookup(i)); 68 EXPECT_FALSE(set.Lookup(i));
69 } 69 }
70 } 70 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 132 }
133 SlotSet set; 133 SlotSet set;
134 set.SetPageStart(0); 134 set.SetPageStart(0);
135 set.Insert(Page::kPageSize / 2); 135 set.Insert(Page::kPageSize / 2);
136 set.RemoveRange(0, Page::kPageSize); 136 set.RemoveRange(0, Page::kPageSize);
137 for (uint32_t i = 0; i < Page::kPageSize; i += kPointerSize) { 137 for (uint32_t i = 0; i < Page::kPageSize; i += kPointerSize) {
138 EXPECT_FALSE(set.Lookup(i)); 138 EXPECT_FALSE(set.Lookup(i));
139 } 139 }
140 } 140 }
141 141
142 TEST(TypedSlotSet, Iterate) {
143 TypedSlotSet set(0);
144 const int kDelta = 10000001;
145 int added = 0;
146 for (uint32_t i = 0; i < TypedSlotSet::kMaxOffset; i += kDelta) {
147 SlotType type = static_cast<SlotType>(i % NUMBER_OF_SLOT_TYPES);
148 set.Insert(type, i);
149 ++added;
150 }
151 int iterated = 0;
152 set.Iterate([&iterated, kDelta](SlotType type, Address addr) {
153 uint32_t i = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr));
154 EXPECT_EQ(i % NUMBER_OF_SLOT_TYPES, static_cast<uint32_t>(type));
155 EXPECT_EQ(0, i % kDelta);
156 ++iterated;
157 return i % 2 == 0 ? KEEP_SLOT : REMOVE_SLOT;
158 });
159 EXPECT_EQ(added, iterated);
160 iterated = 0;
161 set.Iterate([&iterated](SlotType type, Address addr) {
162 uint32_t i = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr));
163 EXPECT_EQ(0, i % 2);
164 ++iterated;
165 return KEEP_SLOT;
166 });
167 EXPECT_EQ(added / 2, iterated);
168 }
169
170 } // namespace internal 142 } // namespace internal
171 } // namespace v8 143 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/heap/remembered-set-unittest.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698