Commit c47ae4ec authored by Nico Weber's avatar Nico Weber Committed by V8 LUCI CQ

[win] Use std::atomic_thread_fence<> instead of _ReadWriteBarrier()

_ReadWriteBarrier() is deprecated, and <atomic> has been available for
a while now.

Ports part of https://chromium-review.googlesource.com/c/chromium/src/+/2365092
to v8.

No behavior change.

Bug: chromium:1255114
Change-Id: I9954193a69dad9396a5e9e7450066382de2fb172
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3204827
Auto-Submit: Nico Weber <thakis@chromium.org>
Commit-Queue: Hannes Payer <hpayer@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77258}
parent 57636196
......@@ -24,6 +24,8 @@
// This has to come after windows.h.
#include <mmsystem.h> // For timeGetTime().
#include <atomic>
#include "src/base/lazy-instance.h"
#include "src/base/win32-headers.h"
#endif
......@@ -619,15 +621,10 @@ using TimeTicksNowFunction = decltype(&TimeTicks::Now);
TimeTicksNowFunction g_time_ticks_now_function = &InitialTimeTicksNowFunction;
int64_t g_qpc_ticks_per_second = 0;
// As of January 2015, use of <atomic> is forbidden in Chromium code. This is
// what std::atomic_thread_fence does on Windows on all Intel architectures when
// the memory_order argument is anything but std::memory_order_seq_cst:
#define ATOMIC_THREAD_FENCE(memory_order) _ReadWriteBarrier();
TimeDelta QPCValueToTimeDelta(LONGLONG qpc_value) {
// Ensure that the assignment to |g_qpc_ticks_per_second|, made in
// InitializeNowFunctionPointer(), has happened by this point.
ATOMIC_THREAD_FENCE(memory_order_acquire);
std::atomic_thread_fence(std::memory_order_acquire);
DCHECK_GT(g_qpc_ticks_per_second, 0);
......@@ -682,7 +679,7 @@ void InitializeTimeTicksNowFunctionPointer() {
// assignment to |g_qpc_ticks_per_second| happens before the function pointers
// are changed.
g_qpc_ticks_per_second = ticks_per_sec.QuadPart;
ATOMIC_THREAD_FENCE(memory_order_release);
std::atomic_thread_fence(std::memory_order_release);
g_time_ticks_now_function = now_function;
}
......@@ -691,8 +688,6 @@ TimeTicks InitialTimeTicksNowFunction() {
return g_time_ticks_now_function();
}
#undef ATOMIC_THREAD_FENCE
} // namespace
// static
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment