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

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

Issue 2360513002: [heap] Make typed slot set state and operations atomic. (Closed)
Patch Set: remove include Created 4 years, 3 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 140 }
141 141
142 TEST(TypedSlotSet, Iterate) { 142 TEST(TypedSlotSet, Iterate) {
143 TypedSlotSet set(0); 143 TypedSlotSet set(0);
144 const int kDelta = 10000001; 144 const int kDelta = 10000001;
145 const int kHostDelta = 50001; 145 const int kHostDelta = 50001;
146 int added = 0; 146 int added = 0;
147 uint32_t j = 0; 147 uint32_t j = 0;
148 for (uint32_t i = 0; i < TypedSlotSet::kMaxOffset; 148 for (uint32_t i = 0; i < TypedSlotSet::kMaxOffset;
149 i += kDelta, j += kHostDelta) { 149 i += kDelta, j += kHostDelta) {
150 SlotType type = static_cast<SlotType>(i % NUMBER_OF_SLOT_TYPES); 150 SlotType type = static_cast<SlotType>(i % CLEARED_SLOT);
151 set.Insert(type, j, i); 151 set.Insert(type, j, i);
152 ++added; 152 ++added;
153 } 153 }
154 int iterated = 0; 154 int iterated = 0;
155 set.Iterate([&iterated, kDelta, kHostDelta](SlotType type, Address host_addr, 155 set.Iterate([&iterated, kDelta, kHostDelta](SlotType type, Address host_addr,
156 Address addr) { 156 Address addr) {
157 uint32_t i = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)); 157 uint32_t i = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr));
158 uint32_t j = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(host_addr)); 158 uint32_t j = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(host_addr));
159 EXPECT_EQ(i % NUMBER_OF_SLOT_TYPES, static_cast<uint32_t>(type)); 159 EXPECT_EQ(i % CLEARED_SLOT, static_cast<uint32_t>(type));
160 EXPECT_EQ(0, i % kDelta); 160 EXPECT_EQ(0, i % kDelta);
161 EXPECT_EQ(0, j % kHostDelta); 161 EXPECT_EQ(0, j % kHostDelta);
162 ++iterated; 162 ++iterated;
163 return i % 2 == 0 ? KEEP_SLOT : REMOVE_SLOT; 163 return i % 2 == 0 ? KEEP_SLOT : REMOVE_SLOT;
164 }); 164 });
165 EXPECT_EQ(added, iterated); 165 EXPECT_EQ(added, iterated);
166 iterated = 0; 166 iterated = 0;
167 set.Iterate([&iterated](SlotType type, Address host_addr, Address addr) { 167 set.Iterate([&iterated](SlotType type, Address host_addr, Address addr) {
168 uint32_t i = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)); 168 uint32_t i = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr));
169 EXPECT_EQ(0, i % 2); 169 EXPECT_EQ(0, i % 2);
170 ++iterated; 170 ++iterated;
171 return KEEP_SLOT; 171 return KEEP_SLOT;
172 }); 172 });
173 EXPECT_EQ(added / 2, iterated); 173 EXPECT_EQ(added / 2, iterated);
174 } 174 }
175 175
176 } // namespace internal 176 } // namespace internal
177 } // namespace v8 177 } // 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