Skip to content

Commit 6ab0aeb

Browse files
committed
WTF::Atomics should model supported hardware
https://bugs.webkit.org/show_bug.cgi?id=328577 rdar://190772091 Reviewed by Marcus Plutowski and Dan Hecht. Replace the runtime `std::memory_order` parameter on `WTF::Atomic` and the free-standing `atomic*` functions with a compile-time `WTF::MemoryOrder` template parameter that explicitly documents and exposes the stronger hardware guarantees WebKit relies on (multi-copy atomicity on ARM64 and x86_64, and full-fence read-modify-writes). This helps clarify what people can actually rely on for hardware WebKit officially supports. Additionally, I believe this model can also be made to work for RISCV and MIPS efficiently. At least to the extent that MIPS has high performance atomics. In the C++ memory model, a `memory_order_seq_cst` read-modify-write does not prevent earlier non-`seq_cst` stores from reordering past later non-`seq_cst` loads, so Dekker-style protocols normally require a separate `storeLoadFence()` (`dmb ish` on ARM64). On x86_64 (`lock`-prefixed instructions) and ARM64 with LSE (`ldaddal`, `ldsetal`, `ldclral`, `swpal`, `casal`), a successful `seq_cst` RMW is already a full barrier in hardware. Add `MemoryOrder::FullyFenced` for read-modify-writes to express this guarantee directly: it lowers to a single `seq_cst` RMW on x86 and ARM64+LSE, and appends a `seq_cst` thread fence only on LL/SC targets. Passing invalid load/store/failure orders is now rejected at compile time via `static_assert`. Also, add `Atomic<T>::loadAndFence(T&)` to pair a relaxed load with a `Dependency` (falling back to an `Acquire` load under TSan, which does not model address dependencies), and use it where callers previously relied on raw `loadRelaxed()` assuming implicit hardware dependency ordering without hiding the dependency from the compiler. Tests: Tools/TestWebKitAPI/Tests/WTF/ReadWriteLock.cpp Tools/TestWebKitAPI/Tests/WTF/VersionedField.cpp * Source/JavaScriptCore/heap/BlockDirectory.cpp: (JSC::BlockDirectory::releaseAndNoteIfStealable): (JSC::BlockDirectory::findEmptyBlockToSteal): Replace the explicit `WTF::storeLoadFence()` calls in the empty-block stealing protocol with `releaseInUse<MemoryOrder::FullyFenced>()` and `m_emptyCursor.watch<MemoryOrder::FullyFenced>()`. Also avoid the `FullyFenced` RMW in `releaseAndNoteIfStealable()` when the block isn't stealable. * Source/JavaScriptCore/heap/BlockDirectory.h: (JSC::BlockDirectory::releaseInUse): Parameterize `releaseInUse` on `MemoryOrder` (defaulting to `Release`) so `releaseAndNoteIfStealable()` can request `FullyFenced`. * Source/WTF/wtf/Atomics.h: (WTF::Atomic<T>::loadAndFence const): (WTF::ensurePointer): Use `loadAndFence` + `Dependency::consume` on the fast path and `Dependency::fence` on the CAS-failure path so loads through the returned pointer have a true address dependency preserved across compiler optimizations. * Source/WTF/wtf/FastBitVector.h: (WTF::FastBitReference::concurrentGet const): (WTF::FastBitReference::concurrentSet): (WTF::FastBitReference::concurrentTestAndSet): (WTF::FastBitReference::concurrentTestAndClear): Template the concurrent bit operations on `MemoryOrder`. * Source/WTF/wtf/ThreadSafeLazyUniquePtr.h: (WTF::ThreadSafeLazyUniquePtr::ensure const): (WTF::ThreadSafeLazyUniquePtr::get const): Use `loadAndFence` + `Dependency::consume` in `ensure()` and `get()` (and `Dependency::fence` when losing the installation race) instead of relying on an unfenced relaxed load. * Source/WTF/wtf/ThreadSafeWeakPtr.h: (WTF::ThreadSafeRefCountedAndCanMakeThreadSafeWeakPtr::bits const): Use `m_bits.loadAndFence()` in `bits()` so loads through the control block carry an explicit address dependency on the load of `m_bits` (and automatically use `Acquire` under TSan). * Source/WTF/wtf/VersionedField.h: (WTF::VersionedField::watch): Template operations on `MemoryOrder`. In `watch<MemoryOrder::FullyFenced>()`, the initial load when checking whether the watched bit is already set uses `MemoryOrder::Acquire` while the `exchangeOr` that sets the bit uses `MemoryOrder::FullyFenced`; by multi-copy atomicity, observing an already-watched value published by an earlier `FullyFenced` watch orders the reader after everything ordered by that watch's fence. Canonical link: https://commits.webkit.org/324977@main
1 parent cc81805 commit 6ab0aeb

