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

Side by Side Diff: third_party/WebKit/Source/wtf/SpinLock.cpp

Issue 1461743002: Add noBarrierStore to WTF and use it for spinlocks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: oops Created 5 years, 1 month 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 | « third_party/WebKit/Source/wtf/Atomics.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium 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 "config.h" 5 #include "config.h"
6 #include "wtf/SpinLock.h" 6 #include "wtf/SpinLock.h"
7 7
8 #include "wtf/Atomics.h" 8 #include "wtf/Atomics.h"
9 #include "wtf/CPU.h" 9 #include "wtf/CPU.h"
10 #include "wtf/Compiler.h" 10 #include "wtf/Compiler.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 { 55 {
56 // The value of kYieldProcessorTries is cargo culted from TCMalloc, Windows 56 // The value of kYieldProcessorTries is cargo culted from TCMalloc, Windows
57 // critical section defaults, and various other recommendations. 57 // critical section defaults, and various other recommendations.
58 // TODO(jschuh): Further tuning may be warranted. 58 // TODO(jschuh): Further tuning may be warranted.
59 static const int kYieldProcessorTries = 1000; 59 static const int kYieldProcessorTries = 1000;
60 do { 60 do {
61 do { 61 do {
62 for (int count = 0; count < kYieldProcessorTries; ++count) { 62 for (int count = 0; count < kYieldProcessorTries; ++count) {
63 // Let the Processor know we're spinning. 63 // Let the Processor know we're spinning.
64 YIELD_PROCESSOR; 64 YIELD_PROCESSOR;
65 if (!*lock && LIKELY(!atomicTestAndSetToOne(lock))) 65 if (!noBarrierLoad(lock) && LIKELY(!atomicTestAndSetToOne(lock)) )
66 return; 66 return;
67 } 67 }
68 68
69 // Give the OS a chance to schedule something on this core. 69 // Give the OS a chance to schedule something on this core.
70 YIELD_THREAD; 70 YIELD_THREAD;
71 } while (*lock); 71 } while (noBarrierLoad(lock));
72 } while (UNLIKELY(atomicTestAndSetToOne(lock))); 72 } while (UNLIKELY(atomicTestAndSetToOne(lock)));
73 } 73 }
74 74
75 } // namespace WTF 75 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/Atomics.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698