Commit ec3616eb authored by Shu-yu Guo's avatar Shu-yu Guo Committed by Commit Bot

[atomics] Make Atomics.isLockFree return true for all sizes

Bug: v8:10293
Change-Id: If585e7860721cb2de37a0de5bf135e7a4e226190
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2081338
Auto-Submit: Shu-yu Guo <syg@chromium.org>
Reviewed-by: 's avatarBen Smith <binji@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66555}
parent 435cbf2d
...@@ -25,20 +25,18 @@ namespace internal { ...@@ -25,20 +25,18 @@ namespace internal {
// #sec-atomics.islockfree // #sec-atomics.islockfree
inline bool AtomicIsLockFree(double size) { inline bool AtomicIsLockFree(double size) {
// According to the standard, 1, 2, and 4 byte atomics are supposed to be // According to the standard, 1, 2, and 4 byte atomics are supposed to be
// 'lock free' on every platform. But what exactly does 'lock free' mean? // 'lock free' on every platform. 'Lock free' means that all possible uses of
// For example, on x64 V8 uses a lock prefix to implement the semantics of // those atomics guarantee forward progress for the agent cluster (i.e. all
// many atomic operations. Is that considered a lock? Probably not. // threads in contrast with a single thread).
// //
// On the other hand, V8 emits a few instructions for some arm atomics which // This property is often, but not always, aligned with whether atomic
// do appear to be a low level form of a spin lock. With an abundance of // accesses are implemented with software locks such as mutexes.
// caution, we only claim to have 'true lock free' support for 8 byte sizes //
// on x64 platforms. If people care about this function returning true, then // V8 has lock free atomics for all sizes on all supported first-class
// we need to clarify exactly what 'lock free' means at the standard level. // architectures: ia32, x64, ARM32 variants, and ARM64. Further, this property
bool is_lock_free = size == 1 || size == 2 || size == 4; // is depended upon by WebAssembly, which prescribes that all atomic accesses
#if V8_TARGET_ARCH_x64 // are always lock free.
is_lock_free |= size == 8; return size == 1 || size == 2 || size == 4 || size == 8;
#endif
return is_lock_free;
} }
// ES #sec-atomics.islockfree // ES #sec-atomics.islockfree
......
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