Commit b9c3d26b authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

Increase bytecode_age with relaxed operation

Release operation uses more expensive operations on some architectures.

Change-Id: Iab84d92c84c791d429b6635641daadb2d608f791
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2276039Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68622}
parent c0e24791
......@@ -65,6 +65,8 @@ using AtomicWord = intptr_t;
// I.e. replace |*ptr| with |new_value| if |*ptr| used to be |old_value|.
// Always return the value of |*ptr| before the operation.
// Acquire, Relaxed, Release correspond to standard C++ memory orders.
Atomic8 Relaxed_CompareAndSwap(volatile Atomic8* ptr, Atomic8 old_value,
Atomic8 new_value);
Atomic16 Relaxed_CompareAndSwap(volatile Atomic16* ptr, Atomic16 old_value,
Atomic16 new_value);
Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value,
......
......@@ -50,6 +50,14 @@ inline void SeqCst_MemoryFence() {
#endif
}
inline Atomic8 Relaxed_CompareAndSwap(volatile Atomic8* ptr, Atomic8 old_value,
Atomic8 new_value) {
bool result = __atomic_compare_exchange_n(ptr, &old_value, new_value, false,
__ATOMIC_RELAXED, __ATOMIC_RELAXED);
USE(result); // Make gcc compiler happy.
return old_value;
}
inline Atomic16 Relaxed_CompareAndSwap(volatile Atomic16* ptr,
Atomic16 old_value, Atomic16 new_value) {
__atomic_compare_exchange_n(ptr, &old_value, new_value, false,
......
......@@ -28,6 +28,14 @@ inline void SeqCst_MemoryFence() {
std::atomic_thread_fence(std::memory_order_seq_cst);
}
inline Atomic8 Relaxed_CompareAndSwap(volatile Atomic8* ptr, Atomic8 old_value,
Atomic8 new_value) {
std::atomic_compare_exchange_strong_explicit(
helper::to_std_atomic(ptr), &old_value, new_value,
std::memory_order_relaxed, std::memory_order_relaxed);
return old_value;
}
inline Atomic16 Relaxed_CompareAndSwap(volatile Atomic16* ptr,
Atomic16 old_value, Atomic16 new_value) {
std::atomic_compare_exchange_strong_explicit(
......
......@@ -841,8 +841,8 @@ void BytecodeArray::MakeOlder() {
DCHECK_LE(RoundDown(age_addr, kTaggedSize) + kTaggedSize, address() + Size());
Age age = bytecode_age();
if (age < kLastBytecodeAge) {
base::AsAtomic8::Release_CompareAndSwap(reinterpret_cast<byte*>(age_addr),
age, age + 1);
base::AsAtomic8::Relaxed_CompareAndSwap(
reinterpret_cast<base::Atomic8*>(age_addr), age, age + 1);
}
DCHECK_GE(bytecode_age(), kFirstBytecodeAge);
......
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