28 files changed

Lines changed: 668 additions & 395 deletions

‎Source/JavaScriptCore/assembler/AssemblerCommon.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2012-2023 Apple Inc. All rights reserved.
2+
* Copyright (C) 2012-2023, 2026 Apple Inc. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -670,16 +670,16 @@ ALWAYS_INLINE void* memcpyAtomic(void* dst, const void* src, size_t n)
670670
ASSERT(isPowerOfTwo(n) && WTF::isAligned(WTF::opaque(dst), n));
671671
switch (n) {
672672
case 1:
673-
WTF::atomicStore(std::bit_cast<uint8_t*>(dst), *std::bit_cast<const uint8_t*>(src), std::memory_order_relaxed);
673+
WTF::atomicStore<MemoryOrder::Relaxed>(std::bit_cast<uint8_t*>(dst), *std::bit_cast<const uint8_t*>(src));
674674
return dst;
675675
case 2:
676-
WTF::atomicStore(std::bit_cast<uint16_t*>(dst), *std::bit_cast<const uint16_t*>(src), std::memory_order_relaxed);
676+
WTF::atomicStore<MemoryOrder::Relaxed>(std::bit_cast<uint16_t*>(dst), *std::bit_cast<const uint16_t*>(src));
677677
return dst;
678678
case 4:
679-
WTF::atomicStore(std::bit_cast<uint32_t*>(dst), *std::bit_cast<const uint32_t*>(src), std::memory_order_relaxed);
679+
WTF::atomicStore<MemoryOrder::Relaxed>(std::bit_cast<uint32_t*>(dst), *std::bit_cast<const uint32_t*>(src));
680680
return dst;
681681
case 8:
682-
WTF::atomicStore(std::bit_cast<uint64_t*>(dst), *std::bit_cast<const uint64_t*>(src), std::memory_order_relaxed);
682+
WTF::atomicStore<MemoryOrder::Relaxed>(std::bit_cast<uint64_t*>(dst), *std::bit_cast<const uint64_t*>(src));
683683
return dst;
684684
default:
685685
break;

‎Source/JavaScriptCore/assembler/SecureARM64EHashPins.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2022 Apple Inc. All rights reserved.
2+
* Copyright (C) 2022, 2026 Apple Inc. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -51,13 +51,13 @@ struct ValidateNonReentrancyScope {
5151
ALWAYS_INLINE ValidateNonReentrancyScope(SecureARM64EHashPins::Metadata* metadata)
5252
: m_metadata(metadata)
5353
{
54-
uint32_t validateNonReentrancy = m_metadata->assertNotReentrant.exchange(1, std::memory_order_seq_cst);
54+
uint32_t validateNonReentrancy = m_metadata->assertNotReentrant.exchange<MemoryOrder::SeqCst>(1);
5555
RELEASE_ASSERT(!validateNonReentrancy);
5656
}
5757

5858
ALWAYS_INLINE ~ValidateNonReentrancyScope()
5959
{
60-
uint32_t validateNonReentrancy = m_metadata->assertNotReentrant.exchange(0, std::memory_order_seq_cst);
60+
uint32_t validateNonReentrancy = m_metadata->assertNotReentrant.exchange<MemoryOrder::SeqCst>(0);
6161
RELEASE_ASSERT(validateNonReentrancy == 1);
6262
}
6363
SecureARM64EHashPins::Metadata* m_metadata;
@@ -160,7 +160,7 @@ bool SecureARM64EHashPins::allocatePinForCurrentThreadImpl(const AbstractLocker&
160160
ValidateNonReentrancyScope validateNonReentrancy(metadata);
161161

162162
RELEASE_ASSERT(isJITPC(metadata));
163-
uint64_t nextPin = metadata->nextPin.exchangeAdd(1, std::memory_order_seq_cst);
163+
uint64_t nextPin = metadata->nextPin.exchangeAdd<MemoryOrder::SeqCst>(1);
164164
RELEASE_ASSERT(nextPin);
165165

166166
newEntryPage->setIsInUse(newEntryIndex);

‎Source/JavaScriptCore/heap/BlockDirectory.cpp‎

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,16 @@ void BlockDirectory::releaseAndNoteIfStealable(unsigned index)
7171
// Read while the block is still ours; once it is released these bits could be modified by whoever claims it next.
7272
bool stealable = isStealable(index);
7373
// Must stay the last bit written for this block; see the comment above m_bits.
74-
releaseInUse(index);
75-
if (!stealable)
74+
if (!stealable) {
75+
releaseInUse(index);
7676
return;
77+
}
78+
// Pairs with the FullyFenced watch() in findEmptyBlockToSteal(): either the stealer's scan sees our
79+
// release, or our minimize() sees their watch and fails their publish.
80+
releaseInUse<MemoryOrder::FullyFenced>(index);
7781
// The cursor normally only moves forward; rewind it so stealers can see this block.
78-
// Pairs with the fence in findEmptyBlockToSteal(): either the stealer's scan sees our release, or our
79-
// minimize() sees their watch and fails their publish.
80-
WTF::storeLoadFence();
8182
// FIXME: If we move the allocation cursor into the directory we should reset it here too.
82-
m_emptyCursor.minimize(index, std::memory_order_relaxed);
83+
m_emptyCursor.minimize<MemoryOrder::Relaxed>(index);
8384
subspace()->alignedMemoryAllocator()->addDirectoryWithEmptyBlocks(this);
8485
}
8586

@@ -89,18 +90,11 @@ MarkedBlock::Handle* BlockDirectory::findEmptyBlockToSteal()
8990
// A block that becomes stealable behind us while we search rewinds the cursor, and publishing our
9091
// result over that would hide the block until prepareForAllocation(). Watching the cursor makes the
9192
// publish fail instead.
92-
auto watched = m_emptyCursor.watch(std::memory_order_relaxed);
93-
// Pairs with the fence in releaseAndNoteIfStealable(): either our scan sees a block released after the
94-
// watch, or that releaser's minimize() sees the watch and fails our publish.
95-
// FIXME: We could make this not have a storeLoadFence (on X86_64 and ARM64 with LSE) by having:
96-
// 1) watch do a seq_cst load/exchangeOr
97-
// 2) releaseAndNoteIfStealable do a seq_cst releaseInUse and minimize (including the transaction's load).
98-
// This is probably faster on Apple Silicon.
99-
WTF::storeLoadFence();
93+
auto watched = m_emptyCursor.watch<MemoryOrder::FullyFenced>();
10094
for (unsigned cursor = watched.value;; ++cursor) {
10195
cursor = (stealableBits() & ~inUseBitsView()).findBit(cursor, true);
10296
if (cursor >= m_blocks.size()) {
103-
m_emptyCursor.tryUpdateWatched(watched, cursor, std::memory_order_relaxed);
97+
m_emptyCursor.tryUpdateWatched<MemoryOrder::Relaxed>(watched, cursor);
10498
return nullptr;
10599
}
106100
if (!claimInUse(cursor))
@@ -110,7 +104,7 @@ MarkedBlock::Handle* BlockDirectory::findEmptyBlockToSteal()
110104
// Recheck under the claim; see claimInUse().
111105
if (isStealable(cursor)) [[likely]] {
112106
dataLogLnIf(BlockDirectoryInternal::verbose, "Setting block ", cursor, " in use (findEmptyBlockToSteal) for ", *this);
113-
m_emptyCursor.tryUpdateWatched(watched, cursor, std::memory_order_relaxed);
107+
m_emptyCursor.tryUpdateWatched<MemoryOrder::Relaxed>(watched, cursor);
114108
return m_blocks[cursor].first;
115109
}
116110
releaseInUse(cursor);
@@ -254,8 +248,8 @@ void BlockDirectory::prepareForAllocation()
254248
allocator->prepareForAllocation();
255249
});
256250

257-
m_unsweptCursor.set(0, std::memory_order_relaxed);
258-
m_emptyCursor.set(0, std::memory_order_relaxed);
251+
m_unsweptCursor.set<MemoryOrder::Relaxed>(0);
252+
m_emptyCursor.set<MemoryOrder::Relaxed>(0);
259253

260254
assertWorldIsStopped();
261255
// endMarking recomputes the empty bits wholesale rather than block by block, so none of the blocks

‎Source/JavaScriptCore/heap/BlockDirectory.h‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ class BlockDirectory {
132132
#define BLOCK_DIRECTORY_BIT_OWNERSHIP_BlockOwned WTF_REQUIRES_LOCK(m_blockOwnership)
133133
#define BLOCK_DIRECTORY_BIT_OWNERSHIP_Unowned
134134
#define BLOCK_DIRECTORY_BIT_ACCESSORS(lowerBitName, capitalBitName, ownership) \
135-
bool is ## capitalBitName(size_t index) const WTF_REQUIRES_SHARED_LOCK(m_bitvectorLock) { return m_bits.bit<BlockDirectoryBits::Kind::capitalBitName>(index).concurrentGet(std::memory_order_relaxed); } \
135+
bool is ## capitalBitName(size_t index) const WTF_REQUIRES_SHARED_LOCK(m_bitvectorLock) { return m_bits.bit<BlockDirectoryBits::Kind::capitalBitName>(index).concurrentGet<MemoryOrder::Relaxed>(); } \
136136
bool is ## capitalBitName(MarkedBlock::Handle* block) const WTF_REQUIRES_SHARED_LOCK(m_bitvectorLock) { return is ## capitalBitName(block->index()); } \
137137
BlockDirectoryBits::BlockDirectoryBitVectorView<BlockDirectoryBits::Kind::capitalBitName> lowerBitName ## BitsView() const WTF_REQUIRES_SHARED_LOCK(m_bitvectorLock) { return m_bits.lowerBitName(); } \
138138
\
139-
void setIs ## capitalBitName(size_t index, bool value) WTF_REQUIRES_SHARED_LOCK(m_bitvectorLock) BLOCK_DIRECTORY_BIT_OWNERSHIP_ ## ownership { m_bits.bit<BlockDirectoryBits::Kind::capitalBitName>(index).concurrentSet(value, std::memory_order_relaxed); } \
139+
void setIs ## capitalBitName(size_t index, bool value) WTF_REQUIRES_SHARED_LOCK(m_bitvectorLock) BLOCK_DIRECTORY_BIT_OWNERSHIP_ ## ownership { m_bits.bit<BlockDirectoryBits::Kind::capitalBitName>(index).concurrentSet<MemoryOrder::Relaxed>(value); } \
140140
void setIs ## capitalBitName(MarkedBlock::Handle* block, bool value) WTF_REQUIRES_SHARED_LOCK(m_bitvectorLock) BLOCK_DIRECTORY_BIT_OWNERSHIP_ ## ownership { setIs ## capitalBitName(block->index(), value); } \
141-
bool testAndClearIs ## capitalBitName(size_t index) WTF_REQUIRES_SHARED_LOCK(m_bitvectorLock) BLOCK_DIRECTORY_BIT_OWNERSHIP_ ## ownership { return m_bits.bit<BlockDirectoryBits::Kind::capitalBitName>(index).concurrentTestAndClear(std::memory_order_relaxed); } \
141+
bool testAndClearIs ## capitalBitName(size_t index) WTF_REQUIRES_SHARED_LOCK(m_bitvectorLock) BLOCK_DIRECTORY_BIT_OWNERSHIP_ ## ownership { return m_bits.bit<BlockDirectoryBits::Kind::capitalBitName>(index).concurrentTestAndClear<MemoryOrder::Relaxed>(); } \
142142
BlockDirectoryBits::BlockDirectoryBitVectorRef<BlockDirectoryBits::Kind::capitalBitName> lowerBitName ## Bits() WTF_REQUIRES_LOCK(m_bitvectorLock) { return m_bits.lowerBitName(); }
143143

144144
FOR_EACH_BLOCK_DIRECTORY_BIT(BLOCK_DIRECTORY_BIT_ACCESSORS)
@@ -150,7 +150,7 @@ class BlockDirectory {
150150
// Callers that pick a block by scanning the bits must recheck those bits after this returns true.
151151
[[nodiscard]] bool claimInUse(size_t index) WTF_REQUIRES_SHARED_LOCK(m_bitvectorLock)
152152
{
153-
return !m_bits.bit<BlockDirectoryBits::Kind::InUse>(index).concurrentTestAndSet(std::memory_order_acquire);
153+
return !m_bits.bit<BlockDirectoryBits::Kind::InUse>(index).concurrentTestAndSet<MemoryOrder::Acquire>();
154154
}
155155

156156
void claimInUseOrCrash(size_t index) WTF_REQUIRES_SHARED_LOCK(m_bitvectorLock) WTF_ASSERTS_ACQUIRED_CAPABILITY(m_blockOwnership)
@@ -159,9 +159,10 @@ class BlockDirectory {
159159
RELEASE_ASSERT(claimed);
160160
}
161161

162+
template<MemoryOrder order = MemoryOrder::Release>
162163
void releaseInUse(size_t index) WTF_REQUIRES_SHARED_LOCK(m_bitvectorLock)
163164
{
164-
m_bits.bit<BlockDirectoryBits::Kind::InUse>(index).concurrentSet(false, std::memory_order_release);
165+
m_bits.bit<BlockDirectoryBits::Kind::InUse>(index).concurrentSet<order>(false);
165166
}
166167

167168
// A destructible block still owes its old owner a destructor pass over every one of its cells,

‎Source/JavaScriptCore/heap/BlockDirectoryInlines.h‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,10 @@ inline void BlockDirectory::forEachNotEmptyBlock(NOESCAPE const std::invocable<M
5151

5252
inline MarkedBlock::Handle* BlockDirectory::findBlockToSweep()
5353
{
54-
auto watched = m_unsweptCursor.watch(std::memory_order_relaxed);
55-
// Order the watch before the scan, so a writer that rewinds the cursor after changing the bits either
56-
// sees the watch or has its change seen by the scan; see VersionedField.
57-
WTF::storeLoadFence();
54+
auto watched = m_unsweptCursor.watch<MemoryOrder::FullyFenced>();
5855
unsigned cursor = watched.value;
5956
MarkedBlock::Handle* block = findBlockToSweep(cursor);
60-
m_unsweptCursor.tryUpdateWatched(watched, cursor, std::memory_order_relaxed);
57+
m_unsweptCursor.tryUpdateWatched<MemoryOrder::Relaxed>(watched, cursor);
6158
return block;
6259
}
6360

‎Source/JavaScriptCore/heap/Heap.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ void Heap::beginMarking()
811811
TimingScope timingScope(*this, "Heap::beginMarking"_s);
812812
ASSERT(isInPhase(CollectorPhase::Begin));
813813
ASSERT(m_collectionScope);
814-
ASSERT(!m_bytesMarkedThisCycle.load(std::memory_order_relaxed));
814+
ASSERT(!m_bytesMarkedThisCycle.load<MemoryOrder::Relaxed>());
815815
if (*m_collectionScope == CollectionScope::Full)
816816
m_mutatorMarkStack->clear();
817817
m_jitStubRoutines->clearMarks();
@@ -910,7 +910,7 @@ void Heap::endMarking()
910910
ASSERT(isInPhase(CollectorPhase::End));
911911
ASSERT(m_objectSpace.isMarking());
912912

913-
updateOldGenerationCellBytes(m_bytesMarkedThisCycle.exchange(0, std::memory_order_relaxed));
913+
updateOldGenerationCellBytes(m_bytesMarkedThisCycle.exchange<MemoryOrder::Relaxed>(0));
914914

915915
m_objectSpace.endMarking();
916916
setMutatorShouldBeFenced(Options::forceFencedBarrier());

‎Source/JavaScriptCore/heap/Heap.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ class Heap {
423423

424424
void completeAllJITPlans();
425425

426-
void reportBytesMarked(size_t bytes) { m_bytesMarkedThisCycle.exchangeAdd(bytes, std::memory_order_relaxed); }
426+
void reportBytesMarked(size_t bytes) { m_bytesMarkedThisCycle.exchangeAdd<MemoryOrder::Relaxed>(bytes); }
427427

428428
// Note that:
429429
// 1. Use this API to report non-GC memory referenced by GC objects. Be sure to

‎Source/JavaScriptCore/heap/PreciseAllocation.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2016-2023 Apple Inc. All rights reserved.
2+
* Copyright (C) 2016-2023, 2026 Apple Inc. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -260,7 +260,7 @@ void PreciseAllocation::flip()
260260
// ^
261261
// This is ensured since this function is used only for full GC.
262262
m_isNewlyAllocated |= isMarked();
263-
m_isMarked.store(false, std::memory_order_relaxed);
263+
m_isMarked.store<MemoryOrder::Relaxed>(false);
264264
}
265265

266266
bool PreciseAllocation::isEmpty()

‎Source/JavaScriptCore/heap/PreciseAllocation.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2016-2023 Apple Inc. All rights reserved.
2+
* Copyright (C) 2016-2023, 2026 Apple Inc. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -87,7 +87,7 @@ class PreciseAllocation : public BasicRawSentinelNode<PreciseAllocation> {
8787
void LEGACY_NODELETE flip();
8888

8989
bool isNewlyAllocated() const { return m_isNewlyAllocated; }
90-
ALWAYS_INLINE bool isMarked() { return m_isMarked.load(std::memory_order_relaxed); }
90+
ALWAYS_INLINE bool isMarked() { return m_isMarked.load<MemoryOrder::Relaxed>(); }
9191
ALWAYS_INLINE bool isMarked(HeapCell*) { return isMarked(); }
9292
ALWAYS_INLINE bool isMarked(HeapCell*, Dependency) { return isMarked(); }
9393
ALWAYS_INLINE bool isMarked(HeapVersion, HeapCell*) { return isMarked(); }

‎Source/JavaScriptCore/jit/JITThunks.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2012-2023 Apple Inc. All rights reserved.
2+
* Copyright (C) 2012-2023, 2026 Apple Inc. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -246,15 +246,15 @@ MacroAssemblerCodeRef<JITThunkPtrTag> JITThunks::lazyCommonThunk(VM& vm, CommonJ
246246
{
247247
auto& thunk = m_lazyCommonThunks[static_cast<unsigned>(thunkID) - numberOfVMIndependentCommonThunkIDs - numberOfVMDependentEagerCommonThunkIDs];
248248

249-
auto state = thunk.state.load(std::memory_order_acquire);
249+
auto state = thunk.state.load<MemoryOrder::Acquire>();
250250
if (state == LazyThunkState::NotGenerated) {
251251
Locker locker { thunk.lock };
252252
state = thunk.state.loadRelaxed();
253253
if (state == LazyThunkState::NotGenerated) {
254254
thunk.codeRef = generatorForLazyCommonThunk(thunkID)(vm);
255255
ASSERT(thunk.codeRef);
256256
state = isCompilationThread() ? LazyThunkState::GeneratedOnCompilationThread : LazyThunkState::Generated;
257-
thunk.state.store(state, std::memory_order_release);
257+
thunk.state.store<MemoryOrder::Release>(state);
258258
}
259259
}
260260

@@ -266,7 +266,7 @@ MacroAssemblerCodeRef<JITThunkPtrTag> JITThunks::lazyCommonThunk(VM& vm, CommonJ
266266
// conservatively say that when the main thread grabs a thunk generated
267267
// from a compiler thread for the first time, it issues a crossModifyingCodeFence.
268268
WTF::crossModifyingCodeFence();
269-
thunk.state.store(LazyThunkState::Generated, std::memory_order_release);
269+
thunk.state.store<MemoryOrder::Release>(LazyThunkState::Generated);
270270
}
271271

272272
return thunk.codeRef;

0 commit comments

Comments
 (0)