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

Side by Side Diff: test/unittests/base/atomic-utils-unittest.cc

Issue 2408233004: [heap] Old-to-new pointer updates need atomic accessors. (Closed)
Patch Set: inline check 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/mark-compact.cc ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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.h> 5 #include <limits.h>
6 6
7 #include "src/base/atomic-utils.h" 7 #include "src/base/atomic-utils.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 AtomicValue<void*> a(nullptr); 118 AtomicValue<void*> a(nullptr);
119 AtomicValue<void*> dummy(nullptr); 119 AtomicValue<void*> dummy(nullptr);
120 EXPECT_EQ(nullptr, a.Value()); 120 EXPECT_EQ(nullptr, a.Value());
121 a.SetValue(&a); 121 a.SetValue(&a);
122 EXPECT_EQ(&a, a.Value()); 122 EXPECT_EQ(&a, a.Value());
123 EXPECT_FALSE(a.TrySetValue(nullptr, &dummy)); 123 EXPECT_FALSE(a.TrySetValue(nullptr, &dummy));
124 EXPECT_TRUE(a.TrySetValue(&a, &dummy)); 124 EXPECT_TRUE(a.TrySetValue(&a, &dummy));
125 EXPECT_EQ(&dummy, a.Value()); 125 EXPECT_EQ(&dummy, a.Value());
126 } 126 }
127 127
128 TEST(NoBarrierAtomicValue, Initial) {
129 NoBarrierAtomicValue<TestFlag> a(kA);
130 EXPECT_EQ(TestFlag::kA, a.Value());
131 }
132
133 TEST(NoBarrierAtomicValue, SetValue) {
134 NoBarrierAtomicValue<TestFlag> a(kB);
135 a.SetValue(kC);
136 EXPECT_EQ(TestFlag::kC, a.Value());
137 }
138
139 TEST(NoBarrierAtomicValue, WithVoidStar) {
140 NoBarrierAtomicValue<void*> a(nullptr);
141 NoBarrierAtomicValue<void*> dummy(nullptr);
142 EXPECT_EQ(nullptr, a.Value());
143 a.SetValue(&a);
144 EXPECT_EQ(&a, a.Value());
145 }
146
147 TEST(NoBarrierAtomicValue, Construction) {
148 NoBarrierAtomicValue<TestFlag> a(kA);
149 TestFlag b = kA;
150 NoBarrierAtomicValue<TestFlag>* ptr =
151 NoBarrierAtomicValue<TestFlag>::FromAddress(&b);
152 EXPECT_EQ(ptr->Value(), a.Value());
153 }
154
155 TEST(NoBarrierAtomicValue, ConstructionVoidStar) {
156 NoBarrierAtomicValue<void*> a(nullptr);
157 void* b = nullptr;
158 NoBarrierAtomicValue<void*>* ptr =
159 NoBarrierAtomicValue<void*>::FromAddress(&b);
160 EXPECT_EQ(ptr->Value(), a.Value());
161 }
128 162
129 namespace { 163 namespace {
130 164
131 enum TestSetValue { kAA, kBB, kCC, kLastValue = kCC }; 165 enum TestSetValue { kAA, kBB, kCC, kLastValue = kCC };
132 166
133 } // namespace 167 } // namespace
134 168
135 169
136 TEST(AtomicEnumSet, Constructor) { 170 TEST(AtomicEnumSet, Constructor) {
137 AtomicEnumSet<TestSetValue> a; 171 AtomicEnumSet<TestSetValue> a;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 a.Add(kAA); 265 a.Add(kAA);
232 EXPECT_FALSE(a == b); 266 EXPECT_FALSE(a == b);
233 EXPECT_TRUE(a != b); 267 EXPECT_TRUE(a != b);
234 b.Add(kAA); 268 b.Add(kAA);
235 EXPECT_TRUE(a == b); 269 EXPECT_TRUE(a == b);
236 EXPECT_FALSE(a != b); 270 EXPECT_FALSE(a != b);
237 } 271 }
238 272
239 } // namespace base 273 } // namespace base
240 } // namespace v8 274 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/mark-compact.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698