OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 Acquire_Store(&value, kVal2); | 207 Acquire_Store(&value, kVal2); |
208 CHECK_EQU(kVal2, value); | 208 CHECK_EQU(kVal2, value); |
209 | 209 |
210 Release_Store(&value, kVal1); | 210 Release_Store(&value, kVal1); |
211 CHECK_EQU(kVal1, value); | 211 CHECK_EQU(kVal1, value); |
212 Release_Store(&value, kVal2); | 212 Release_Store(&value, kVal2); |
213 CHECK_EQU(kVal2, value); | 213 CHECK_EQU(kVal2, value); |
214 } | 214 } |
215 | 215 |
216 | 216 |
| 217 // Merge this test with TestStore as soon as we have Atomic8 acquire |
| 218 // and release stores. |
| 219 static void TestStoreAtomic8() { |
| 220 const Atomic8 kVal1 = TestFillValue<Atomic8>(); |
| 221 const Atomic8 kVal2 = static_cast<Atomic8>(-1); |
| 222 |
| 223 Atomic8 value; |
| 224 |
| 225 NoBarrier_Store(&value, kVal1); |
| 226 CHECK_EQU(kVal1, value); |
| 227 NoBarrier_Store(&value, kVal2); |
| 228 CHECK_EQU(kVal2, value); |
| 229 } |
| 230 |
| 231 |
217 // This is a simple sanity check to ensure that values are correct. | 232 // This is a simple sanity check to ensure that values are correct. |
218 // Not testing atomicity. | 233 // Not testing atomicity. |
219 template <class AtomicType> | 234 template <class AtomicType> |
220 static void TestLoad() { | 235 static void TestLoad() { |
221 const AtomicType kVal1 = TestFillValue<AtomicType>(); | 236 const AtomicType kVal1 = TestFillValue<AtomicType>(); |
222 const AtomicType kVal2 = static_cast<AtomicType>(-1); | 237 const AtomicType kVal2 = static_cast<AtomicType>(-1); |
223 | 238 |
224 AtomicType value; | 239 AtomicType value; |
225 | 240 |
226 value = kVal1; | 241 value = kVal1; |
227 CHECK_EQU(kVal1, NoBarrier_Load(&value)); | 242 CHECK_EQU(kVal1, NoBarrier_Load(&value)); |
228 value = kVal2; | 243 value = kVal2; |
229 CHECK_EQU(kVal2, NoBarrier_Load(&value)); | 244 CHECK_EQU(kVal2, NoBarrier_Load(&value)); |
230 | 245 |
231 value = kVal1; | 246 value = kVal1; |
232 CHECK_EQU(kVal1, Acquire_Load(&value)); | 247 CHECK_EQU(kVal1, Acquire_Load(&value)); |
233 value = kVal2; | 248 value = kVal2; |
234 CHECK_EQU(kVal2, Acquire_Load(&value)); | 249 CHECK_EQU(kVal2, Acquire_Load(&value)); |
235 | 250 |
236 value = kVal1; | 251 value = kVal1; |
237 CHECK_EQU(kVal1, Release_Load(&value)); | 252 CHECK_EQU(kVal1, Release_Load(&value)); |
238 value = kVal2; | 253 value = kVal2; |
239 CHECK_EQU(kVal2, Release_Load(&value)); | 254 CHECK_EQU(kVal2, Release_Load(&value)); |
240 } | 255 } |
241 | 256 |
242 | 257 |
| 258 // Merge this test with TestLoad as soon as we have Atomic8 acquire |
| 259 // and release loads. |
| 260 static void TestLoadAtomic8() { |
| 261 const Atomic8 kVal1 = TestFillValue<Atomic8>(); |
| 262 const Atomic8 kVal2 = static_cast<Atomic8>(-1); |
| 263 |
| 264 Atomic8 value; |
| 265 |
| 266 value = kVal1; |
| 267 CHECK_EQU(kVal1, NoBarrier_Load(&value)); |
| 268 value = kVal2; |
| 269 CHECK_EQU(kVal2, NoBarrier_Load(&value)); |
| 270 } |
| 271 |
| 272 |
243 TEST(AtomicIncrement) { | 273 TEST(AtomicIncrement) { |
244 TestAtomicIncrement<Atomic32>(); | 274 TestAtomicIncrement<Atomic32>(); |
245 TestAtomicIncrement<AtomicWord>(); | 275 TestAtomicIncrement<AtomicWord>(); |
246 } | 276 } |
247 | 277 |
248 | 278 |
249 TEST(CompareAndSwap) { | 279 TEST(CompareAndSwap) { |
250 TestCompareAndSwap<Atomic32>(); | 280 TestCompareAndSwap<Atomic32>(); |
251 TestCompareAndSwap<AtomicWord>(); | 281 TestCompareAndSwap<AtomicWord>(); |
252 } | 282 } |
253 | 283 |
254 | 284 |
255 TEST(AtomicExchange) { | 285 TEST(AtomicExchange) { |
256 TestAtomicExchange<Atomic32>(); | 286 TestAtomicExchange<Atomic32>(); |
257 TestAtomicExchange<AtomicWord>(); | 287 TestAtomicExchange<AtomicWord>(); |
258 } | 288 } |
259 | 289 |
260 | 290 |
261 TEST(AtomicIncrementBounds) { | 291 TEST(AtomicIncrementBounds) { |
262 TestAtomicIncrementBounds<Atomic32>(); | 292 TestAtomicIncrementBounds<Atomic32>(); |
263 TestAtomicIncrementBounds<AtomicWord>(); | 293 TestAtomicIncrementBounds<AtomicWord>(); |
264 } | 294 } |
265 | 295 |
266 | 296 |
267 TEST(Store) { | 297 TEST(Store) { |
| 298 TestStoreAtomic8(); |
268 TestStore<Atomic32>(); | 299 TestStore<Atomic32>(); |
269 TestStore<AtomicWord>(); | 300 TestStore<AtomicWord>(); |
270 } | 301 } |
271 | 302 |
272 | 303 |
273 TEST(Load) { | 304 TEST(Load) { |
| 305 TestLoadAtomic8(); |
274 TestLoad<Atomic32>(); | 306 TestLoad<Atomic32>(); |
275 TestLoad<AtomicWord>(); | 307 TestLoad<AtomicWord>(); |
276 } | 308 } |
OLD | NEW |