2017-08-02 21:40:45 +00:00
|
|
|
// Copyright 2017 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.
|
|
|
|
|
2018-02-28 22:17:39 +00:00
|
|
|
#include "test/cctest/wasm/wasm-atomics-utils.h"
|
2017-08-02 21:40:45 +00:00
|
|
|
#include "test/common/wasm/wasm-macro-gen.h"
|
|
|
|
|
2017-09-01 12:57:34 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
namespace wasm {
|
2018-03-03 09:02:01 +00:00
|
|
|
namespace test_run_wasm_atomics {
|
2017-09-01 12:57:34 +00:00
|
|
|
|
2018-08-21 15:01:31 +00:00
|
|
|
void RunU32BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op,
|
2017-10-25 12:46:43 +00:00
|
|
|
Uint32BinOp expected_op) {
|
2017-08-02 21:40:45 +00:00
|
|
|
EXPERIMENTAL_FLAG_SCOPE(threads);
|
2018-08-21 15:01:31 +00:00
|
|
|
WasmRunner<uint32_t, uint32_t> r(execution_tier);
|
2018-04-27 20:00:12 +00:00
|
|
|
uint32_t* memory =
|
|
|
|
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
|
2017-09-14 06:14:48 +00:00
|
|
|
r.builder().SetHasSharedMemory();
|
2017-08-02 21:40:45 +00:00
|
|
|
|
2017-09-23 18:59:12 +00:00
|
|
|
BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_GET_LOCAL(0),
|
|
|
|
MachineRepresentation::kWord32));
|
2017-08-02 21:40:45 +00:00
|
|
|
|
|
|
|
FOR_UINT32_INPUTS(i) {
|
|
|
|
uint32_t initial = *i;
|
|
|
|
FOR_UINT32_INPUTS(j) {
|
2017-08-19 16:34:11 +00:00
|
|
|
r.builder().WriteMemory(&memory[0], initial);
|
2017-08-02 21:40:45 +00:00
|
|
|
CHECK_EQ(initial, r.Call(*j));
|
|
|
|
uint32_t expected = expected_op(*i, *j);
|
2017-08-19 16:34:11 +00:00
|
|
|
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
|
2017-08-02 21:40:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-04 01:03:03 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicAdd) {
|
2018-08-21 15:01:31 +00:00
|
|
|
RunU32BinOp(execution_tier, kExprI32AtomicAdd, Add);
|
2017-10-25 12:46:43 +00:00
|
|
|
}
|
2017-11-04 01:03:03 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicSub) {
|
2018-08-21 15:01:31 +00:00
|
|
|
RunU32BinOp(execution_tier, kExprI32AtomicSub, Sub);
|
2017-10-25 12:46:43 +00:00
|
|
|
}
|
2017-11-04 01:03:03 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicAnd) {
|
2018-08-21 15:01:31 +00:00
|
|
|
RunU32BinOp(execution_tier, kExprI32AtomicAnd, And);
|
2017-10-25 12:46:43 +00:00
|
|
|
}
|
2017-11-04 01:03:03 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicOr) {
|
2018-08-21 15:01:31 +00:00
|
|
|
RunU32BinOp(execution_tier, kExprI32AtomicOr, Or);
|
2017-10-25 12:46:43 +00:00
|
|
|
}
|
2017-11-04 01:03:03 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicXor) {
|
2018-08-21 15:01:31 +00:00
|
|
|
RunU32BinOp(execution_tier, kExprI32AtomicXor, Xor);
|
2017-10-25 12:46:43 +00:00
|
|
|
}
|
2017-11-04 01:03:03 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicExchange) {
|
2018-08-21 15:01:31 +00:00
|
|
|
RunU32BinOp(execution_tier, kExprI32AtomicExchange, Exchange);
|
2017-10-25 12:46:43 +00:00
|
|
|
}
|
2017-08-02 21:40:45 +00:00
|
|
|
|
2018-08-21 15:01:31 +00:00
|
|
|
void RunU16BinOp(ExecutionTier tier, WasmOpcode wasm_op,
|
2017-10-25 12:46:43 +00:00
|
|
|
Uint16BinOp expected_op) {
|
2017-08-02 21:40:45 +00:00
|
|
|
EXPERIMENTAL_FLAG_SCOPE(threads);
|
2018-08-21 15:01:31 +00:00
|
|
|
WasmRunner<uint32_t, uint32_t> r(tier);
|
2017-09-14 06:14:48 +00:00
|
|
|
r.builder().SetHasSharedMemory();
|
2018-04-27 20:00:12 +00:00
|
|
|
uint16_t* memory =
|
|
|
|
r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t));
|
2017-08-02 21:40:45 +00:00
|
|
|
|
2017-09-23 18:59:12 +00:00
|
|
|
BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_GET_LOCAL(0),
|
|
|
|
MachineRepresentation::kWord16));
|
2017-08-02 21:40:45 +00:00
|
|
|
|
|
|
|
FOR_UINT16_INPUTS(i) {
|
|
|
|
uint16_t initial = *i;
|
|
|
|
FOR_UINT16_INPUTS(j) {
|
2017-08-19 16:34:11 +00:00
|
|
|
r.builder().WriteMemory(&memory[0], initial);
|
2017-08-02 21:40:45 +00:00
|
|
|
CHECK_EQ(initial, r.Call(*j));
|
|
|
|
uint16_t expected = expected_op(*i, *j);
|
2017-08-19 16:34:11 +00:00
|
|
|
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
|
2017-08-02 21:40:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-04 01:03:03 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicAdd16U) {
|
2018-08-21 15:01:31 +00:00
|
|
|
RunU16BinOp(execution_tier, kExprI32AtomicAdd16U, Add);
|
2017-10-25 12:46:43 +00:00
|
|
|
}
|
2017-11-04 01:03:03 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicSub16U) {
|
2018-08-21 15:01:31 +00:00
|
|
|
RunU16BinOp(execution_tier, kExprI32AtomicSub16U, Sub);
|
2017-10-25 12:46:43 +00:00
|
|
|
}
|
2017-11-04 01:03:03 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicAnd16U) {
|
2018-08-21 15:01:31 +00:00
|
|
|
RunU16BinOp(execution_tier, kExprI32AtomicAnd16U, And);
|
2017-10-25 12:46:43 +00:00
|
|
|
}
|
2017-11-04 01:03:03 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicOr16U) {
|
2018-08-21 15:01:31 +00:00
|
|
|
RunU16BinOp(execution_tier, kExprI32AtomicOr16U, Or);
|
2017-10-25 12:46:43 +00:00
|
|
|
}
|
2017-11-04 01:03:03 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicXor16U) {
|
2018-08-21 15:01:31 +00:00
|
|
|
RunU16BinOp(execution_tier, kExprI32AtomicXor16U, Xor);
|
2017-10-25 12:46:43 +00:00
|
|
|
}
|
2017-11-04 01:03:03 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicExchange16U) {
|
2018-08-21 15:01:31 +00:00
|
|
|
RunU16BinOp(execution_tier, kExprI32AtomicExchange16U, Exchange);
|
2017-10-25 12:46:43 +00:00
|
|
|
}
|
2017-08-02 21:40:45 +00:00
|
|
|
|
2018-08-21 15:01:31 +00:00
|
|
|
void RunU8BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op,
|
2017-10-25 12:46:43 +00:00
|
|
|
Uint8BinOp expected_op) {
|
2017-08-02 21:40:45 +00:00
|
|
|
EXPERIMENTAL_FLAG_SCOPE(threads);
|
2018-08-21 15:01:31 +00:00
|
|
|
WasmRunner<uint32_t, uint32_t> r(execution_tier);
|
2017-09-14 06:14:48 +00:00
|
|
|
r.builder().SetHasSharedMemory();
|
2018-04-27 20:00:12 +00:00
|
|
|
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize);
|
2017-08-02 21:40:45 +00:00
|
|
|
|
2017-09-23 18:59:12 +00:00
|
|
|
BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_GET_LOCAL(0),
|
|
|
|
MachineRepresentation::kWord8));
|
2017-08-02 21:40:45 +00:00
|
|
|
|
|
|
|
FOR_UINT8_INPUTS(i) {
|
|
|
|
uint8_t initial = *i;
|
|
|
|
FOR_UINT8_INPUTS(j) {
|
2017-08-19 16:34:11 +00:00
|
|
|
r.builder().WriteMemory(&memory[0], initial);
|
2017-08-02 21:40:45 +00:00
|
|
|
CHECK_EQ(initial, r.Call(*j));
|
|
|
|
uint8_t expected = expected_op(*i, *j);
|
2017-08-19 16:34:11 +00:00
|
|
|
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
|
2017-08-02 21:40:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-04 01:03:03 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicAdd8U) {
|
2018-08-21 15:01:31 +00:00
|
|
|
RunU8BinOp(execution_tier, kExprI32AtomicAdd8U, Add);
|
2017-10-25 12:46:43 +00:00
|
|
|
}
|
2017-11-04 01:03:03 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicSub8U) {
|
2018-08-21 15:01:31 +00:00
|
|
|
RunU8BinOp(execution_tier, kExprI32AtomicSub8U, Sub);
|
2017-10-25 12:46:43 +00:00
|
|
|
}
|
2017-11-04 01:03:03 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicAnd8U) {
|
2018-08-21 15:01:31 +00:00
|
|
|
RunU8BinOp(execution_tier, kExprI32AtomicAnd8U, And);
|
2017-10-25 12:46:43 +00:00
|
|
|
}
|
2017-11-04 01:03:03 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicOr8U) {
|
2018-08-21 15:01:31 +00:00
|
|
|
RunU8BinOp(execution_tier, kExprI32AtomicOr8U, Or);
|
2017-10-25 12:46:43 +00:00
|
|
|
}
|
2017-11-04 01:03:03 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicXor8U) {
|
2018-08-21 15:01:31 +00:00
|
|
|
RunU8BinOp(execution_tier, kExprI32AtomicXor8U, Xor);
|
2017-10-25 12:46:43 +00:00
|
|
|
}
|
2017-11-04 01:03:03 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicExchange8U) {
|
2018-08-21 15:01:31 +00:00
|
|
|
RunU8BinOp(execution_tier, kExprI32AtomicExchange8U, Exchange);
|
2017-10-25 12:46:43 +00:00
|
|
|
}
|
2017-08-25 21:30:35 +00:00
|
|
|
|
2018-04-26 09:58:33 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicCompareExchange) {
|
2017-08-25 21:30:35 +00:00
|
|
|
EXPERIMENTAL_FLAG_SCOPE(threads);
|
2018-08-21 15:01:31 +00:00
|
|
|
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier);
|
2017-09-14 06:14:48 +00:00
|
|
|
r.builder().SetHasSharedMemory();
|
2018-04-27 20:00:12 +00:00
|
|
|
uint32_t* memory =
|
|
|
|
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
|
2017-09-23 18:59:12 +00:00
|
|
|
BUILD(r, WASM_ATOMICS_TERNARY_OP(
|
|
|
|
kExprI32AtomicCompareExchange, WASM_I32V_1(0), WASM_GET_LOCAL(0),
|
|
|
|
WASM_GET_LOCAL(1), MachineRepresentation::kWord32));
|
2017-08-25 21:30:35 +00:00
|
|
|
|
|
|
|
FOR_UINT32_INPUTS(i) {
|
|
|
|
uint32_t initial = *i;
|
|
|
|
FOR_UINT32_INPUTS(j) {
|
|
|
|
r.builder().WriteMemory(&memory[0], initial);
|
|
|
|
CHECK_EQ(initial, r.Call(*i, *j));
|
|
|
|
uint32_t expected = CompareExchange(initial, *i, *j);
|
|
|
|
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-26 09:58:33 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicCompareExchange16U) {
|
2017-08-25 21:30:35 +00:00
|
|
|
EXPERIMENTAL_FLAG_SCOPE(threads);
|
2018-08-21 15:01:31 +00:00
|
|
|
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier);
|
2017-09-14 06:14:48 +00:00
|
|
|
r.builder().SetHasSharedMemory();
|
2018-04-27 20:00:12 +00:00
|
|
|
uint16_t* memory =
|
|
|
|
r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t));
|
2017-08-25 21:30:35 +00:00
|
|
|
BUILD(r, WASM_ATOMICS_TERNARY_OP(kExprI32AtomicCompareExchange16U,
|
|
|
|
WASM_I32V_1(0), WASM_GET_LOCAL(0),
|
2017-09-23 18:59:12 +00:00
|
|
|
WASM_GET_LOCAL(1),
|
|
|
|
MachineRepresentation::kWord16));
|
2017-08-25 21:30:35 +00:00
|
|
|
|
|
|
|
FOR_UINT16_INPUTS(i) {
|
|
|
|
uint16_t initial = *i;
|
|
|
|
FOR_UINT16_INPUTS(j) {
|
|
|
|
r.builder().WriteMemory(&memory[0], initial);
|
|
|
|
CHECK_EQ(initial, r.Call(*i, *j));
|
|
|
|
uint16_t expected = CompareExchange(initial, *i, *j);
|
|
|
|
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-26 09:58:33 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicCompareExchange8U) {
|
2017-08-25 21:30:35 +00:00
|
|
|
EXPERIMENTAL_FLAG_SCOPE(threads);
|
2018-08-21 15:01:31 +00:00
|
|
|
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier);
|
2017-09-14 06:14:48 +00:00
|
|
|
r.builder().SetHasSharedMemory();
|
2018-04-27 20:00:12 +00:00
|
|
|
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize);
|
2017-08-25 21:30:35 +00:00
|
|
|
BUILD(r,
|
|
|
|
WASM_ATOMICS_TERNARY_OP(kExprI32AtomicCompareExchange8U, WASM_I32V_1(0),
|
2017-09-23 18:59:12 +00:00
|
|
|
WASM_GET_LOCAL(0), WASM_GET_LOCAL(1),
|
|
|
|
MachineRepresentation::kWord8));
|
2017-08-25 21:30:35 +00:00
|
|
|
|
|
|
|
FOR_UINT8_INPUTS(i) {
|
|
|
|
uint8_t initial = *i;
|
|
|
|
FOR_UINT8_INPUTS(j) {
|
|
|
|
r.builder().WriteMemory(&memory[0], initial);
|
|
|
|
CHECK_EQ(initial, r.Call(*i, *j));
|
|
|
|
uint8_t expected = CompareExchange(initial, *i, *j);
|
|
|
|
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-01 12:57:34 +00:00
|
|
|
|
2017-12-01 22:31:45 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicLoad) {
|
2017-10-02 05:05:45 +00:00
|
|
|
EXPERIMENTAL_FLAG_SCOPE(threads);
|
2018-08-21 15:01:31 +00:00
|
|
|
WasmRunner<uint32_t> r(execution_tier);
|
2017-10-02 05:05:45 +00:00
|
|
|
r.builder().SetHasSharedMemory();
|
2018-04-27 20:00:12 +00:00
|
|
|
uint32_t* memory =
|
|
|
|
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
|
2017-10-02 05:05:45 +00:00
|
|
|
BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad, WASM_ZERO,
|
|
|
|
MachineRepresentation::kWord32));
|
|
|
|
|
|
|
|
FOR_UINT32_INPUTS(i) {
|
|
|
|
uint32_t expected = *i;
|
|
|
|
r.builder().WriteMemory(&memory[0], expected);
|
|
|
|
CHECK_EQ(expected, r.Call());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-01 22:31:45 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicLoad16U) {
|
2017-10-02 05:05:45 +00:00
|
|
|
EXPERIMENTAL_FLAG_SCOPE(threads);
|
2018-08-21 15:01:31 +00:00
|
|
|
WasmRunner<uint32_t> r(execution_tier);
|
2017-10-02 05:05:45 +00:00
|
|
|
r.builder().SetHasSharedMemory();
|
2018-04-27 20:00:12 +00:00
|
|
|
uint16_t* memory =
|
|
|
|
r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t));
|
2017-10-02 05:05:45 +00:00
|
|
|
BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad16U, WASM_ZERO,
|
|
|
|
MachineRepresentation::kWord16));
|
|
|
|
|
|
|
|
FOR_UINT16_INPUTS(i) {
|
|
|
|
uint16_t expected = *i;
|
|
|
|
r.builder().WriteMemory(&memory[0], expected);
|
|
|
|
CHECK_EQ(expected, r.Call());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-01 22:31:45 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicLoad8U) {
|
2017-10-02 05:05:45 +00:00
|
|
|
EXPERIMENTAL_FLAG_SCOPE(threads);
|
2018-08-21 15:01:31 +00:00
|
|
|
WasmRunner<uint32_t> r(execution_tier);
|
2017-10-02 05:05:45 +00:00
|
|
|
r.builder().SetHasSharedMemory();
|
2018-04-27 20:00:12 +00:00
|
|
|
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize);
|
2017-10-02 05:05:45 +00:00
|
|
|
BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad8U, WASM_ZERO,
|
|
|
|
MachineRepresentation::kWord8));
|
|
|
|
|
|
|
|
FOR_UINT8_INPUTS(i) {
|
|
|
|
uint8_t expected = *i;
|
|
|
|
r.builder().WriteMemory(&memory[0], expected);
|
|
|
|
CHECK_EQ(expected, r.Call());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-01 22:31:45 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicStoreLoad) {
|
2017-10-02 05:05:45 +00:00
|
|
|
EXPERIMENTAL_FLAG_SCOPE(threads);
|
2018-08-21 15:01:31 +00:00
|
|
|
WasmRunner<uint32_t, uint32_t> r(execution_tier);
|
2017-10-02 05:05:45 +00:00
|
|
|
r.builder().SetHasSharedMemory();
|
2018-04-27 20:00:12 +00:00
|
|
|
uint32_t* memory =
|
|
|
|
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
|
2017-10-02 05:05:45 +00:00
|
|
|
|
|
|
|
BUILD(r,
|
|
|
|
WASM_ATOMICS_STORE_OP(kExprI32AtomicStore, WASM_ZERO, WASM_GET_LOCAL(0),
|
|
|
|
MachineRepresentation::kWord32),
|
|
|
|
WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad, WASM_ZERO,
|
|
|
|
MachineRepresentation::kWord32));
|
|
|
|
|
|
|
|
FOR_UINT32_INPUTS(i) {
|
|
|
|
uint32_t expected = *i;
|
|
|
|
CHECK_EQ(expected, r.Call(*i));
|
|
|
|
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-01 22:31:45 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicStoreLoad16U) {
|
2017-10-02 05:05:45 +00:00
|
|
|
EXPERIMENTAL_FLAG_SCOPE(threads);
|
2018-08-21 15:01:31 +00:00
|
|
|
WasmRunner<uint32_t, uint32_t> r(execution_tier);
|
2017-10-02 05:05:45 +00:00
|
|
|
r.builder().SetHasSharedMemory();
|
2018-04-27 20:00:12 +00:00
|
|
|
uint16_t* memory =
|
|
|
|
r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t));
|
2017-10-02 05:05:45 +00:00
|
|
|
|
|
|
|
BUILD(
|
|
|
|
r,
|
|
|
|
WASM_ATOMICS_STORE_OP(kExprI32AtomicStore16U, WASM_ZERO,
|
|
|
|
WASM_GET_LOCAL(0), MachineRepresentation::kWord16),
|
|
|
|
WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad16U, WASM_ZERO,
|
|
|
|
MachineRepresentation::kWord16));
|
|
|
|
|
|
|
|
FOR_UINT16_INPUTS(i) {
|
|
|
|
uint16_t expected = *i;
|
|
|
|
CHECK_EQ(expected, r.Call(*i));
|
|
|
|
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-01 22:31:45 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicStoreLoad8U) {
|
2017-10-02 05:05:45 +00:00
|
|
|
EXPERIMENTAL_FLAG_SCOPE(threads);
|
2018-08-21 15:01:31 +00:00
|
|
|
WasmRunner<uint32_t, uint32_t> r(execution_tier);
|
2017-10-02 05:05:45 +00:00
|
|
|
r.builder().SetHasSharedMemory();
|
2018-04-27 20:00:12 +00:00
|
|
|
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize);
|
2017-10-02 05:05:45 +00:00
|
|
|
|
|
|
|
BUILD(r,
|
|
|
|
WASM_ATOMICS_STORE_OP(kExprI32AtomicStore8U, WASM_ZERO,
|
|
|
|
WASM_GET_LOCAL(0), MachineRepresentation::kWord8),
|
|
|
|
WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad8U, WASM_ZERO,
|
|
|
|
MachineRepresentation::kWord8));
|
|
|
|
|
|
|
|
FOR_UINT8_INPUTS(i) {
|
|
|
|
uint8_t expected = *i;
|
|
|
|
CHECK_EQ(expected, r.Call(*i));
|
|
|
|
CHECK_EQ(*i, r.builder().ReadMemory(&memory[0]));
|
|
|
|
}
|
|
|
|
}
|
2017-09-08 13:59:05 +00:00
|
|
|
|
2018-07-19 00:38:58 +00:00
|
|
|
WASM_EXEC_TEST(I32AtomicStoreParameter) {
|
|
|
|
EXPERIMENTAL_FLAG_SCOPE(threads);
|
2018-08-21 15:01:31 +00:00
|
|
|
WasmRunner<uint32_t, uint32_t> r(execution_tier);
|
2018-07-19 00:38:58 +00:00
|
|
|
uint32_t* memory =
|
|
|
|
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
|
|
|
|
r.builder().SetHasSharedMemory();
|
|
|
|
|
|
|
|
BUILD(r,
|
|
|
|
WASM_ATOMICS_STORE_OP(kExprI32AtomicStore, WASM_ZERO, WASM_GET_LOCAL(0),
|
|
|
|
MachineRepresentation::kWord8),
|
|
|
|
WASM_ATOMICS_BINOP(kExprI32AtomicAdd, WASM_I32V_1(0), WASM_GET_LOCAL(0),
|
|
|
|
MachineRepresentation::kWord32));
|
|
|
|
CHECK_EQ(10, r.Call(10));
|
|
|
|
CHECK_EQ(20, r.builder().ReadMemory(&memory[0]));
|
|
|
|
}
|
2018-03-03 09:02:01 +00:00
|
|
|
} // namespace test_run_wasm_atomics
|
2017-09-01 12:57:34 +00:00
|
|
|
} // namespace wasm
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|