OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include <limits> | |
6 | |
7 #include <set> | |
8 | |
9 #include "src/globals.h" | |
10 #include "src/heap/remembered-set.h" | |
11 #include "src/heap/spaces.h" | |
12 #include "testing/gtest/include/gtest/gtest.h" | |
13 | |
14 namespace v8 { | |
15 namespace internal { | |
16 | |
17 TEST(LocalSlotsBuffer, InsertAndIterate) { | |
18 LocalSlotsBuffer buffer; | |
19 std::set<Address> untyped; | |
20 std::set<std::pair<SlotType, Address> > typed; | |
21 | |
22 for (int k = 1000; k < 10000; k += NUMBER_OF_SLOT_TYPES) { | |
23 untyped.insert(reinterpret_cast<Address>(k)); | |
24 buffer.Record(reinterpret_cast<Address>(k)); | |
25 for (int i = 0; i < NUMBER_OF_SLOT_TYPES; i++) { | |
26 typed.insert(std::make_pair(static_cast<SlotType>(i), | |
27 reinterpret_cast<Address>(k + i))); | |
28 buffer.Record(static_cast<SlotType>(i), reinterpret_cast<Address>(k + i)); | |
29 } | |
30 } | |
31 buffer.Iterate( | |
32 [&untyped](Address addr) { | |
33 EXPECT_NE(untyped.count(addr), 0); | |
34 untyped.erase(addr); | |
35 }, | |
36 [&typed](SlotType type, Address addr) { | |
37 EXPECT_NE(typed.count(std::make_pair(type, addr)), 0); | |
38 typed.erase(std::make_pair(type, addr)); | |
39 }); | |
40 EXPECT_EQ(untyped.size(), 0); | |
41 EXPECT_EQ(typed.size(), 0); | |
42 } | |
43 | |
44 } // namespace internal | |
45 } // namespace v8 | |
OLD | NEW |