Commit 40daf5b1 authored by Ilya Rezvov's avatar Ilya Rezvov Committed by V8 LUCI CQ

[wasm-atomics] Prevent atomic load operation to be optimized out

Bug: chromium:1339276
Change-Id: Ice60167660fa52e84c78bb0bd9d2a2c85e0c377a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3733027Reviewed-by: 's avatarDeepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Ilya Rezvov <irezvov@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81478}
parent 0d6e95b4
......@@ -1073,7 +1073,7 @@ struct MachineOperatorGlobalCache {
: public Operator1<AtomicLoadParameters> { \
Word32SeqCstLoad##Type##Kind##Operator() \
: Operator1<AtomicLoadParameters>( \
IrOpcode::kWord32AtomicLoad, Operator::kEliminatable, \
IrOpcode::kWord32AtomicLoad, Operator::kNoProperties, \
"Word32AtomicLoad", 2, 1, 1, 1, 1, 0, \
AtomicLoadParameters(MachineType::Type(), \
AtomicMemoryOrder::kSeqCst, \
......@@ -1092,7 +1092,7 @@ struct MachineOperatorGlobalCache {
: public Operator1<AtomicLoadParameters> { \
Word64SeqCstLoad##Type##Kind##Operator() \
: Operator1<AtomicLoadParameters>( \
IrOpcode::kWord64AtomicLoad, Operator::kEliminatable, \
IrOpcode::kWord64AtomicLoad, Operator::kNoProperties, \
"Word64AtomicLoad", 2, 1, 1, 1, 1, 0, \
AtomicLoadParameters(MachineType::Type(), \
AtomicMemoryOrder::kSeqCst, \
......@@ -1699,7 +1699,7 @@ const Operator* MachineOperatorBuilder::Word32AtomicLoad(
#define LOAD(Type) \
if (params.representation() == MachineType::Type()) { \
return zone_->New<Operator1<AtomicLoadParameters>>( \
IrOpcode::kWord32AtomicLoad, Operator::kEliminatable, \
IrOpcode::kWord32AtomicLoad, Operator::kNoProperties, \
"Word32AtomicLoad", 2, 1, 1, 1, 1, 0, params); \
}
ATOMIC_TYPE_LIST(LOAD)
......@@ -1826,7 +1826,7 @@ const Operator* MachineOperatorBuilder::Word64AtomicLoad(
#define LOAD(Type) \
if (params.representation() == MachineType::Type()) { \
return zone_->New<Operator1<AtomicLoadParameters>>( \
IrOpcode::kWord64AtomicLoad, Operator::kEliminatable, \
IrOpcode::kWord64AtomicLoad, Operator::kNoProperties, \
"Word64AtomicLoad", 2, 1, 1, 1, 1, 0, params); \
}
ATOMIC_U64_TYPE_LIST(LOAD)
......
......@@ -412,6 +412,18 @@ WASM_EXEC_TEST(I64AtomicStore_trap) {
CHECK_TRAP(r.Call());
}
WASM_EXEC_TEST(I32AtomicLoad_NotOptOut) {
EXPERIMENTAL_FLAG_SCOPE(threads);
WasmRunner<uint32_t> r(execution_tier);
r.builder().SetHasSharedMemory();
r.builder().AddMemory(kWasmPageSize);
BUILD(r, WASM_I32_AND(
WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad, WASM_I32V_3(kWasmPageSize),
MachineRepresentation::kWord32),
WASM_ZERO));
CHECK_TRAP(r.Call());
}
} // namespace test_run_wasm_atomics
} // namespace wasm
} // namespace internal
......
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