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

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

Issue 1608583002: New page local store buffer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase and fix signed unsigned conversion 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/cctest/test-unboxed-doubles.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
(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 "src/globals.h"
8 #include "src/heap/slot-set.h"
9 #include "src/heap/spaces.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace v8 {
13 namespace internal {
14
15 TEST(SlotSet, InsertAndLookup1) {
16 SlotSet set;
17 set.SetPageStart(0);
18 for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
19 EXPECT_FALSE(set.Lookup(i));
20 }
21 for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
22 set.Insert(i);
23 }
24 for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
25 EXPECT_TRUE(set.Lookup(i));
26 }
27 }
28
29 TEST(SlotSet, InsertAndLookup2) {
30 SlotSet set;
31 set.SetPageStart(0);
32 for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
33 if (i % 7 == 0) {
34 set.Insert(i);
35 }
36 }
37 for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
38 if (i % 7 == 0) {
39 EXPECT_TRUE(set.Lookup(i));
40 } else {
41 EXPECT_FALSE(set.Lookup(i));
42 }
43 }
44 }
45
46 TEST(SlotSet, Iterate) {
47 SlotSet set;
48 set.SetPageStart(0);
49 for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
50 if (i % 7 == 0) {
51 set.Insert(i);
52 }
53 }
54
55 set.Iterate([](Address slot_address) {
56 uintptr_t intaddr = reinterpret_cast<uintptr_t>(slot_address);
57 if (intaddr % 3 == 0) {
58 return SlotSet::KEEP_SLOT;
59 } else {
60 return SlotSet::REMOVE_SLOT;
61 }
62 });
63
64 for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
65 if (i % 21 == 0) {
66 EXPECT_TRUE(set.Lookup(i));
67 } else {
68 EXPECT_FALSE(set.Lookup(i));
69 }
70 }
71 }
72
73 TEST(SlotSet, Remove) {
74 SlotSet set;
75 set.SetPageStart(0);
76 for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
77 if (i % 7 == 0) {
78 set.Insert(i);
79 }
80 }
81
82 for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
83 if (i % 3 != 0) {
84 set.Remove(i);
85 }
86 }
87
88 for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
89 if (i % 21 == 0) {
90 EXPECT_TRUE(set.Lookup(i));
91 } else {
92 EXPECT_FALSE(set.Lookup(i));
93 }
94 }
95 }
96
97 TEST(SlotSet, RemoveRange) {
98 SlotSet set;
99 set.SetPageStart(0);
100 for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
101 set.Insert(i);
102 }
103
104 set.RemoveRange(0, Page::kPageSize);
105
106 for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
107 EXPECT_FALSE(set.Lookup(i));
108 }
109
110 for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
111 set.Insert(i);
112 }
113
114 set.RemoveRange(10 * kPointerSize, 10 * kPointerSize);
115 EXPECT_TRUE(set.Lookup(9 * kPointerSize));
116 EXPECT_TRUE(set.Lookup(10 * kPointerSize));
117 EXPECT_TRUE(set.Lookup(11 * kPointerSize));
118
119 set.RemoveRange(10 * kPointerSize, 1000 * kPointerSize);
120 for (int i = 0; i < Page::kPageSize; i += kPointerSize) {
121 if (10 * kPointerSize <= i && i < 1000 * kPointerSize) {
122 EXPECT_FALSE(set.Lookup(i));
123 } else {
124 EXPECT_TRUE(set.Lookup(i));
125 }
126 }
127 }
128
129 } // namespace internal
130 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/test-unboxed-doubles.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698