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

Side by Side Diff: src/atomicops_internals_x86_msvc.h

Issue 129813008: Atomic ops: sync with Chromium. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Resolve a conflict with the new ARM64 code Created 6 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 | « src/atomicops_internals_x86_macosx.h ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 15 matching lines...) Expand all
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // This file is an internal atomic implementation, use atomicops.h instead. 28 // This file is an internal atomic implementation, use atomicops.h instead.
29 29
30 #ifndef V8_ATOMICOPS_INTERNALS_X86_MSVC_H_ 30 #ifndef V8_ATOMICOPS_INTERNALS_X86_MSVC_H_
31 #define V8_ATOMICOPS_INTERNALS_X86_MSVC_H_ 31 #define V8_ATOMICOPS_INTERNALS_X86_MSVC_H_
32 32
33 #include "checks.h" 33 #include "checks.h"
34 #include "win32-headers.h" 34 #include "win32-headers.h"
35 35
36 #if defined(V8_HOST_ARCH_64_BIT)
37 // windows.h #defines this (only on x64). This causes problems because the
38 // public API also uses MemoryBarrier at the public name for this fence. So, on
39 // X64, undef it, and call its documented
40 // (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684208.aspx)
41 // implementation directly.
42 #undef MemoryBarrier
43 #endif
44
36 namespace v8 { 45 namespace v8 {
37 namespace internal { 46 namespace internal {
38 47
39 inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, 48 inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
40 Atomic32 old_value, 49 Atomic32 old_value,
41 Atomic32 new_value) { 50 Atomic32 new_value) {
42 LONG result = InterlockedCompareExchange( 51 LONG result = InterlockedCompareExchange(
43 reinterpret_cast<volatile LONG*>(ptr), 52 reinterpret_cast<volatile LONG*>(ptr),
44 static_cast<LONG>(new_value), 53 static_cast<LONG>(new_value),
45 static_cast<LONG>(old_value)); 54 static_cast<LONG>(old_value));
(...skipping 17 matching lines...) Expand all
63 72
64 inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, 73 inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
65 Atomic32 increment) { 74 Atomic32 increment) {
66 return Barrier_AtomicIncrement(ptr, increment); 75 return Barrier_AtomicIncrement(ptr, increment);
67 } 76 }
68 77
69 #if !(defined(_MSC_VER) && _MSC_VER >= 1400) 78 #if !(defined(_MSC_VER) && _MSC_VER >= 1400)
70 #error "We require at least vs2005 for MemoryBarrier" 79 #error "We require at least vs2005 for MemoryBarrier"
71 #endif 80 #endif
72 inline void MemoryBarrier() { 81 inline void MemoryBarrier() {
82 #if defined(V8_HOST_ARCH_64_BIT)
83 // See #undef and note at the top of this file.
84 __faststorefence();
85 #else
73 // We use MemoryBarrier from WinNT.h 86 // We use MemoryBarrier from WinNT.h
74 ::MemoryBarrier(); 87 ::MemoryBarrier();
88 #endif
75 } 89 }
76 90
77 inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, 91 inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
78 Atomic32 old_value, 92 Atomic32 old_value,
79 Atomic32 new_value) { 93 Atomic32 new_value) {
80 return NoBarrier_CompareAndSwap(ptr, old_value, new_value); 94 return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
81 } 95 }
82 96
83 inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, 97 inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
84 Atomic32 old_value, 98 Atomic32 old_value,
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 Atomic64 new_value) { 208 Atomic64 new_value) {
195 return NoBarrier_CompareAndSwap(ptr, old_value, new_value); 209 return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
196 } 210 }
197 211
198 212
199 #endif // defined(_WIN64) 213 #endif // defined(_WIN64)
200 214
201 } } // namespace v8::internal 215 } } // namespace v8::internal
202 216
203 #endif // V8_ATOMICOPS_INTERNALS_X86_MSVC_H_ 217 #endif // V8_ATOMICOPS_INTERNALS_X86_MSVC_H_
OLDNEW
« no previous file with comments | « src/atomicops_internals_x86_macosx.h ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698