Commit 368945e4 authored by Shu-yu Guo's avatar Shu-yu Guo Committed by V8 LUCI CQ

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: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78268}
parent d6c01d5f
...@@ -11,6 +11,23 @@ ...@@ -11,6 +11,23 @@
// other hyper-thread on this core. See the following for context: // other hyper-thread on this core. See the following for context:
// https://software.intel.com/en-us/articles/benefitting-power-and-performance-sleep-loops // 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) #if defined(V8_HOST_ARCH_IA32) || defined(V8_HOST_ARCH_X64)
#define YIELD_PROCESSOR __asm__ __volatile__("pause") #define YIELD_PROCESSOR __asm__ __volatile__("pause")
#elif defined(V8_HOST_ARCH_ARM64) || \ #elif defined(V8_HOST_ARCH_ARM64) || \
...@@ -29,6 +46,8 @@ ...@@ -29,6 +46,8 @@
#define YIELD_PROCESSOR __asm__ __volatile__("or 31,31,31") #define YIELD_PROCESSOR __asm__ __volatile__("or 31,31,31")
#endif // V8_HOST_ARCH #endif // V8_HOST_ARCH
#endif // V8_CC_MSVC
#ifndef YIELD_PROCESSOR #ifndef YIELD_PROCESSOR
#define YIELD_PROCESSOR ((void)0) #define YIELD_PROCESSOR ((void)0)
#endif #endif
......
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