[cleanup] Rename base::MemoryBarrier to base::MemoryFence.

This reduces confusion with GC write barrier. The word "barrier" is
reserved for GC write barrier and "fence" for memory ordering fence.

BUG=v8:6474

Change-Id: Ic4352f04430eaca742b72db1580ee0a42a1ffefb
Reviewed-on: https://chromium-review.googlesource.com/528103
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45813}
diff --git a/src/base/atomicops.h b/src/base/atomicops.h
index 7fb0700..0cd1369 100644
--- a/src/base/atomicops.h
+++ b/src/base/atomicops.h
@@ -36,15 +36,6 @@
 #include "src/base/base-export.h"
 #include "src/base/build_config.h"
 
-#if defined(V8_OS_WIN) && defined(V8_HOST_ARCH_64_BIT)
-// windows.h #defines this (only on x64). This causes problems because the
-// public API also uses MemoryBarrier at the public name for this fence. So, on
-// X64, undef it, and call its documented
-// (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684208.aspx)
-// implementation directly.
-#undef MemoryBarrier
-#endif
-
 namespace v8 {
 namespace base {
 
@@ -94,9 +85,8 @@
 // a store with appropriate memory-ordering instructions.  "Acquire" operations
 // ensure that no later memory access can be reordered ahead of the operation.
 // "Release" operations ensure that no previous memory access can be reordered
-// after the operation.  "Barrier" operations have both "Acquire" and "Release"
-// semantics.   A MemoryBarrier() has "Barrier" semantics, but does no memory
-// access.
+// after the operation.  "Fence" operations have both "Acquire" and "Release"
+// semantics. A MemoryFence() has "Fence" semantics, but does no memory access.
 Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
                                 Atomic32 old_value,
                                 Atomic32 new_value);
@@ -104,7 +94,7 @@
                                 Atomic32 old_value,
                                 Atomic32 new_value);
 
-void MemoryBarrier();
+void MemoryFence();
 void Relaxed_Store(volatile Atomic8* ptr, Atomic8 value);
 void Relaxed_Store(volatile Atomic32* ptr, Atomic32 value);
 void Release_Store(volatile Atomic32* ptr, Atomic32 value);
diff --git a/src/base/atomicops_internals_portable.h b/src/base/atomicops_internals_portable.h
index 8f86785..ad1e595 100644
--- a/src/base/atomicops_internals_portable.h
+++ b/src/base/atomicops_internals_portable.h
@@ -39,7 +39,7 @@
 // This implementation is transitional and maintains the original API for
 // atomicops.h.
 
-inline void MemoryBarrier() {
+inline void MemoryFence() {
 #if defined(__GLIBCXX__)
   // Work around libstdc++ bug 51038 where atomic_thread_fence was declared but
   // not defined, leading to the linker complaining about undefined references.
diff --git a/src/base/atomicops_internals_x86_msvc.h b/src/base/atomicops_internals_x86_msvc.h
index cf3a3c0..89a458e 100644
--- a/src/base/atomicops_internals_x86_msvc.h
+++ b/src/base/atomicops_internals_x86_msvc.h
@@ -10,15 +10,6 @@
 #include "src/base/macros.h"
 #include "src/base/win32-headers.h"
 
-#if defined(V8_HOST_ARCH_64_BIT)
-// windows.h #defines this (only on x64). This causes problems because the
-// public API also uses MemoryBarrier at the public name for this fence. So, on
-// X64, undef it, and call its documented
-// (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684208.aspx)
-// implementation directly.
-#undef MemoryBarrier
-#endif
-
 namespace v8 {
 namespace base {
 
@@ -49,15 +40,7 @@
   return Barrier_AtomicIncrement(ptr, increment);
 }
 
-inline void MemoryBarrier() {
-#if defined(V8_HOST_ARCH_64_BIT)
-  // See #undef and note at the top of this file.
-  __faststorefence();
-#else
-  // We use MemoryBarrier from WinNT.h
-  ::MemoryBarrier();
-#endif
-}
+inline void MemoryFence() { MemoryBarrier(); }
 
 inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
                                        Atomic32 old_value,
diff --git a/src/base/platform/platform-win32.cc b/src/base/platform/platform-win32.cc
index 7b7ff99..fd4461b 100644
--- a/src/base/platform/platform-win32.cc
+++ b/src/base/platform/platform-win32.cc
@@ -37,7 +37,7 @@
 #define _TRUNCATE 0
 #define STRUNCATE 80
 
-inline void MemoryBarrier() {
+inline void MemoryFence() {
   int barrier = 0;
   __asm__ __volatile__("xchgl %%eax,%0 ":"=r" (barrier));
 }
diff --git a/src/profiler/circular-queue-inl.h b/src/profiler/circular-queue-inl.h
index 428945a..4ba7741 100644
--- a/src/profiler/circular-queue-inl.h
+++ b/src/profiler/circular-queue-inl.h
@@ -24,7 +24,7 @@
 
 template<typename T, unsigned L>
 T* SamplingCircularQueue<T, L>::Peek() {
-  base::MemoryBarrier();
+  base::MemoryFence();
   if (base::Acquire_Load(&dequeue_pos_->marker) == kFull) {
     return &dequeue_pos_->record;
   }
@@ -41,7 +41,7 @@
 
 template<typename T, unsigned L>
 T* SamplingCircularQueue<T, L>::StartEnqueue() {
-  base::MemoryBarrier();
+  base::MemoryFence();
   if (base::Acquire_Load(&enqueue_pos_->marker) == kEmpty) {
     return &enqueue_pos_->record;
   }