Commit a7fcaa5a authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[base][atomic] Remove specialization for AtomicWord

AtomicWord will either alias Atomic32 or Atomic64, depending on the
platform. By slightly changing the definition to encode this directly
instead of relying on intptr_t, we can get rid of a number of
compatibility helpers that cast between pointers to equally sized
atomics.

R=mlippautz@chromium.org

Bug: v8:12425
Change-Id: I04e8433cba5af8cf398d75d7832b84680109cf8b
Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3586988Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80017}
parent 4b0737d2
......@@ -579,7 +579,6 @@ filegroup(
"src/base/address-region.h",
"src/base/atomic-utils.h",
"src/base/atomicops.h",
"src/base/atomicops_internals_atomicword_compat.h",
"src/base/base-export.h",
"src/base/bit-field.h",
"src/base/bits-iterator.h",
......
......@@ -5104,7 +5104,6 @@ v8_component("v8_libbase") {
"src/base/address-region.h",
"src/base/atomic-utils.h",
"src/base/atomicops.h",
"src/base/atomicops_internals_atomicword_compat.h",
"src/base/base-export.h",
"src/base/bit-field.h",
"src/base/bits-iterator.h",
......
......@@ -68,13 +68,14 @@ using Atomic64 = intptr_t;
#endif // defined(V8_HOST_ARCH_64_BIT)
#endif // V8_OS_STARBOARD
// Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or
// Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or
// Atomic64 routines below, depending on your architecture.
#if defined(V8_OS_STARBOARD)
using AtomicWord = SbAtomicPtr;
#if defined(V8_HOST_ARCH_64_BIT)
using AtomicWord = Atomic64;
#else
using AtomicWord = intptr_t;
using AtomicWord = Atomic32;
#endif
STATIC_ASSERT(sizeof(void*) == sizeof(AtomicWord));
namespace helper {
template <typename T>
......@@ -466,10 +467,4 @@ inline int Relaxed_Memcmp(volatile const Atomic8* s1,
} // namespace base
} // namespace v8
// On some platforms we need additional declarations to make
// AtomicWord compatible with our other Atomic* types.
#if defined(V8_OS_DARWIN) || defined(V8_OS_OPENBSD) || defined(V8_OS_AIX)
#include "src/base/atomicops_internals_atomicword_compat.h"
#endif
#endif // V8_BASE_ATOMICOPS_H_
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is an internal atomic implementation, use atomicops.h instead.
#ifndef V8_BASE_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_
#define V8_BASE_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_
// AtomicWord is a synonym for intptr_t, and Atomic32 is a synonym for int32,
// which in turn means int. On some LP32 platforms, intptr_t is an int, but
// on others, it's a long. When AtomicWord and Atomic32 are based on different
// fundamental types, their pointers are incompatible.
//
// This file defines function overloads to allow both AtomicWord and Atomic32
// data to be used with this interface.
//
// On LP64 platforms, AtomicWord and Atomic64 are both always long,
// so this problem doesn't occur.
#if !defined(V8_HOST_ARCH_64_BIT)
namespace v8 {
namespace base {
inline AtomicWord Relaxed_CompareAndSwap(volatile AtomicWord* ptr,
AtomicWord old_value,
AtomicWord new_value) {
return Relaxed_CompareAndSwap(reinterpret_cast<volatile Atomic32*>(ptr),
old_value, new_value);
}
inline AtomicWord Relaxed_AtomicExchange(volatile AtomicWord* ptr,
AtomicWord new_value) {
return Relaxed_AtomicExchange(reinterpret_cast<volatile Atomic32*>(ptr),
new_value);
}
inline AtomicWord Relaxed_AtomicIncrement(volatile AtomicWord* ptr,
AtomicWord increment) {
return Relaxed_AtomicIncrement(reinterpret_cast<volatile Atomic32*>(ptr),
increment);
}
inline AtomicWord Acquire_CompareAndSwap(volatile AtomicWord* ptr,
AtomicWord old_value,
AtomicWord new_value) {
return v8::base::Acquire_CompareAndSwap(
reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
}
inline AtomicWord Release_CompareAndSwap(volatile AtomicWord* ptr,
AtomicWord old_value,
AtomicWord new_value) {
return v8::base::Release_CompareAndSwap(
reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
}
inline AtomicWord AcquireRelease_CompareAndSwap(volatile AtomicWord* ptr,
AtomicWord old_value,
AtomicWord new_value) {
return v8::base::AcquireRelease_CompareAndSwap(
reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
}
inline void Relaxed_Store(volatile AtomicWord* ptr, AtomicWord value) {
Relaxed_Store(reinterpret_cast<volatile Atomic32*>(ptr), value);
}
inline void Release_Store(volatile AtomicWord* ptr, AtomicWord value) {
return v8::base::Release_Store(
reinterpret_cast<volatile Atomic32*>(ptr), value);
}
inline AtomicWord Relaxed_Load(volatile const AtomicWord* ptr) {
return Relaxed_Load(reinterpret_cast<volatile const Atomic32*>(ptr));
}
inline AtomicWord Acquire_Load(volatile const AtomicWord* ptr) {
return v8::base::Acquire_Load(
reinterpret_cast<volatile const Atomic32*>(ptr));
}
} // namespace base
} // namespace v8
#endif // !defined(V8_HOST_ARCH_64_BIT)
#endif // V8_BASE_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_
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