Make YIELD_PROCESSOR work on MSVC
MSVC disallows inline assembly on x64 and arm64, and instead requires use of compiler intrinsics [0]. This CL checks for MSVC and uses intrinsics for yield/pause, where available. [0] https://docs.microsoft.com/en-us/cpp/intrinsics/compiler-intrinsics?view=msvc-170 Cq-Include-Trybots: luci.v8.try:v8_win64_msvc_rel_ng Change-Id: I3b9cbd998e91b391a21f1443e83758e7242425c4 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3318721 Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Auto-Submit: Shu-yu Guo <syg@chromium.org> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/main@{#78268}
This commit is contained in:
parent
d6c01d5f48
commit
368945e4a6
@ -11,6 +11,23 @@
|
||||
// other hyper-thread on this core. See the following for context:
|
||||
// https://software.intel.com/en-us/articles/benefitting-power-and-performance-sleep-loops
|
||||
|
||||
#if defined(V8_CC_MSVC)
|
||||
// MSVC does not support inline assembly via __asm__ and provides compiler
|
||||
// intrinsics instead. Check if there is a usable intrinsic.
|
||||
//
|
||||
// intrin.h is an expensive header, so only include it if we're on a host
|
||||
// architecture that has a usable intrinsic.
|
||||
#if defined(V8_HOST_ARCH_IA32) || defined(V8_HOST_ARCH_X64)
|
||||
#include <intrin.h>
|
||||
#define YIELD_PROCESSOR _mm_pause()
|
||||
#elif defined(V8_HOST_ARCH_ARM64) || \
|
||||
(defined(V8_HOST_ARCH_ARM) && __ARM_ARCH >= 6)
|
||||
#include <intrin.h>
|
||||
#define YIELD_PROCESSOR __yield()
|
||||
#endif // V8_HOST_ARCH
|
||||
|
||||
#else // !V8_CC_MSVC
|
||||
|
||||
#if defined(V8_HOST_ARCH_IA32) || defined(V8_HOST_ARCH_X64)
|
||||
#define YIELD_PROCESSOR __asm__ __volatile__("pause")
|
||||
#elif defined(V8_HOST_ARCH_ARM64) || \
|
||||
@ -29,6 +46,8 @@
|
||||
#define YIELD_PROCESSOR __asm__ __volatile__("or 31,31,31")
|
||||
#endif // V8_HOST_ARCH
|
||||
|
||||
#endif // V8_CC_MSVC
|
||||
|
||||
#ifndef YIELD_PROCESSOR
|
||||
#define YIELD_PROCESSOR ((void)0)
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user