[wasm][test] Remove useless macro

Remove the BUILD macro, call a function with an initializer list
instead. This makes the code slightly shorter, but most importantly it
avoids an unnecessary macro, which improves maintainability and
debuggability.

R=jkummerow@chromium.org

Bug: v8:13312
Change-Id: I904ccf8e5b98c4d2f487c0cedc865db1386321c6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4152482
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85259}
This commit is contained in:
Clemens Backes 2023-01-12 11:55:52 +01:00 committed by V8 LUCI CQ
parent 48fee7d232
commit c74c9e63e1
23 changed files with 2508 additions and 2595 deletions

View File

@ -13860,13 +13860,13 @@ TEST(WasmSetJitCodeEventHandler) {
TestSignatures sigs;
auto& f = r.NewFunction(sigs.i_i(), "f");
BUILD(f, WASM_I32_ADD(WASM_LOCAL_GET(0), WASM_LOCAL_GET(0)));
f.Build({WASM_I32_ADD(WASM_LOCAL_GET(0), WASM_LOCAL_GET(0))});
LocalContext env;
BUILD(r,
WASM_I32_ADD(WASM_LOCAL_GET(0), WASM_CALL_FUNCTION(f.function_index(),
WASM_LOCAL_GET(1))));
r.Build(
{WASM_I32_ADD(WASM_LOCAL_GET(0), WASM_CALL_FUNCTION(f.function_index(),
WASM_LOCAL_GET(1)))});
Handle<JSFunction> func = r.builder().WrapCode(0);
CHECK(env->Global()
@ -26788,9 +26788,9 @@ TEST(WasmI32AtomicWaitCallback) {
WasmRunner<int32_t, int32_t, int32_t, double> r(TestExecutionTier::kTurbofan);
r.builder().AddMemory(kWasmPageSize, SharedFlag::kShared);
r.builder().SetHasSharedMemory();
BUILD(r, WASM_ATOMICS_WAIT(kExprI32AtomicWait, WASM_LOCAL_GET(0),
r.Build({WASM_ATOMICS_WAIT(kExprI32AtomicWait, WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1),
WASM_I64_SCONVERT_F64(WASM_LOCAL_GET(2)), 4));
WASM_I64_SCONVERT_F64(WASM_LOCAL_GET(2)), 4)});
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
@ -26823,9 +26823,9 @@ TEST(WasmI64AtomicWaitCallback) {
WasmRunner<int32_t, int32_t, double, double> r(TestExecutionTier::kTurbofan);
r.builder().AddMemory(kWasmPageSize, SharedFlag::kShared);
r.builder().SetHasSharedMemory();
BUILD(r, WASM_ATOMICS_WAIT(kExprI64AtomicWait, WASM_LOCAL_GET(0),
r.Build({WASM_ATOMICS_WAIT(kExprI64AtomicWait, WASM_LOCAL_GET(0),
WASM_I64_SCONVERT_F64(WASM_LOCAL_GET(1)),
WASM_I64_SCONVERT_F64(WASM_LOCAL_GET(2)), 8));
WASM_I64_SCONVERT_F64(WASM_LOCAL_GET(2)), 8)});
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);

View File

@ -17,7 +17,7 @@ namespace test_liftoff_for_fuzzing {
TEST(MaxSteps) {
WasmRunner<uint32_t> r(TestExecutionTier::kLiftoffForFuzzing);
BUILD(r, WASM_LOOP(WASM_BR(0)), WASM_I32V(23));
r.Build({WASM_LOOP(WASM_BR(0)), WASM_I32V(23)});
r.SetMaxSteps(10);
r.CheckCallViaJSTraps();
}
@ -25,7 +25,7 @@ TEST(MaxSteps) {
TEST(NondeterminismUnopF32) {
WasmRunner<float> r(TestExecutionTier::kLiftoffForFuzzing);
BUILD(r, WASM_F32_ABS(WASM_F32(std::nanf(""))));
r.Build({WASM_F32_ABS(WASM_F32(std::nanf("")))});
CHECK(!r.HasNondeterminism());
r.CheckCallViaJS(std::nanf(""));
CHECK(r.HasNondeterminism());
@ -34,7 +34,7 @@ TEST(NondeterminismUnopF32) {
TEST(NondeterminismUnopF64) {
WasmRunner<double> r(TestExecutionTier::kLiftoffForFuzzing);
BUILD(r, WASM_F64_ABS(WASM_F64(std::nan(""))));
r.Build({WASM_F64_ABS(WASM_F64(std::nan("")))});
CHECK(!r.HasNondeterminism());
r.CheckCallViaJS(std::nan(""));
CHECK(r.HasNondeterminism());
@ -44,10 +44,9 @@ TEST(NondeterminismUnopF32x4AllNaN) {
WasmRunner<int32_t, float> r(TestExecutionTier::kLiftoffForFuzzing);
byte value = 0;
BUILD(r,
WASM_SIMD_UNOP(kExprF32x4Ceil,
WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value))),
kExprDrop, WASM_ONE);
r.Build({WASM_SIMD_UNOP(kExprF32x4Ceil,
WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value))),
kExprDrop, WASM_ONE});
CHECK(!r.HasNondeterminism());
r.CheckCallViaJS(1, 0.0);
CHECK(!r.HasNondeterminism());
@ -58,9 +57,9 @@ TEST(NondeterminismUnopF32x4AllNaN) {
TEST(NondeterminismUnopF32x4OneNaN) {
for (byte lane = 0; lane < 4; ++lane) {
WasmRunner<int32_t, float> r(TestExecutionTier::kLiftoffForFuzzing);
BUILD(r, WASM_SIMD_F32x4_SPLAT(WASM_F32(0)), WASM_LOCAL_GET(0),
WASM_SIMD_OP(kExprF32x4ReplaceLane), lane,
WASM_SIMD_OP(kExprF32x4Ceil), kExprDrop, WASM_ONE);
r.Build({WASM_SIMD_F32x4_SPLAT(WASM_F32(0)), WASM_LOCAL_GET(0),
WASM_SIMD_OP(kExprF32x4ReplaceLane), lane,
WASM_SIMD_OP(kExprF32x4Ceil), kExprDrop, WASM_ONE});
CHECK(!r.HasNondeterminism());
r.CheckCallViaJS(1, 0.0);
CHECK(!r.HasNondeterminism());
@ -73,10 +72,9 @@ TEST(NondeterminismUnopF64x2AllNaN) {
WasmRunner<int32_t, double> r(TestExecutionTier::kLiftoffForFuzzing);
byte value = 0;
BUILD(r,
WASM_SIMD_UNOP(kExprF64x2Ceil,
WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value))),
kExprDrop, WASM_ONE);
r.Build({WASM_SIMD_UNOP(kExprF64x2Ceil,
WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value))),
kExprDrop, WASM_ONE});
CHECK(!r.HasNondeterminism());
r.CheckCallViaJS(1, 0.0);
CHECK(!r.HasNondeterminism());
@ -87,9 +85,9 @@ TEST(NondeterminismUnopF64x2AllNaN) {
TEST(NondeterminismUnopF64x2OneNaN) {
for (byte lane = 0; lane < 2; ++lane) {
WasmRunner<int32_t, double> r(TestExecutionTier::kLiftoffForFuzzing);
BUILD(r, WASM_SIMD_F64x2_SPLAT(WASM_F64(0)), WASM_LOCAL_GET(0),
WASM_SIMD_OP(kExprF64x2ReplaceLane), lane,
WASM_SIMD_OP(kExprF64x2Ceil), kExprDrop, WASM_ONE);
r.Build({WASM_SIMD_F64x2_SPLAT(WASM_F64(0)), WASM_LOCAL_GET(0),
WASM_SIMD_OP(kExprF64x2ReplaceLane), lane,
WASM_SIMD_OP(kExprF64x2Ceil), kExprDrop, WASM_ONE});
CHECK(!r.HasNondeterminism());
r.CheckCallViaJS(1, 0.0);
CHECK(!r.HasNondeterminism());
@ -101,7 +99,7 @@ TEST(NondeterminismUnopF64x2OneNaN) {
TEST(NondeterminismBinop) {
WasmRunner<float> r(TestExecutionTier::kLiftoffForFuzzing);
BUILD(r, WASM_F32_ADD(WASM_F32(std::nanf("")), WASM_F32(0)));
r.Build({WASM_F32_ADD(WASM_F32(std::nanf("")), WASM_F32(0))});
CHECK(!r.HasNondeterminism());
r.CheckCallViaJS(std::nanf(""));
CHECK(r.HasNondeterminism());

View File

@ -135,7 +135,7 @@ class LiftoffCompileEnvironment {
// Compile the function so we can get the WasmCode* which is later used to
// generate the debug side table lazily.
auto& func_compiler = wasm_runner_.NewFunction(sig, "f");
func_compiler.Build(function_bytes.begin(), function_bytes.end());
func_compiler.Build(base::VectorOf(function_bytes));
WasmCode* code =
wasm_runner_.builder().GetFunctionCode(func_compiler.function_index());

View File

@ -26,7 +26,7 @@ WASM_EXEC_TEST(I64Const) {
WasmRunner<int64_t> r(execution_tier);
const int64_t kExpectedValue = 0x1122334455667788LL;
// return(kExpectedValue)
BUILD(r, WASM_I64V_9(kExpectedValue));
r.Build({WASM_I64V_9(kExpectedValue)});
CHECK_EQ(kExpectedValue, r.Call());
}
@ -36,7 +36,7 @@ WASM_EXEC_TEST(I64Const_many) {
WasmRunner<int64_t> r(execution_tier);
const int64_t kExpectedValue = (static_cast<uint64_t>(i) << 32) | cntr;
// return(kExpectedValue)
BUILD(r, WASM_I64V(kExpectedValue));
r.Build({WASM_I64V(kExpectedValue)});
CHECK_EQ(kExpectedValue, r.Call());
cntr++;
}
@ -45,14 +45,14 @@ WASM_EXEC_TEST(I64Const_many) {
WASM_EXEC_TEST(Return_I64) {
WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_RETURN(WASM_LOCAL_GET(0)));
r.Build({WASM_RETURN(WASM_LOCAL_GET(0))});
FOR_INT64_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
}
WASM_EXEC_TEST(I64Add) {
WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_ADD(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_ADD(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) {
CHECK_EQ(base::AddWithWraparound(i, j), r.Call(i, j));
@ -67,17 +67,16 @@ const int64_t kHasBit33On = 0x100000000;
WASM_EXEC_TEST(Regress5800_Add) {
WasmRunner<int32_t> r(execution_tier);
BUILD(r,
WASM_BLOCK(WASM_BR_IF(0, WASM_I64_EQZ(WASM_I64_ADD(
WASM_I64V(0), WASM_I64V(kHasBit33On)))),
WASM_RETURN(WASM_I32V(0))),
WASM_I32V(0));
r.Build({WASM_BLOCK(WASM_BR_IF(0, WASM_I64_EQZ(WASM_I64_ADD(
WASM_I64V(0), WASM_I64V(kHasBit33On)))),
WASM_RETURN(WASM_I32V(0))),
WASM_I32V(0)});
CHECK_EQ(0, r.Call());
}
WASM_EXEC_TEST(I64Sub) {
WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SUB(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_SUB(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) {
CHECK_EQ(base::SubWithWraparound(i, j), r.Call(i, j));
@ -87,18 +86,17 @@ WASM_EXEC_TEST(I64Sub) {
WASM_EXEC_TEST(Regress5800_Sub) {
WasmRunner<int32_t> r(execution_tier);
BUILD(r,
WASM_BLOCK(WASM_BR_IF(0, WASM_I64_EQZ(WASM_I64_SUB(
WASM_I64V(0), WASM_I64V(kHasBit33On)))),
WASM_RETURN(WASM_I32V(0))),
WASM_I32V(0));
r.Build({WASM_BLOCK(WASM_BR_IF(0, WASM_I64_EQZ(WASM_I64_SUB(
WASM_I64V(0), WASM_I64V(kHasBit33On)))),
WASM_RETURN(WASM_I32V(0))),
WASM_I32V(0)});
CHECK_EQ(0, r.Call());
}
WASM_EXEC_TEST(I64AddUseOnlyLowWord) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I32_CONVERT_I64(
WASM_I64_ADD(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))));
r.Build({WASM_I32_CONVERT_I64(
WASM_I64_ADD(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) {
CHECK_EQ(static_cast<int32_t>(base::AddWithWraparound(i, j)),
@ -109,8 +107,8 @@ WASM_EXEC_TEST(I64AddUseOnlyLowWord) {
WASM_EXEC_TEST(I64SubUseOnlyLowWord) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I32_CONVERT_I64(
WASM_I64_SUB(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))));
r.Build({WASM_I32_CONVERT_I64(
WASM_I64_SUB(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) {
CHECK_EQ(static_cast<int32_t>(base::SubWithWraparound(i, j)),
@ -121,8 +119,8 @@ WASM_EXEC_TEST(I64SubUseOnlyLowWord) {
WASM_EXEC_TEST(I64MulUseOnlyLowWord) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I32_CONVERT_I64(
WASM_I64_MUL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))));
r.Build({WASM_I32_CONVERT_I64(
WASM_I64_MUL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) {
CHECK_EQ(static_cast<int32_t>(base::MulWithWraparound(i, j)),
@ -133,8 +131,8 @@ WASM_EXEC_TEST(I64MulUseOnlyLowWord) {
WASM_EXEC_TEST(I64ShlUseOnlyLowWord) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I32_CONVERT_I64(
WASM_I64_SHL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))));
r.Build({WASM_I32_CONVERT_I64(
WASM_I64_SHL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) {
int32_t expected = static_cast<int32_t>(base::ShlWithWraparound(i, j));
@ -145,8 +143,8 @@ WASM_EXEC_TEST(I64ShlUseOnlyLowWord) {
WASM_EXEC_TEST(I64ShrUseOnlyLowWord) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I32_CONVERT_I64(
WASM_I64_SHR(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))));
r.Build({WASM_I32_CONVERT_I64(
WASM_I64_SHR(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)))});
FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) {
int32_t expected = static_cast<int32_t>((i) >> (j & 0x3F));
@ -157,8 +155,8 @@ WASM_EXEC_TEST(I64ShrUseOnlyLowWord) {
WASM_EXEC_TEST(I64SarUseOnlyLowWord) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I32_CONVERT_I64(
WASM_I64_SAR(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))));
r.Build({WASM_I32_CONVERT_I64(
WASM_I64_SAR(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) {
int32_t expected = static_cast<int32_t>((i) >> (j & 0x3F));
@ -169,7 +167,7 @@ WASM_EXEC_TEST(I64SarUseOnlyLowWord) {
WASM_EXEC_TEST(I64DivS) {
WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_DIVS(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_DIVS(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) {
if (j == 0) {
@ -185,7 +183,7 @@ WASM_EXEC_TEST(I64DivS) {
WASM_EXEC_TEST(I64DivS_Trap) {
WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_DIVS(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_DIVS(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
CHECK_EQ(0, r.Call(int64_t{0}, int64_t{100}));
CHECK_TRAP64(r.Call(int64_t{100}, int64_t{0}));
CHECK_TRAP64(r.Call(int64_t{-1001}, int64_t{0}));
@ -196,7 +194,7 @@ WASM_EXEC_TEST(I64DivS_Trap) {
WASM_EXEC_TEST(I64DivS_Byzero_Const) {
for (int8_t denom = -2; denom < 8; denom++) {
WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_DIVS(WASM_LOCAL_GET(0), WASM_I64V_1(denom)));
r.Build({WASM_I64_DIVS(WASM_LOCAL_GET(0), WASM_I64V_1(denom))});
for (int64_t val = -7; val < 8; val++) {
if (denom == 0) {
CHECK_TRAP64(r.Call(val));
@ -209,7 +207,7 @@ WASM_EXEC_TEST(I64DivS_Byzero_Const) {
WASM_EXEC_TEST(I64DivU) {
WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier);
BUILD(r, WASM_I64_DIVU(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_DIVU(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) {
if (j == 0) {
@ -223,7 +221,7 @@ WASM_EXEC_TEST(I64DivU) {
WASM_EXEC_TEST(I64DivU_Trap) {
WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier);
BUILD(r, WASM_I64_DIVU(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_DIVU(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
CHECK_EQ(0, r.Call(uint64_t{0}, uint64_t{100}));
CHECK_TRAP64(r.Call(uint64_t{100}, uint64_t{0}));
CHECK_TRAP64(r.Call(uint64_t{1001}, uint64_t{0}));
@ -233,7 +231,7 @@ WASM_EXEC_TEST(I64DivU_Trap) {
WASM_EXEC_TEST(I64DivU_Byzero_Const) {
for (uint64_t denom = 0xFFFFFFFFFFFFFFFE; denom < 8; denom++) {
WasmRunner<uint64_t, uint64_t> r(execution_tier);
BUILD(r, WASM_I64_DIVU(WASM_LOCAL_GET(0), WASM_I64V_1(denom)));
r.Build({WASM_I64_DIVU(WASM_LOCAL_GET(0), WASM_I64V_1(denom))});
for (uint64_t val = 0xFFFFFFFFFFFFFFF0; val < 8; val++) {
if (denom == 0) {
@ -247,7 +245,7 @@ WASM_EXEC_TEST(I64DivU_Byzero_Const) {
WASM_EXEC_TEST(I64RemS) {
WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_REMS(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_REMS(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) {
if (j == 0) {
@ -263,7 +261,7 @@ WASM_EXEC_TEST(I64RemS) {
WASM_EXEC_TEST(I64RemS_Trap) {
WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_REMS(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_REMS(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
CHECK_EQ(33, r.Call(int64_t{133}, int64_t{100}));
CHECK_EQ(0, r.Call(std::numeric_limits<int64_t>::min(), int64_t{-1}));
CHECK_TRAP64(r.Call(int64_t{100}, int64_t{0}));
@ -273,7 +271,7 @@ WASM_EXEC_TEST(I64RemS_Trap) {
WASM_EXEC_TEST(I64RemU) {
WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier);
BUILD(r, WASM_I64_REMU(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_REMU(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) {
if (j == 0) {
@ -287,7 +285,7 @@ WASM_EXEC_TEST(I64RemU) {
WASM_EXEC_TEST(I64RemU_Trap) {
WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier);
BUILD(r, WASM_I64_REMU(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_REMU(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
CHECK_EQ(17, r.Call(uint64_t{217}, uint64_t{100}));
CHECK_TRAP64(r.Call(uint64_t{100}, uint64_t{0}));
CHECK_TRAP64(r.Call(uint64_t{1001}, uint64_t{0}));
@ -296,7 +294,7 @@ WASM_EXEC_TEST(I64RemU_Trap) {
WASM_EXEC_TEST(I64And) {
WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_AND(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_AND(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ((i) & (j), r.Call(i, j)); }
}
@ -304,7 +302,7 @@ WASM_EXEC_TEST(I64And) {
WASM_EXEC_TEST(I64Ior) {
WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_IOR(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_IOR(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ((i) | (j), r.Call(i, j)); }
}
@ -312,7 +310,7 @@ WASM_EXEC_TEST(I64Ior) {
WASM_EXEC_TEST(I64Xor) {
WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_XOR(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_XOR(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ((i) ^ (j), r.Call(i, j)); }
}
@ -321,7 +319,7 @@ WASM_EXEC_TEST(I64Xor) {
WASM_EXEC_TEST(I64Shl) {
{
WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier);
BUILD(r, WASM_I64_SHL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_SHL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) {
@ -332,22 +330,22 @@ WASM_EXEC_TEST(I64Shl) {
}
{
WasmRunner<uint64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SHL(WASM_LOCAL_GET(0), WASM_I64V_1(0)));
r.Build({WASM_I64_SHL(WASM_LOCAL_GET(0), WASM_I64V_1(0))});
FOR_UINT64_INPUTS(i) { CHECK_EQ(i << 0, r.Call(i)); }
}
{
WasmRunner<uint64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SHL(WASM_LOCAL_GET(0), WASM_I64V_1(32)));
r.Build({WASM_I64_SHL(WASM_LOCAL_GET(0), WASM_I64V_1(32))});
FOR_UINT64_INPUTS(i) { CHECK_EQ(i << 32, r.Call(i)); }
}
{
WasmRunner<uint64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SHL(WASM_LOCAL_GET(0), WASM_I64V_1(20)));
r.Build({WASM_I64_SHL(WASM_LOCAL_GET(0), WASM_I64V_1(20))});
FOR_UINT64_INPUTS(i) { CHECK_EQ(i << 20, r.Call(i)); }
}
{
WasmRunner<uint64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SHL(WASM_LOCAL_GET(0), WASM_I64V_1(40)));
r.Build({WASM_I64_SHL(WASM_LOCAL_GET(0), WASM_I64V_1(40))});
FOR_UINT64_INPUTS(i) { CHECK_EQ(i << 40, r.Call(i)); }
}
}
@ -355,7 +353,7 @@ WASM_EXEC_TEST(I64Shl) {
WASM_EXEC_TEST(I64ShrU) {
{
WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier);
BUILD(r, WASM_I64_SHR(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_SHR(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) {
@ -366,22 +364,22 @@ WASM_EXEC_TEST(I64ShrU) {
}
{
WasmRunner<uint64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SHR(WASM_LOCAL_GET(0), WASM_I64V_1(0)));
r.Build({WASM_I64_SHR(WASM_LOCAL_GET(0), WASM_I64V_1(0))});
FOR_UINT64_INPUTS(i) { CHECK_EQ(i >> 0, r.Call(i)); }
}
{
WasmRunner<uint64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SHR(WASM_LOCAL_GET(0), WASM_I64V_1(32)));
r.Build({WASM_I64_SHR(WASM_LOCAL_GET(0), WASM_I64V_1(32))});
FOR_UINT64_INPUTS(i) { CHECK_EQ(i >> 32, r.Call(i)); }
}
{
WasmRunner<uint64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SHR(WASM_LOCAL_GET(0), WASM_I64V_1(20)));
r.Build({WASM_I64_SHR(WASM_LOCAL_GET(0), WASM_I64V_1(20))});
FOR_UINT64_INPUTS(i) { CHECK_EQ(i >> 20, r.Call(i)); }
}
{
WasmRunner<uint64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SHR(WASM_LOCAL_GET(0), WASM_I64V_1(40)));
r.Build({WASM_I64_SHR(WASM_LOCAL_GET(0), WASM_I64V_1(40))});
FOR_UINT64_INPUTS(i) { CHECK_EQ(i >> 40, r.Call(i)); }
}
}
@ -389,7 +387,7 @@ WASM_EXEC_TEST(I64ShrU) {
WASM_EXEC_TEST(I64ShrS) {
{
WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SAR(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_SAR(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) {
@ -400,29 +398,29 @@ WASM_EXEC_TEST(I64ShrS) {
}
{
WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SAR(WASM_LOCAL_GET(0), WASM_I64V_1(0)));
r.Build({WASM_I64_SAR(WASM_LOCAL_GET(0), WASM_I64V_1(0))});
FOR_INT64_INPUTS(i) { CHECK_EQ(i >> 0, r.Call(i)); }
}
{
WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SAR(WASM_LOCAL_GET(0), WASM_I64V_1(32)));
r.Build({WASM_I64_SAR(WASM_LOCAL_GET(0), WASM_I64V_1(32))});
FOR_INT64_INPUTS(i) { CHECK_EQ(i >> 32, r.Call(i)); }
}
{
WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SAR(WASM_LOCAL_GET(0), WASM_I64V_1(20)));
r.Build({WASM_I64_SAR(WASM_LOCAL_GET(0), WASM_I64V_1(20))});
FOR_INT64_INPUTS(i) { CHECK_EQ(i >> 20, r.Call(i)); }
}
{
WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SAR(WASM_LOCAL_GET(0), WASM_I64V_1(40)));
r.Build({WASM_I64_SAR(WASM_LOCAL_GET(0), WASM_I64V_1(40))});
FOR_INT64_INPUTS(i) { CHECK_EQ(i >> 40, r.Call(i)); }
}
}
WASM_EXEC_TEST(I64Eq) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_EQ(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_EQ(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ(i == j ? 1 : 0, r.Call(i, j)); }
}
@ -430,7 +428,7 @@ WASM_EXEC_TEST(I64Eq) {
WASM_EXEC_TEST(I64Ne) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_NE(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_NE(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ(i != j ? 1 : 0, r.Call(i, j)); }
}
@ -438,7 +436,7 @@ WASM_EXEC_TEST(I64Ne) {
WASM_EXEC_TEST(I64LtS) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_LTS(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_LTS(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ(i < j ? 1 : 0, r.Call(i, j)); }
}
@ -446,7 +444,7 @@ WASM_EXEC_TEST(I64LtS) {
WASM_EXEC_TEST(I64LeS) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_LES(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_LES(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ(i <= j ? 1 : 0, r.Call(i, j)); }
}
@ -454,7 +452,7 @@ WASM_EXEC_TEST(I64LeS) {
WASM_EXEC_TEST(I64LtU) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_LTU(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_LTU(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) { CHECK_EQ(i < j ? 1 : 0, r.Call(i, j)); }
}
@ -462,7 +460,7 @@ WASM_EXEC_TEST(I64LtU) {
WASM_EXEC_TEST(I64LeU) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_LEU(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_LEU(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) { CHECK_EQ(i <= j ? 1 : 0, r.Call(i, j)); }
}
@ -470,7 +468,7 @@ WASM_EXEC_TEST(I64LeU) {
WASM_EXEC_TEST(I64GtS) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_GTS(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_GTS(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ(i > j ? 1 : 0, r.Call(i, j)); }
}
@ -478,7 +476,7 @@ WASM_EXEC_TEST(I64GtS) {
WASM_EXEC_TEST(I64GeS) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_GES(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_GES(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ(i >= j ? 1 : 0, r.Call(i, j)); }
}
@ -486,7 +484,7 @@ WASM_EXEC_TEST(I64GeS) {
WASM_EXEC_TEST(I64GtU) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_GTU(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_GTU(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) { CHECK_EQ(i > j ? 1 : 0, r.Call(i, j)); }
}
@ -494,7 +492,7 @@ WASM_EXEC_TEST(I64GtU) {
WASM_EXEC_TEST(I64GeU) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_GEU(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_GEU(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) { CHECK_EQ(i >= j ? 1 : 0, r.Call(i, j)); }
}
@ -503,20 +501,20 @@ WASM_EXEC_TEST(I64GeU) {
WASM_EXEC_TEST(I32ConvertI64) {
FOR_INT64_INPUTS(i) {
WasmRunner<int32_t> r(execution_tier);
BUILD(r, WASM_I32_CONVERT_I64(WASM_I64V(i)));
r.Build({WASM_I32_CONVERT_I64(WASM_I64V(i))});
CHECK_EQ(static_cast<int32_t>(i), r.Call());
}
}
WASM_EXEC_TEST(I64SConvertI32) {
WasmRunner<int64_t, int32_t> r(execution_tier);
BUILD(r, WASM_I64_SCONVERT_I32(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_SCONVERT_I32(WASM_LOCAL_GET(0))});
FOR_INT32_INPUTS(i) { CHECK_EQ(static_cast<int64_t>(i), r.Call(i)); }
}
WASM_EXEC_TEST(I64UConvertI32) {
WasmRunner<int64_t, uint32_t> r(execution_tier);
BUILD(r, WASM_I64_UCONVERT_I32(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_UCONVERT_I32(WASM_LOCAL_GET(0))});
FOR_UINT32_INPUTS(i) { CHECK_EQ(static_cast<int64_t>(i), r.Call(i)); }
}
@ -531,7 +529,7 @@ WASM_EXEC_TEST(I64Popcnt) {
{38, 0xFFEDCBA09EDCBA09}};
WasmRunner<int64_t, uint64_t> r(execution_tier);
BUILD(r, WASM_I64_POPCNT(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_POPCNT(WASM_LOCAL_GET(0))});
for (size_t i = 0; i < arraysize(values); i++) {
CHECK_EQ(values[i].expected, r.Call(values[i].input));
}
@ -539,7 +537,7 @@ WASM_EXEC_TEST(I64Popcnt) {
WASM_EXEC_TEST(F32SConvertI64) {
WasmRunner<float, int64_t> r(execution_tier);
BUILD(r, WASM_F32_SCONVERT_I64(WASM_LOCAL_GET(0)));
r.Build({WASM_F32_SCONVERT_I64(WASM_LOCAL_GET(0))});
FOR_INT64_INPUTS(i) { CHECK_FLOAT_EQ(static_cast<float>(i), r.Call(i)); }
}
@ -626,7 +624,7 @@ WASM_EXEC_TEST(F32UConvertI64) {
{0x20000020000001, 0x5a000001},
{0xFFFFFe8000000001, 0x5f7FFFFF}};
WasmRunner<float, uint64_t> r(execution_tier);
BUILD(r, WASM_F32_UCONVERT_I64(WASM_LOCAL_GET(0)));
r.Build({WASM_F32_UCONVERT_I64(WASM_LOCAL_GET(0))});
for (size_t i = 0; i < arraysize(values); i++) {
CHECK_EQ(base::bit_cast<float>(values[i].expected),
r.Call(values[i].input));
@ -635,7 +633,7 @@ WASM_EXEC_TEST(F32UConvertI64) {
WASM_EXEC_TEST(F64SConvertI64) {
WasmRunner<double, int64_t> r(execution_tier);
BUILD(r, WASM_F64_SCONVERT_I64(WASM_LOCAL_GET(0)));
r.Build({WASM_F64_SCONVERT_I64(WASM_LOCAL_GET(0))});
FOR_INT64_INPUTS(i) { CHECK_DOUBLE_EQ(static_cast<double>(i), r.Call(i)); }
}
@ -719,7 +717,7 @@ WASM_EXEC_TEST(F64UConvertI64) {
{0x8000000000000400, 0x43E0000000000000},
{0x8000000000000401, 0x43E0000000000001}};
WasmRunner<double, uint64_t> r(execution_tier);
BUILD(r, WASM_F64_UCONVERT_I64(WASM_LOCAL_GET(0)));
r.Build({WASM_F64_UCONVERT_I64(WASM_LOCAL_GET(0))});
for (size_t i = 0; i < arraysize(values); i++) {
CHECK_EQ(base::bit_cast<double>(values[i].expected),
r.Call(values[i].input));
@ -728,7 +726,7 @@ WASM_EXEC_TEST(F64UConvertI64) {
WASM_EXEC_TEST(I64SConvertF32) {
WasmRunner<int64_t, float> r(execution_tier);
BUILD(r, WASM_I64_SCONVERT_F32(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_SCONVERT_F32(WASM_LOCAL_GET(0))});
FOR_FLOAT32_INPUTS(i) {
if (base::IsValueInRangeForNumericType<int64_t>(i)) {
@ -741,7 +739,7 @@ WASM_EXEC_TEST(I64SConvertF32) {
WASM_EXEC_TEST(I64SConvertSatF32) {
WasmRunner<int64_t, float> r(execution_tier);
BUILD(r, WASM_I64_SCONVERT_SAT_F32(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_SCONVERT_SAT_F32(WASM_LOCAL_GET(0))});
FOR_FLOAT32_INPUTS(i) {
int64_t expected;
if (base::IsValueInRangeForNumericType<int64_t>(i)) {
@ -760,7 +758,7 @@ WASM_EXEC_TEST(I64SConvertSatF32) {
WASM_EXEC_TEST(I64SConvertF64) {
WasmRunner<int64_t, double> r(execution_tier);
BUILD(r, WASM_I64_SCONVERT_F64(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_SCONVERT_F64(WASM_LOCAL_GET(0))});
FOR_FLOAT64_INPUTS(i) {
if (base::IsValueInRangeForNumericType<int64_t>(i)) {
@ -773,7 +771,7 @@ WASM_EXEC_TEST(I64SConvertF64) {
WASM_EXEC_TEST(I64SConvertSatF64) {
WasmRunner<int64_t, double> r(execution_tier);
BUILD(r, WASM_I64_SCONVERT_SAT_F64(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_SCONVERT_SAT_F64(WASM_LOCAL_GET(0))});
FOR_FLOAT64_INPUTS(i) {
int64_t expected;
if (base::IsValueInRangeForNumericType<int64_t>(i)) {
@ -792,7 +790,7 @@ WASM_EXEC_TEST(I64SConvertSatF64) {
WASM_EXEC_TEST(I64UConvertF32) {
WasmRunner<uint64_t, float> r(execution_tier);
BUILD(r, WASM_I64_UCONVERT_F32(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_UCONVERT_F32(WASM_LOCAL_GET(0))});
FOR_FLOAT32_INPUTS(i) {
if (i < static_cast<float>(std::numeric_limits<uint64_t>::max()) &&
@ -806,7 +804,7 @@ WASM_EXEC_TEST(I64UConvertF32) {
WASM_EXEC_TEST(I64UConvertSatF32) {
WasmRunner<int64_t, float> r(execution_tier);
BUILD(r, WASM_I64_UCONVERT_SAT_F32(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_UCONVERT_SAT_F32(WASM_LOCAL_GET(0))});
FOR_FLOAT32_INPUTS(i) {
uint64_t expected;
if (i < static_cast<float>(std::numeric_limits<uint64_t>::max()) &&
@ -826,7 +824,7 @@ WASM_EXEC_TEST(I64UConvertSatF32) {
WASM_EXEC_TEST(I64UConvertF64) {
WasmRunner<uint64_t, double> r(execution_tier);
BUILD(r, WASM_I64_UCONVERT_F64(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_UCONVERT_F64(WASM_LOCAL_GET(0))});
FOR_FLOAT64_INPUTS(i) {
if (i < static_cast<float>(std::numeric_limits<uint64_t>::max()) &&
@ -840,7 +838,7 @@ WASM_EXEC_TEST(I64UConvertF64) {
WASM_EXEC_TEST(I64UConvertSatF64) {
WasmRunner<int64_t, double> r(execution_tier);
BUILD(r, WASM_I64_UCONVERT_SAT_F64(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_UCONVERT_SAT_F64(WASM_LOCAL_GET(0))});
FOR_FLOAT64_INPUTS(i) {
int64_t expected;
if (i < static_cast<float>(std::numeric_limits<uint64_t>::max()) &&
@ -869,23 +867,21 @@ WASM_EXEC_TEST(CallI64Parameter) {
WasmRunner<int32_t> r(execution_tier);
// Build the target function.
WasmFunctionCompiler& t = r.NewFunction(&sig);
BUILD(t, WASM_LOCAL_GET(i));
t.Build({WASM_LOCAL_GET(i)});
// Build the calling function.
BUILD(
r,
WASM_I32_CONVERT_I64(WASM_CALL_FUNCTION(
t.function_index(), WASM_I64V_9(0xBCD12340000000B),
WASM_I64V_9(0xBCD12340000000C), WASM_I32V_1(0xD),
WASM_I32_CONVERT_I64(WASM_I64V_9(0xBCD12340000000E)),
WASM_I64V_9(0xBCD12340000000F), WASM_I64V_10(0xBCD1234000000010),
WASM_I64V_10(0xBCD1234000000011), WASM_I64V_10(0xBCD1234000000012),
WASM_I64V_10(0xBCD1234000000013), WASM_I64V_10(0xBCD1234000000014),
WASM_I64V_10(0xBCD1234000000015), WASM_I64V_10(0xBCD1234000000016),
WASM_I64V_10(0xBCD1234000000017), WASM_I64V_10(0xBCD1234000000018),
WASM_I64V_10(0xBCD1234000000019), WASM_I64V_10(0xBCD123400000001A),
WASM_I64V_10(0xBCD123400000001B), WASM_I64V_10(0xBCD123400000001C),
WASM_I64V_10(0xBCD123400000001D))));
r.Build({WASM_I32_CONVERT_I64(WASM_CALL_FUNCTION(
t.function_index(), WASM_I64V_9(0xBCD12340000000B),
WASM_I64V_9(0xBCD12340000000C), WASM_I32V_1(0xD),
WASM_I32_CONVERT_I64(WASM_I64V_9(0xBCD12340000000E)),
WASM_I64V_9(0xBCD12340000000F), WASM_I64V_10(0xBCD1234000000010),
WASM_I64V_10(0xBCD1234000000011), WASM_I64V_10(0xBCD1234000000012),
WASM_I64V_10(0xBCD1234000000013), WASM_I64V_10(0xBCD1234000000014),
WASM_I64V_10(0xBCD1234000000015), WASM_I64V_10(0xBCD1234000000016),
WASM_I64V_10(0xBCD1234000000017), WASM_I64V_10(0xBCD1234000000018),
WASM_I64V_10(0xBCD1234000000019), WASM_I64V_10(0xBCD123400000001A),
WASM_I64V_10(0xBCD123400000001B), WASM_I64V_10(0xBCD123400000001C),
WASM_I64V_10(0xBCD123400000001D)))});
CHECK_EQ(i + 0xB, r.Call());
}
@ -900,11 +896,11 @@ WASM_EXEC_TEST(CallI64Return) {
WasmRunner<int64_t> r(execution_tier);
// Build the target function.
WasmFunctionCompiler& t = r.NewFunction(&sig);
BUILD(t, WASM_LOCAL_GET(0), WASM_I32V(7));
t.Build({WASM_LOCAL_GET(0), WASM_I32V(7)});
// Build the first calling function.
BUILD(r, WASM_CALL_FUNCTION(t.function_index(), WASM_I64V(0xBCD12340000000B)),
WASM_DROP);
r.Build({WASM_CALL_FUNCTION(t.function_index(), WASM_I64V(0xBCD12340000000B)),
WASM_DROP});
CHECK_EQ(0xBCD12340000000B, r.Call());
}
@ -914,13 +910,13 @@ void TestI64Binop(TestExecutionTier execution_tier, WasmOpcode opcode,
{
WasmRunner<int64_t> r(execution_tier);
// return K op K
BUILD(r, WASM_BINOP(opcode, WASM_I64V(a), WASM_I64V(b)));
r.Build({WASM_BINOP(opcode, WASM_I64V(a), WASM_I64V(b))});
CHECK_EQ(expected, r.Call());
}
{
WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
// return a op b
BUILD(r, WASM_BINOP(opcode, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_BINOP(opcode, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
CHECK_EQ(expected, r.Call(a, b));
}
}
@ -930,13 +926,13 @@ void TestI64Cmp(TestExecutionTier execution_tier, WasmOpcode opcode,
{
WasmRunner<int32_t> r(execution_tier);
// return K op K
BUILD(r, WASM_BINOP(opcode, WASM_I64V(a), WASM_I64V(b)));
r.Build({WASM_BINOP(opcode, WASM_I64V(a), WASM_I64V(b))});
CHECK_EQ(expected, r.Call());
}
{
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
// return a op b
BUILD(r, WASM_BINOP(opcode, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_BINOP(opcode, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
CHECK_EQ(expected, r.Call(a, b));
}
}
@ -1044,7 +1040,7 @@ WASM_EXEC_TEST(I64Clz) {
{64, 0x0000000000000000}};
WasmRunner<int64_t, uint64_t> r(execution_tier);
BUILD(r, WASM_I64_CLZ(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_CLZ(WASM_LOCAL_GET(0))});
for (size_t i = 0; i < arraysize(values); i++) {
CHECK_EQ(values[i].expected, r.Call(values[i].input));
}
@ -1089,7 +1085,7 @@ WASM_EXEC_TEST(I64Ctz) {
{0, 0x000000009AFDBC81}};
WasmRunner<int64_t, uint64_t> r(execution_tier);
BUILD(r, WASM_I64_CTZ(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_CTZ(WASM_LOCAL_GET(0))});
for (size_t i = 0; i < arraysize(values); i++) {
CHECK_EQ(values[i].expected, r.Call(values[i].input));
}
@ -1106,7 +1102,7 @@ WASM_EXEC_TEST(I64Popcnt2) {
{38, 0xFFEDCBA09EDCBA09}};
WasmRunner<int64_t, uint64_t> r(execution_tier);
BUILD(r, WASM_I64_POPCNT(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_POPCNT(WASM_LOCAL_GET(0))});
for (size_t i = 0; i < arraysize(values); i++) {
CHECK_EQ(values[i].expected, r.Call(values[i].input));
}
@ -1117,25 +1113,25 @@ WASM_EXEC_TEST(I64Popcnt2) {
WASM_EXEC_TEST(I64WasmRunner) {
FOR_INT64_INPUTS(i) {
WasmRunner<int64_t> r(execution_tier);
BUILD(r, WASM_I64V(i));
r.Build({WASM_I64V(i)});
CHECK_EQ(i, r.Call());
}
{
WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_LOCAL_GET(0));
r.Build({WASM_LOCAL_GET(0)});
FOR_INT64_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
}
{
WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_XOR(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_XOR(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ(i ^ j, r.Call(i, j)); }
}
}
{
WasmRunner<int64_t, int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_XOR(WASM_LOCAL_GET(0),
WASM_I64_XOR(WASM_LOCAL_GET(1), WASM_LOCAL_GET(2))));
r.Build({WASM_I64_XOR(WASM_LOCAL_GET(0),
WASM_I64_XOR(WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) {
CHECK_EQ(i ^ j ^ j, r.Call(i, j, j));
@ -1146,10 +1142,10 @@ WASM_EXEC_TEST(I64WasmRunner) {
}
{
WasmRunner<int64_t, int64_t, int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_XOR(WASM_LOCAL_GET(0),
WASM_I64_XOR(WASM_LOCAL_GET(1),
WASM_I64_XOR(WASM_LOCAL_GET(2),
WASM_LOCAL_GET(3)))));
r.Build({WASM_I64_XOR(
WASM_LOCAL_GET(0),
WASM_I64_XOR(WASM_LOCAL_GET(1),
WASM_I64_XOR(WASM_LOCAL_GET(2), WASM_LOCAL_GET(3))))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) {
CHECK_EQ(i ^ j ^ j ^ j, r.Call(i, j, j, j));
@ -1166,11 +1162,11 @@ WASM_EXEC_TEST(Call_Int64Sub) {
// Build the target function.
TestSignatures sigs;
WasmFunctionCompiler& t = r.NewFunction(sigs.l_ll());
BUILD(t, WASM_I64_SUB(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
t.Build({WASM_I64_SUB(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
// Build the caller function.
BUILD(r, WASM_CALL_FUNCTION(t.function_index(), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1)));
r.Build({WASM_CALL_FUNCTION(t.function_index(), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1))});
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) {
@ -1227,8 +1223,8 @@ WASM_EXEC_TEST(I64ReinterpretF64) {
int64_t* memory =
r.builder().AddMemoryElems<int64_t>(kWasmPageSize / sizeof(int64_t));
BUILD(r, WASM_I64_REINTERPRET_F64(
WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO)));
r.Build({WASM_I64_REINTERPRET_F64(
WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO))});
FOR_INT32_INPUTS(i) {
int64_t expected =
@ -1240,8 +1236,8 @@ WASM_EXEC_TEST(I64ReinterpretF64) {
WASM_EXEC_TEST(SignallingNanSurvivesI64ReinterpretF64) {
WasmRunner<int64_t> r(execution_tier);
BUILD(r, WASM_I64_REINTERPRET_F64(WASM_SEQ(kExprF64Const, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xF4, 0x7F)));
r.Build({WASM_I64_REINTERPRET_F64(WASM_SEQ(kExprF64Const, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xF4, 0x7F))});
// This is a signalling nan.
CHECK_EQ(0x7FF4000000000000, r.Call());
@ -1252,10 +1248,9 @@ WASM_EXEC_TEST(F64ReinterpretI64) {
int64_t* memory =
r.builder().AddMemoryElems<int64_t>(kWasmPageSize / sizeof(int64_t));
BUILD(r,
WASM_STORE_MEM(MachineType::Float64(), WASM_ZERO,
WASM_F64_REINTERPRET_I64(WASM_LOCAL_GET(0))),
WASM_LOCAL_GET(0));
r.Build({WASM_STORE_MEM(MachineType::Float64(), WASM_ZERO,
WASM_F64_REINTERPRET_I64(WASM_LOCAL_GET(0))),
WASM_LOCAL_GET(0)});
FOR_INT32_INPUTS(i) {
int64_t expected =
@ -1271,7 +1266,7 @@ WASM_EXEC_TEST(LoadMemI64) {
r.builder().AddMemoryElems<int64_t>(kWasmPageSize / sizeof(int64_t));
r.builder().RandomizeMemory(1111);
BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO));
r.Build({WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO)});
r.builder().WriteMemory<int64_t>(&memory[0], 0x1ABBCCDD00112233LL);
CHECK_EQ(0x1ABBCCDD00112233LL, r.Call());
@ -1290,8 +1285,8 @@ WASM_EXEC_TEST(LoadMemI64_alignment) {
r.builder().AddMemoryElems<int64_t>(kWasmPageSize / sizeof(int64_t));
r.builder().RandomizeMemory(1111);
BUILD(r,
WASM_LOAD_MEM_ALIGNMENT(MachineType::Int64(), WASM_ZERO, alignment));
r.Build(
{WASM_LOAD_MEM_ALIGNMENT(MachineType::Int64(), WASM_ZERO, alignment)});
r.builder().WriteMemory<int64_t>(&memory[0], 0x1ABBCCDD00112233LL);
CHECK_EQ(0x1ABBCCDD00112233LL, r.Call());
@ -1311,17 +1306,16 @@ WASM_EXEC_TEST(MemI64_Sum) {
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
const byte kSum = r.AllocateLocal(kWasmI64);
BUILD(
r,
WASM_WHILE(
WASM_LOCAL_GET(0),
WASM_BLOCK(WASM_LOCAL_SET(
kSum, WASM_I64_ADD(WASM_LOCAL_GET(kSum),
WASM_LOAD_MEM(MachineType::Int64(),
WASM_LOCAL_GET(0)))),
WASM_LOCAL_SET(
0, WASM_I32_SUB(WASM_LOCAL_GET(0), WASM_I32V_1(8))))),
WASM_LOCAL_GET(1));
r.Build(
{WASM_WHILE(
WASM_LOCAL_GET(0),
WASM_BLOCK(WASM_LOCAL_SET(
kSum, WASM_I64_ADD(WASM_LOCAL_GET(kSum),
WASM_LOAD_MEM(MachineType::Int64(),
WASM_LOCAL_GET(0)))),
WASM_LOCAL_SET(
0, WASM_I32_SUB(WASM_LOCAL_GET(0), WASM_I32V_1(8))))),
WASM_LOCAL_GET(1)});
// Run 4 trials.
for (int i = 0; i < 3; i++) {
@ -1342,10 +1336,9 @@ WASM_EXEC_TEST(StoreMemI64_alignment) {
WasmRunner<int64_t, int64_t> r(execution_tier);
int64_t* memory =
r.builder().AddMemoryElems<int64_t>(kWasmPageSize / sizeof(int64_t));
BUILD(r,
WASM_STORE_MEM_ALIGNMENT(MachineType::Int64(), WASM_ZERO, i,
WASM_LOCAL_GET(0)),
WASM_LOCAL_GET(0));
r.Build({WASM_STORE_MEM_ALIGNMENT(MachineType::Int64(), WASM_ZERO, i,
WASM_LOCAL_GET(0)),
WASM_LOCAL_GET(0)});
r.builder().RandomizeMemory(1111);
r.builder().WriteMemory<int64_t>(&memory[0], 0);
@ -1358,11 +1351,10 @@ WASM_EXEC_TEST(I64Global) {
WasmRunner<int32_t, int32_t> r(execution_tier);
int64_t* global = r.builder().AddGlobal<int64_t>();
// global = global + p0
BUILD(r,
WASM_GLOBAL_SET(0,
WASM_I64_AND(WASM_GLOBAL_GET(0),
WASM_I64_SCONVERT_I32(WASM_LOCAL_GET(0)))),
WASM_ZERO);
r.Build({WASM_GLOBAL_SET(
0, WASM_I64_AND(WASM_GLOBAL_GET(0),
WASM_I64_SCONVERT_I32(WASM_LOCAL_GET(0)))),
WASM_ZERO});
r.builder().WriteMemory<int64_t>(global, 0xFFFFFFFFFFFFFFFFLL);
for (int i = 9; i < 444444; i += 111111) {
@ -1374,7 +1366,7 @@ WASM_EXEC_TEST(I64Global) {
WASM_EXEC_TEST(I64Eqz) {
WasmRunner<int32_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_EQZ(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_EQZ(WASM_LOCAL_GET(0))});
FOR_INT64_INPUTS(i) {
int32_t result = i == 0 ? 1 : 0;
@ -1384,7 +1376,7 @@ WASM_EXEC_TEST(I64Eqz) {
WASM_EXEC_TEST(I64Ror) {
WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_ROR(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_ROR(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) {
@ -1396,7 +1388,7 @@ WASM_EXEC_TEST(I64Ror) {
WASM_EXEC_TEST(I64Rol) {
WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_ROL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_ROL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) {
@ -1420,10 +1412,9 @@ WASM_EXEC_TEST(StoreMem_offset_oob_i64) {
byte* memory = r.builder().AddMemoryElems<byte>(num_bytes);
r.builder().RandomizeMemory(1119 + static_cast<int>(m));
BUILD(r,
WASM_STORE_MEM_OFFSET(machineTypes[m], 8, WASM_LOCAL_GET(0),
WASM_LOAD_MEM(machineTypes[m], WASM_ZERO)),
WASM_ZERO);
r.Build({WASM_STORE_MEM_OFFSET(machineTypes[m], 8, WASM_LOCAL_GET(0),
WASM_LOAD_MEM(machineTypes[m], WASM_ZERO)),
WASM_ZERO});
byte memsize = machineTypes[m].MemSize();
uint32_t boundary = num_bytes - 8 - memsize;
@ -1448,10 +1439,10 @@ WASM_EXEC_TEST(Store_i64_narrowed) {
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize);
constexpr uint64_t kPattern = 0x0123456789abcdef;
BUILD(r, WASM_LOCAL_GET(0), // index
WASM_LOCAL_GET(1), // value
opcode, ZERO_ALIGNMENT, ZERO_OFFSET, // store
WASM_ZERO); // return value
r.Build({WASM_LOCAL_GET(0), // index
WASM_LOCAL_GET(1), // value
opcode, ZERO_ALIGNMENT, ZERO_OFFSET, // store
WASM_ZERO}); // return value
for (int i = 0; i <= kBytes - stored_size_in_bytes; ++i) {
uint64_t pattern = base::bits::RotateLeft64(kPattern, i % 64);
@ -1469,16 +1460,16 @@ WASM_EXEC_TEST(Store_i64_narrowed) {
WASM_EXEC_TEST(UnalignedInt64Load) {
WasmRunner<uint64_t> r(execution_tier);
r.builder().AddMemoryElems<int64_t>(kWasmPageSize / sizeof(int64_t));
BUILD(r, WASM_LOAD_MEM_ALIGNMENT(MachineType::Int64(), WASM_ONE, 3));
r.Build({WASM_LOAD_MEM_ALIGNMENT(MachineType::Int64(), WASM_ONE, 3)});
r.Call();
}
WASM_EXEC_TEST(UnalignedInt64Store) {
WasmRunner<int32_t> r(execution_tier);
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(int64_t));
BUILD(r, WASM_SEQ(WASM_STORE_MEM_ALIGNMENT(MachineType::Int64(), WASM_ONE, 3,
r.Build({WASM_SEQ(WASM_STORE_MEM_ALIGNMENT(MachineType::Int64(), WASM_ONE, 3,
WASM_I64V_1(1)),
WASM_I32V_1(12)));
WASM_I32V_1(12))});
r.Call();
}
@ -1503,7 +1494,7 @@ static void CompileCallIndirectMany(TestExecutionTier tier, ValueType param) {
ADD_CODE(code, kExprI32Const, 0);
ADD_CODE(code, kExprCallIndirect, 1, TABLE_ZERO);
t.Build(&code[0], &code[0] + code.size());
t.Build(base::VectorOf(code));
}
}
@ -1541,7 +1532,7 @@ static void Run_WasmMixedCall_N(TestExecutionTier execution_tier, int start) {
b.AddParam(ValueType::For(memtypes[i]));
}
WasmFunctionCompiler& f = r.NewFunction(b.Build());
BUILD(f, WASM_LOCAL_GET(which));
f.Build({WASM_LOCAL_GET(which)});
// =========================================================================
// Build the calling function.
@ -1595,11 +1586,11 @@ WASM_EXEC_TEST(Regress5874) {
WasmRunner<int32_t> r(execution_tier);
r.builder().AddMemoryElems<int64_t>(kWasmPageSize / sizeof(int64_t));
BUILD(r, kExprI64Const, 0x00, // --
kExprI32ConvertI64, // --
kExprI64Const, 0x00, // --
kExprI64StoreMem, 0x03, 0x00, // --
kExprI32Const, 0x00); // --
r.Build({kExprI64Const, 0x00, // --
kExprI32ConvertI64, // --
kExprI64Const, 0x00, // --
kExprI64StoreMem, 0x03, 0x00, // --
kExprI32Const, 0x00}); // --
r.Call();
}
@ -1607,7 +1598,7 @@ WASM_EXEC_TEST(Regress5874) {
WASM_EXEC_TEST(Regression_6858) {
// WasmRunner with 5 params and returns, which is the maximum.
WasmRunner<int64_t, int64_t, int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_DIVS(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I64_DIVS(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
int64_t dividend = 15;
int64_t divisor = 0;
int64_t filler = 34;

View File

@ -32,7 +32,8 @@ namespace wasm {
ASMJS_EXEC_TEST(Int32AsmjsDivS) {
WasmRunner<int32_t, int32_t, int32_t> r(execution_tier, kAsmJsSloppyOrigin);
BUILD(r, WASM_BINOP(kExprI32AsmjsDivS, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build(
{WASM_BINOP(kExprI32AsmjsDivS, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
const int32_t kMin = std::numeric_limits<int32_t>::min();
CHECK_EQ(0, r.Call(0, 100));
CHECK_EQ(0, r.Call(100, 0));
@ -43,7 +44,8 @@ ASMJS_EXEC_TEST(Int32AsmjsDivS) {
ASMJS_EXEC_TEST(Int32AsmjsRemS) {
WasmRunner<int32_t, int32_t, int32_t> r(execution_tier, kAsmJsSloppyOrigin);
BUILD(r, WASM_BINOP(kExprI32AsmjsRemS, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build(
{WASM_BINOP(kExprI32AsmjsRemS, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
const int32_t kMin = std::numeric_limits<int32_t>::min();
CHECK_EQ(33, r.Call(133, 100));
CHECK_EQ(0, r.Call(kMin, -1));
@ -54,7 +56,8 @@ ASMJS_EXEC_TEST(Int32AsmjsRemS) {
ASMJS_EXEC_TEST(Int32AsmjsDivU) {
WasmRunner<int32_t, int32_t, int32_t> r(execution_tier, kAsmJsSloppyOrigin);
BUILD(r, WASM_BINOP(kExprI32AsmjsDivU, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build(
{WASM_BINOP(kExprI32AsmjsDivU, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
const int32_t kMin = std::numeric_limits<int32_t>::min();
CHECK_EQ(0, r.Call(0, 100));
CHECK_EQ(0, r.Call(kMin, -1));
@ -65,7 +68,8 @@ ASMJS_EXEC_TEST(Int32AsmjsDivU) {
ASMJS_EXEC_TEST(Int32AsmjsRemU) {
WasmRunner<int32_t, int32_t, int32_t> r(execution_tier, kAsmJsSloppyOrigin);
BUILD(r, WASM_BINOP(kExprI32AsmjsRemU, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build(
{WASM_BINOP(kExprI32AsmjsRemU, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
const int32_t kMin = std::numeric_limits<int32_t>::min();
CHECK_EQ(17, r.Call(217, 100));
CHECK_EQ(0, r.Call(100, 0));
@ -76,7 +80,7 @@ ASMJS_EXEC_TEST(Int32AsmjsRemU) {
ASMJS_EXEC_TEST(I32AsmjsSConvertF32) {
WasmRunner<int32_t, float> r(execution_tier, kAsmJsSloppyOrigin);
BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF32, WASM_LOCAL_GET(0)));
r.Build({WASM_UNOP(kExprI32AsmjsSConvertF32, WASM_LOCAL_GET(0))});
FOR_FLOAT32_INPUTS(i) {
int32_t expected = DoubleToInt32(i);
@ -86,7 +90,7 @@ ASMJS_EXEC_TEST(I32AsmjsSConvertF32) {
ASMJS_EXEC_TEST(I32AsmjsSConvertF64) {
WasmRunner<int32_t, double> r(execution_tier, kAsmJsSloppyOrigin);
BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF64, WASM_LOCAL_GET(0)));
r.Build({WASM_UNOP(kExprI32AsmjsSConvertF64, WASM_LOCAL_GET(0))});
FOR_FLOAT64_INPUTS(i) {
int32_t expected = DoubleToInt32(i);
@ -96,7 +100,7 @@ ASMJS_EXEC_TEST(I32AsmjsSConvertF64) {
ASMJS_EXEC_TEST(I32AsmjsUConvertF32) {
WasmRunner<uint32_t, float> r(execution_tier, kAsmJsSloppyOrigin);
BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF32, WASM_LOCAL_GET(0)));
r.Build({WASM_UNOP(kExprI32AsmjsUConvertF32, WASM_LOCAL_GET(0))});
FOR_FLOAT32_INPUTS(i) {
uint32_t expected = DoubleToUint32(i);
@ -106,7 +110,7 @@ ASMJS_EXEC_TEST(I32AsmjsUConvertF32) {
ASMJS_EXEC_TEST(I32AsmjsUConvertF64) {
WasmRunner<uint32_t, double> r(execution_tier, kAsmJsSloppyOrigin);
BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF64, WASM_LOCAL_GET(0)));
r.Build({WASM_UNOP(kExprI32AsmjsUConvertF64, WASM_LOCAL_GET(0))});
FOR_FLOAT64_INPUTS(i) {
uint32_t expected = DoubleToUint32(i);
@ -119,7 +123,7 @@ ASMJS_EXEC_TEST(LoadMemI32_oob_asm) {
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
r.builder().RandomizeMemory(1112);
BUILD(r, WASM_UNOP(kExprI32AsmjsLoadMem, WASM_LOCAL_GET(0)));
r.Build({WASM_UNOP(kExprI32AsmjsLoadMem, WASM_LOCAL_GET(0))});
memory[0] = 999999;
CHECK_EQ(999999, r.Call(0u));
@ -138,7 +142,7 @@ ASMJS_EXEC_TEST(LoadMemF32_oob_asm) {
float* memory = r.builder().AddMemoryElems<float>(8);
r.builder().RandomizeMemory(1112);
BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_LOCAL_GET(0)));
r.Build({WASM_UNOP(kExprF32AsmjsLoadMem, WASM_LOCAL_GET(0))});
memory[0] = 9999.5f;
CHECK_EQ(9999.5f, r.Call(0u));
@ -157,7 +161,7 @@ ASMJS_EXEC_TEST(LoadMemF64_oob_asm) {
double* memory = r.builder().AddMemoryElems<double>(8);
r.builder().RandomizeMemory(1112);
BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_LOCAL_GET(0)));
r.Build({WASM_UNOP(kExprF64AsmjsLoadMem, WASM_LOCAL_GET(0))});
memory[0] = 9799.5;
CHECK_EQ(9799.5, r.Call(0u));
@ -178,8 +182,8 @@ ASMJS_EXEC_TEST(StoreMemI32_oob_asm) {
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
r.builder().RandomizeMemory(1112);
BUILD(r, WASM_BINOP(kExprI32AsmjsStoreMem, WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1)));
r.Build({WASM_BINOP(kExprI32AsmjsStoreMem, WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1))});
memory[0] = 7777;
CHECK_EQ(999999, r.Call(0u, 999999));
@ -197,7 +201,7 @@ ASMJS_EXEC_TEST(StoreMemI32_oob_asm) {
ASMJS_EXEC_TEST(Int32AsmjsDivS_byzero_const) {
for (int8_t denom = -2; denom < 8; ++denom) {
WasmRunner<int32_t, int32_t> r(execution_tier, kAsmJsSloppyOrigin);
BUILD(r, WASM_I32_ASMJS_DIVS(WASM_LOCAL_GET(0), WASM_I32V_1(denom)));
r.Build({WASM_I32_ASMJS_DIVS(WASM_LOCAL_GET(0), WASM_I32V_1(denom))});
FOR_INT32_INPUTS(i) {
if (denom == 0) {
CHECK_EQ(0, r.Call(i));
@ -213,7 +217,7 @@ ASMJS_EXEC_TEST(Int32AsmjsDivS_byzero_const) {
ASMJS_EXEC_TEST(Int32AsmjsRemS_byzero_const) {
for (int8_t denom = -2; denom < 8; ++denom) {
WasmRunner<int32_t, int32_t> r(execution_tier, kAsmJsSloppyOrigin);
BUILD(r, WASM_I32_ASMJS_REMS(WASM_LOCAL_GET(0), WASM_I32V_1(denom)));
r.Build({WASM_I32_ASMJS_REMS(WASM_LOCAL_GET(0), WASM_I32V_1(denom))});
FOR_INT32_INPUTS(i) {
if (denom == 0) {
CHECK_EQ(0, r.Call(i));

View File

@ -17,8 +17,8 @@ void RunU32BinOp(TestExecutionTier execution_tier, WasmOpcode wasm_op,
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
r.builder().SetHasSharedMemory();
BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord32));
r.Build({WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord32)});
FOR_UINT32_INPUTS(i) {
uint32_t initial = i;
@ -45,8 +45,8 @@ void RunU16BinOp(TestExecutionTier tier, WasmOpcode wasm_op,
uint16_t* memory =
r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t));
BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord16));
r.Build({WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord16)});
FOR_UINT16_INPUTS(i) {
uint16_t initial = i;
@ -72,8 +72,8 @@ void RunU8BinOp(TestExecutionTier execution_tier, WasmOpcode wasm_op,
r.builder().SetHasSharedMemory();
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize);
BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord8));
r.Build({WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord8)});
FOR_UINT8_INPUTS(i) {
uint8_t initial = i;
@ -98,9 +98,9 @@ WASM_EXEC_TEST(I32AtomicCompareExchange) {
r.builder().SetHasSharedMemory();
uint32_t* memory =
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
BUILD(r, WASM_ATOMICS_TERNARY_OP(
kExprI32AtomicCompareExchange, WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord32));
r.Build({WASM_ATOMICS_TERNARY_OP(
kExprI32AtomicCompareExchange, WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord32)});
FOR_UINT32_INPUTS(i) {
uint32_t initial = i;
@ -118,10 +118,9 @@ WASM_EXEC_TEST(I32AtomicCompareExchange16U) {
r.builder().SetHasSharedMemory();
uint16_t* memory =
r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t));
BUILD(r, WASM_ATOMICS_TERNARY_OP(kExprI32AtomicCompareExchange16U,
WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1),
MachineRepresentation::kWord16));
r.Build({WASM_ATOMICS_TERNARY_OP(
kExprI32AtomicCompareExchange16U, WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord16)});
FOR_UINT16_INPUTS(i) {
uint16_t initial = i;
@ -138,10 +137,9 @@ WASM_EXEC_TEST(I32AtomicCompareExchange8U) {
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().SetHasSharedMemory();
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize);
BUILD(r,
WASM_ATOMICS_TERNARY_OP(kExprI32AtomicCompareExchange8U, WASM_I32V_1(0),
WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
MachineRepresentation::kWord8));
r.Build({WASM_ATOMICS_TERNARY_OP(
kExprI32AtomicCompareExchange8U, WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord8)});
FOR_UINT8_INPUTS(i) {
uint8_t initial = i;
@ -159,9 +157,9 @@ WASM_EXEC_TEST(I32AtomicCompareExchange_fail) {
r.builder().SetHasSharedMemory();
uint32_t* memory =
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
BUILD(r, WASM_ATOMICS_TERNARY_OP(
kExprI32AtomicCompareExchange, WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord32));
r.Build({WASM_ATOMICS_TERNARY_OP(
kExprI32AtomicCompareExchange, WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord32)});
// The original value at the memory location.
uint32_t old_val = 4;
@ -180,8 +178,8 @@ WASM_EXEC_TEST(I32AtomicLoad) {
r.builder().SetHasSharedMemory();
uint32_t* memory =
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad, WASM_ZERO,
MachineRepresentation::kWord32));
r.Build({WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad, WASM_ZERO,
MachineRepresentation::kWord32)});
FOR_UINT32_INPUTS(i) {
uint32_t expected = i;
@ -195,8 +193,8 @@ WASM_EXEC_TEST(I32AtomicLoad16U) {
r.builder().SetHasSharedMemory();
uint16_t* memory =
r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t));
BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad16U, WASM_ZERO,
MachineRepresentation::kWord16));
r.Build({WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad16U, WASM_ZERO,
MachineRepresentation::kWord16)});
FOR_UINT16_INPUTS(i) {
uint16_t expected = i;
@ -209,8 +207,8 @@ WASM_EXEC_TEST(I32AtomicLoad8U) {
WasmRunner<uint32_t> r(execution_tier);
r.builder().SetHasSharedMemory();
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize);
BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad8U, WASM_ZERO,
MachineRepresentation::kWord8));
r.Build({WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad8U, WASM_ZERO,
MachineRepresentation::kWord8)});
FOR_UINT8_INPUTS(i) {
uint8_t expected = i;
@ -225,11 +223,11 @@ WASM_EXEC_TEST(I32AtomicStoreLoad) {
uint32_t* memory =
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
BUILD(r,
WASM_ATOMICS_STORE_OP(kExprI32AtomicStore, WASM_ZERO, WASM_LOCAL_GET(0),
MachineRepresentation::kWord32),
WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad, WASM_ZERO,
MachineRepresentation::kWord32));
r.Build(
{WASM_ATOMICS_STORE_OP(kExprI32AtomicStore, WASM_ZERO, WASM_LOCAL_GET(0),
MachineRepresentation::kWord32),
WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad, WASM_ZERO,
MachineRepresentation::kWord32)});
FOR_UINT32_INPUTS(i) {
uint32_t expected = i;
@ -244,12 +242,11 @@ WASM_EXEC_TEST(I32AtomicStoreLoad16U) {
uint16_t* memory =
r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t));
BUILD(
r,
WASM_ATOMICS_STORE_OP(kExprI32AtomicStore16U, WASM_ZERO,
WASM_LOCAL_GET(0), MachineRepresentation::kWord16),
WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad16U, WASM_ZERO,
MachineRepresentation::kWord16));
r.Build(
{WASM_ATOMICS_STORE_OP(kExprI32AtomicStore16U, WASM_ZERO,
WASM_LOCAL_GET(0), MachineRepresentation::kWord16),
WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad16U, WASM_ZERO,
MachineRepresentation::kWord16)});
FOR_UINT16_INPUTS(i) {
uint16_t expected = i;
@ -263,11 +260,11 @@ WASM_EXEC_TEST(I32AtomicStoreLoad8U) {
r.builder().SetHasSharedMemory();
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize);
BUILD(r,
WASM_ATOMICS_STORE_OP(kExprI32AtomicStore8U, WASM_ZERO,
WASM_LOCAL_GET(0), MachineRepresentation::kWord8),
WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad8U, WASM_ZERO,
MachineRepresentation::kWord8));
r.Build(
{WASM_ATOMICS_STORE_OP(kExprI32AtomicStore8U, WASM_ZERO,
WASM_LOCAL_GET(0), MachineRepresentation::kWord8),
WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad8U, WASM_ZERO,
MachineRepresentation::kWord8)});
FOR_UINT8_INPUTS(i) {
uint8_t expected = i;
@ -282,11 +279,11 @@ WASM_EXEC_TEST(I32AtomicStoreParameter) {
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
r.builder().SetHasSharedMemory();
BUILD(r,
WASM_ATOMICS_STORE_OP(kExprI32AtomicStore, WASM_ZERO, WASM_LOCAL_GET(0),
MachineRepresentation::kWord8),
WASM_ATOMICS_BINOP(kExprI32AtomicAdd, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord32));
r.Build(
{WASM_ATOMICS_STORE_OP(kExprI32AtomicStore, WASM_ZERO, WASM_LOCAL_GET(0),
MachineRepresentation::kWord8),
WASM_ATOMICS_BINOP(kExprI32AtomicAdd, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord32)});
CHECK_EQ(10, r.Call(10));
CHECK_EQ(20, r.builder().ReadMemory(&memory[0]));
}
@ -298,7 +295,7 @@ WASM_EXEC_TEST(AtomicFence) {
// modules which declare no memory, or a non-shared memory, without causing a
// validation error.
BUILD(r, WASM_ATOMICS_FENCE, WASM_ZERO);
r.Build({WASM_ATOMICS_FENCE, WASM_ZERO});
CHECK_EQ(0, r.Call());
}
@ -308,10 +305,11 @@ WASM_EXEC_TEST(AtomicStoreNoConsideredEffectful) {
WasmRunner<uint32_t> r(execution_tier);
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
r.builder().SetHasSharedMemory();
BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO),
WASM_ATOMICS_STORE_OP(kExprI32AtomicStore, WASM_ZERO, WASM_I32V_1(20),
MachineRepresentation::kWord32),
kExprI64Eqz);
r.Build(
{WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO),
WASM_ATOMICS_STORE_OP(kExprI32AtomicStore, WASM_ZERO, WASM_I32V_1(20),
MachineRepresentation::kWord32),
kExprI64Eqz});
CHECK_EQ(1, r.Call());
}
@ -321,10 +319,10 @@ void RunNoEffectTest(TestExecutionTier execution_tier, WasmOpcode wasm_op) {
WasmRunner<uint32_t> r(execution_tier);
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
r.builder().SetHasSharedMemory();
BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO),
WASM_ATOMICS_BINOP(wasm_op, WASM_ZERO, WASM_I32V_1(20),
MachineRepresentation::kWord32),
WASM_DROP, kExprI64Eqz);
r.Build({WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO),
WASM_ATOMICS_BINOP(wasm_op, WASM_ZERO, WASM_I32V_1(20),
MachineRepresentation::kWord32),
WASM_DROP, kExprI64Eqz});
CHECK_EQ(1, r.Call());
}
@ -342,11 +340,11 @@ WASM_EXEC_TEST(AtomicCompareExchangeNoConsideredEffectful) {
WasmRunner<uint32_t> r(execution_tier);
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
r.builder().SetHasSharedMemory();
BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO),
WASM_ATOMICS_TERNARY_OP(kExprI32AtomicCompareExchange, WASM_ZERO,
WASM_ZERO, WASM_I32V_1(30),
MachineRepresentation::kWord32),
WASM_DROP, kExprI32Eqz);
r.Build({WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO),
WASM_ATOMICS_TERNARY_OP(kExprI32AtomicCompareExchange, WASM_ZERO,
WASM_ZERO, WASM_I32V_1(30),
MachineRepresentation::kWord32),
WASM_DROP, kExprI32Eqz});
CHECK_EQ(1, r.Call());
}
@ -354,8 +352,8 @@ WASM_EXEC_TEST(I32AtomicLoad_trap) {
WasmRunner<uint32_t> r(execution_tier);
r.builder().SetHasSharedMemory();
r.builder().AddMemory(kWasmPageSize);
BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad, WASM_I32V_3(kWasmPageSize),
MachineRepresentation::kWord32));
r.Build({WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad, WASM_I32V_3(kWasmPageSize),
MachineRepresentation::kWord32)});
CHECK_TRAP(r.Call());
}
@ -363,8 +361,8 @@ WASM_EXEC_TEST(I64AtomicLoad_trap) {
WasmRunner<uint64_t> r(execution_tier);
r.builder().SetHasSharedMemory();
r.builder().AddMemory(kWasmPageSize);
BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad, WASM_I32V_3(kWasmPageSize),
MachineRepresentation::kWord64));
r.Build({WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad, WASM_I32V_3(kWasmPageSize),
MachineRepresentation::kWord64)});
CHECK_TRAP64(r.Call());
}
@ -372,10 +370,10 @@ WASM_EXEC_TEST(I32AtomicStore_trap) {
WasmRunner<uint32_t> r(execution_tier);
r.builder().SetHasSharedMemory();
r.builder().AddMemory(kWasmPageSize);
BUILD(r,
WASM_ATOMICS_STORE_OP(kExprI32AtomicStore, WASM_I32V_3(kWasmPageSize),
WASM_ZERO, MachineRepresentation::kWord32),
WASM_ZERO);
r.Build(
{WASM_ATOMICS_STORE_OP(kExprI32AtomicStore, WASM_I32V_3(kWasmPageSize),
WASM_ZERO, MachineRepresentation::kWord32),
WASM_ZERO});
CHECK_TRAP(r.Call());
}
@ -383,10 +381,10 @@ WASM_EXEC_TEST(I64AtomicStore_trap) {
WasmRunner<uint32_t> r(execution_tier);
r.builder().SetHasSharedMemory();
r.builder().AddMemory(kWasmPageSize);
BUILD(r,
WASM_ATOMICS_STORE_OP(kExprI64AtomicStore, WASM_I32V_3(kWasmPageSize),
WASM_ZERO64, MachineRepresentation::kWord64),
WASM_ZERO);
r.Build(
{WASM_ATOMICS_STORE_OP(kExprI64AtomicStore, WASM_I32V_3(kWasmPageSize),
WASM_ZERO64, MachineRepresentation::kWord64),
WASM_ZERO});
CHECK_TRAP(r.Call());
}
@ -394,10 +392,10 @@ WASM_EXEC_TEST(I32AtomicLoad_NotOptOut) {
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));
r.Build({WASM_I32_AND(
WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad, WASM_I32V_3(kWasmPageSize),
MachineRepresentation::kWord32),
WASM_ZERO)});
CHECK_TRAP(r.Call());
}
@ -406,8 +404,8 @@ void RunU32BinOp_OOB(TestExecutionTier execution_tier, WasmOpcode wasm_op) {
r.builder().AddMemory(kWasmPageSize);
r.builder().SetHasSharedMemory();
BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_3(kWasmPageSize),
WASM_ZERO, MachineRepresentation::kWord32));
r.Build({WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_3(kWasmPageSize), WASM_ZERO,
MachineRepresentation::kWord32)});
CHECK_TRAP(r.Call());
}
@ -424,8 +422,8 @@ void RunU64BinOp_OOB(TestExecutionTier execution_tier, WasmOpcode wasm_op) {
r.builder().AddMemory(kWasmPageSize);
r.builder().SetHasSharedMemory();
BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_3(kWasmPageSize),
WASM_ZERO64, MachineRepresentation::kWord32));
r.Build({WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_3(kWasmPageSize), WASM_ZERO64,
MachineRepresentation::kWord32)});
CHECK_TRAP64(r.Call());
}
@ -442,10 +440,9 @@ WASM_EXEC_TEST(I32AtomicCompareExchange_trap) {
r.builder().SetHasSharedMemory();
uint32_t* memory =
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
BUILD(r, WASM_ATOMICS_TERNARY_OP(
kExprI32AtomicCompareExchange, WASM_I32V_3(kWasmPageSize),
WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
MachineRepresentation::kWord32));
r.Build({WASM_ATOMICS_TERNARY_OP(
kExprI32AtomicCompareExchange, WASM_I32V_3(kWasmPageSize),
WASM_LOCAL_GET(0), WASM_LOCAL_GET(1), MachineRepresentation::kWord32)});
FOR_UINT32_INPUTS(i) {
uint32_t initial = i;
@ -460,10 +457,9 @@ WASM_EXEC_TEST(I64AtomicCompareExchange_trap) {
WasmRunner<uint64_t> r(execution_tier);
r.builder().SetHasSharedMemory();
r.builder().AddMemory(kWasmPageSize);
BUILD(r, WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange, WASM_I32V_3(kWasmPageSize),
WASM_ZERO64, WASM_ZERO64,
MachineRepresentation::kWord64));
r.Build({WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange, WASM_I32V_3(kWasmPageSize), WASM_ZERO64,
WASM_ZERO64, MachineRepresentation::kWord64)});
CHECK_TRAP64(r.Call());
}

View File

@ -17,8 +17,8 @@ void RunU64BinOp(TestExecutionTier execution_tier, WasmOpcode wasm_op,
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
r.builder().SetHasSharedMemory();
BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord64));
r.Build({WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord64)});
FOR_UINT64_INPUTS(i) {
uint64_t initial = i;
@ -45,8 +45,8 @@ void RunU32BinOp(TestExecutionTier execution_tier, WasmOpcode wasm_op,
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
r.builder().SetHasSharedMemory();
BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord32));
r.Build({WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord32)});
FOR_UINT32_INPUTS(i) {
uint32_t initial = i;
@ -73,8 +73,8 @@ void RunU16BinOp(TestExecutionTier tier, WasmOpcode wasm_op,
uint16_t* memory =
r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t));
BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord16));
r.Build({WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord16)});
FOR_UINT16_INPUTS(i) {
uint16_t initial = i;
@ -100,8 +100,8 @@ void RunU8BinOp(TestExecutionTier execution_tier, WasmOpcode wasm_op,
r.builder().SetHasSharedMemory();
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize);
BUILD(r, WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord8));
r.Build({WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord8)});
FOR_UINT8_INPUTS(i) {
uint8_t initial = i;
@ -126,9 +126,9 @@ WASM_EXEC_TEST(I64AtomicCompareExchange) {
r.builder().SetHasSharedMemory();
uint64_t* memory =
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
BUILD(r, WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange, WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord64));
r.Build({WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange, WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord64)});
FOR_UINT64_INPUTS(i) {
uint64_t initial = i;
@ -146,10 +146,9 @@ WASM_EXEC_TEST(I64AtomicCompareExchange32U) {
r.builder().SetHasSharedMemory();
uint32_t* memory =
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
BUILD(r, WASM_ATOMICS_TERNARY_OP(kExprI64AtomicCompareExchange32U,
WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1),
MachineRepresentation::kWord32));
r.Build({WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange32U, WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord32)});
FOR_UINT32_INPUTS(i) {
uint32_t initial = i;
@ -167,10 +166,9 @@ WASM_EXEC_TEST(I64AtomicCompareExchange16U) {
r.builder().SetHasSharedMemory();
uint16_t* memory =
r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t));
BUILD(r, WASM_ATOMICS_TERNARY_OP(kExprI64AtomicCompareExchange16U,
WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1),
MachineRepresentation::kWord16));
r.Build({WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange16U, WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord16)});
FOR_UINT16_INPUTS(i) {
uint16_t initial = i;
@ -187,10 +185,9 @@ WASM_EXEC_TEST(I32AtomicCompareExchange8U) {
WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier);
r.builder().SetHasSharedMemory();
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize);
BUILD(r,
WASM_ATOMICS_TERNARY_OP(kExprI64AtomicCompareExchange8U, WASM_I32V_1(0),
WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
MachineRepresentation::kWord8));
r.Build({WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange8U, WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord8)});
FOR_UINT8_INPUTS(i) {
uint8_t initial = i;
FOR_UINT8_INPUTS(j) {
@ -207,8 +204,8 @@ WASM_EXEC_TEST(I64AtomicLoad) {
r.builder().SetHasSharedMemory();
uint64_t* memory =
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad, WASM_ZERO,
MachineRepresentation::kWord64));
r.Build({WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad, WASM_ZERO,
MachineRepresentation::kWord64)});
FOR_UINT64_INPUTS(i) {
uint64_t expected = i;
@ -222,8 +219,8 @@ WASM_EXEC_TEST(I64AtomicLoad32U) {
r.builder().SetHasSharedMemory();
uint32_t* memory =
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad32U, WASM_ZERO,
MachineRepresentation::kWord32));
r.Build({WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad32U, WASM_ZERO,
MachineRepresentation::kWord32)});
FOR_UINT32_INPUTS(i) {
uint32_t expected = i;
@ -237,8 +234,8 @@ WASM_EXEC_TEST(I64AtomicLoad16U) {
r.builder().SetHasSharedMemory();
uint16_t* memory =
r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t));
BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad16U, WASM_ZERO,
MachineRepresentation::kWord16));
r.Build({WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad16U, WASM_ZERO,
MachineRepresentation::kWord16)});
FOR_UINT16_INPUTS(i) {
uint16_t expected = i;
@ -251,8 +248,8 @@ WASM_EXEC_TEST(I64AtomicLoad8U) {
WasmRunner<uint64_t> r(execution_tier);
r.builder().SetHasSharedMemory();
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize);
BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad8U, WASM_ZERO,
MachineRepresentation::kWord8));
r.Build({WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad8U, WASM_ZERO,
MachineRepresentation::kWord8)});
FOR_UINT8_INPUTS(i) {
uint8_t expected = i;
@ -267,11 +264,11 @@ WASM_EXEC_TEST(I64AtomicStoreLoad) {
uint64_t* memory =
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
BUILD(r,
WASM_ATOMICS_STORE_OP(kExprI64AtomicStore, WASM_ZERO, WASM_LOCAL_GET(0),
MachineRepresentation::kWord64),
WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad, WASM_ZERO,
MachineRepresentation::kWord64));
r.Build(
{WASM_ATOMICS_STORE_OP(kExprI64AtomicStore, WASM_ZERO, WASM_LOCAL_GET(0),
MachineRepresentation::kWord64),
WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad, WASM_ZERO,
MachineRepresentation::kWord64)});
FOR_UINT64_INPUTS(i) {
uint64_t expected = i;
@ -286,12 +283,11 @@ WASM_EXEC_TEST(I64AtomicStoreLoad32U) {
uint32_t* memory =
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
BUILD(
r,
WASM_ATOMICS_STORE_OP(kExprI64AtomicStore32U, WASM_ZERO,
WASM_LOCAL_GET(0), MachineRepresentation::kWord32),
WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad32U, WASM_ZERO,
MachineRepresentation::kWord32));
r.Build(
{WASM_ATOMICS_STORE_OP(kExprI64AtomicStore32U, WASM_ZERO,
WASM_LOCAL_GET(0), MachineRepresentation::kWord32),
WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad32U, WASM_ZERO,
MachineRepresentation::kWord32)});
FOR_UINT32_INPUTS(i) {
uint32_t expected = i;
@ -306,12 +302,11 @@ WASM_EXEC_TEST(I64AtomicStoreLoad16U) {
uint16_t* memory =
r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t));
BUILD(
r,
WASM_ATOMICS_STORE_OP(kExprI64AtomicStore16U, WASM_ZERO,
WASM_LOCAL_GET(0), MachineRepresentation::kWord16),
WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad16U, WASM_ZERO,
MachineRepresentation::kWord16));
r.Build(
{WASM_ATOMICS_STORE_OP(kExprI64AtomicStore16U, WASM_ZERO,
WASM_LOCAL_GET(0), MachineRepresentation::kWord16),
WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad16U, WASM_ZERO,
MachineRepresentation::kWord16)});
FOR_UINT16_INPUTS(i) {
uint16_t expected = i;
@ -325,11 +320,11 @@ WASM_EXEC_TEST(I64AtomicStoreLoad8U) {
r.builder().SetHasSharedMemory();
uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize);
BUILD(r,
WASM_ATOMICS_STORE_OP(kExprI64AtomicStore8U, WASM_ZERO,
WASM_LOCAL_GET(0), MachineRepresentation::kWord8),
WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad8U, WASM_ZERO,
MachineRepresentation::kWord8));
r.Build(
{WASM_ATOMICS_STORE_OP(kExprI64AtomicStore8U, WASM_ZERO,
WASM_LOCAL_GET(0), MachineRepresentation::kWord8),
WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad8U, WASM_ZERO,
MachineRepresentation::kWord8)});
FOR_UINT8_INPUTS(i) {
uint8_t expected = i;
@ -347,10 +342,9 @@ void RunDropTest(TestExecutionTier execution_tier, WasmOpcode wasm_op,
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
r.builder().SetHasSharedMemory();
BUILD(r,
WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord64),
WASM_DROP, WASM_LOCAL_GET(0));
r.Build({WASM_ATOMICS_BINOP(wasm_op, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord64),
WASM_DROP, WASM_LOCAL_GET(0)});
uint64_t initial = 0x1111222233334444, local = 0x1111111111111111;
r.builder().WriteMemory(&memory[0], initial);
@ -372,10 +366,10 @@ WASM_EXEC_TEST(I64AtomicSub16UDrop) {
r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t));
r.builder().SetHasSharedMemory();
BUILD(r,
WASM_ATOMICS_BINOP(kExprI64AtomicSub16U, WASM_I32V_1(0),
WASM_LOCAL_GET(0), MachineRepresentation::kWord16),
WASM_DROP, WASM_LOCAL_GET(0));
r.Build(
{WASM_ATOMICS_BINOP(kExprI64AtomicSub16U, WASM_I32V_1(0),
WASM_LOCAL_GET(0), MachineRepresentation::kWord16),
WASM_DROP, WASM_LOCAL_GET(0)});
uint16_t initial = 0x7, local = 0xffe0;
r.builder().WriteMemory(&memory[0], initial);
@ -389,11 +383,10 @@ WASM_EXEC_TEST(I64AtomicCompareExchangeDrop) {
r.builder().SetHasSharedMemory();
uint64_t* memory =
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
BUILD(r,
WASM_ATOMICS_TERNARY_OP(kExprI64AtomicCompareExchange, WASM_I32V_1(0),
WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
MachineRepresentation::kWord64),
WASM_DROP, WASM_LOCAL_GET(1));
r.Build({WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange, WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord64),
WASM_DROP, WASM_LOCAL_GET(1)});
uint64_t initial = 0x1111222233334444, local = 0x1111111111111111;
r.builder().WriteMemory(&memory[0], initial);
@ -408,12 +401,12 @@ WASM_EXEC_TEST(I64AtomicStoreLoadDrop) {
uint64_t* memory =
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
BUILD(r,
WASM_ATOMICS_STORE_OP(kExprI64AtomicStore, WASM_ZERO, WASM_LOCAL_GET(0),
MachineRepresentation::kWord64),
WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad, WASM_ZERO,
r.Build(
{WASM_ATOMICS_STORE_OP(kExprI64AtomicStore, WASM_ZERO, WASM_LOCAL_GET(0),
MachineRepresentation::kWord64),
WASM_DROP, WASM_LOCAL_GET(1));
WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad, WASM_ZERO,
MachineRepresentation::kWord64),
WASM_DROP, WASM_LOCAL_GET(1)});
uint64_t store_value = 0x1111111111111111, expected = 0xC0DE;
CHECK_EQ(expected, r.Call(store_value, expected));
@ -426,10 +419,10 @@ WASM_EXEC_TEST(I64AtomicAddConvertDrop) {
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
r.builder().SetHasSharedMemory();
BUILD(r,
WASM_ATOMICS_BINOP(kExprI64AtomicAdd, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord64),
kExprI32ConvertI64, WASM_DROP, WASM_LOCAL_GET(0));
r.Build(
{WASM_ATOMICS_BINOP(kExprI64AtomicAdd, WASM_I32V_1(0), WASM_LOCAL_GET(0),
MachineRepresentation::kWord64),
kExprI32ConvertI64, WASM_DROP, WASM_LOCAL_GET(0)});
uint64_t initial = 0x1111222233334444, local = 0x1111111111111111;
r.builder().WriteMemory(&memory[0], initial);
@ -444,8 +437,8 @@ WASM_EXEC_TEST(I64AtomicLoadConvertDrop) {
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
r.builder().SetHasSharedMemory();
BUILD(r, WASM_I32_CONVERT_I64(WASM_ATOMICS_LOAD_OP(
kExprI64AtomicLoad, WASM_ZERO, MachineRepresentation::kWord64)));
r.Build({WASM_I32_CONVERT_I64(WASM_ATOMICS_LOAD_OP(
kExprI64AtomicLoad, WASM_ZERO, MachineRepresentation::kWord64))});
uint64_t initial = 0x1111222233334444;
r.builder().WriteMemory(&memory[0], initial);
@ -461,9 +454,8 @@ void RunConvertTest(TestExecutionTier execution_tier, WasmOpcode wasm_op,
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
r.builder().SetHasSharedMemory();
BUILD(r, WASM_I32_CONVERT_I64(
WASM_ATOMICS_BINOP(wasm_op, WASM_ZERO, WASM_LOCAL_GET(0),
MachineRepresentation::kWord64)));
r.Build({WASM_I32_CONVERT_I64(WASM_ATOMICS_BINOP(
wasm_op, WASM_ZERO, WASM_LOCAL_GET(0), MachineRepresentation::kWord64))});
uint64_t initial = 0x1111222233334444, local = 0x1111111111111111;
r.builder().WriteMemory(&memory[0], initial);
@ -485,9 +477,9 @@ WASM_EXEC_TEST(I64AtomicConvertCompareExchange) {
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
r.builder().SetHasSharedMemory();
BUILD(r, WASM_I32_CONVERT_I64(WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange, WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord64)));
r.Build({WASM_I32_CONVERT_I64(WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange, WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord64))});
uint64_t initial = 0x1111222233334444, local = 0x1111111111111111;
r.builder().WriteMemory(&memory[0], initial);
@ -505,9 +497,9 @@ void RunNonConstIndexTest(TestExecutionTier execution_tier, WasmOpcode wasm_op,
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
r.builder().SetHasSharedMemory();
BUILD(r, WASM_I32_CONVERT_I64(WASM_ATOMICS_BINOP(
wasm_op, WASM_I64_EQ(WASM_I64V(1), WASM_I64V(0)),
WASM_LOCAL_GET(0), MachineRepresentation::kWord32)));
r.Build({WASM_I32_CONVERT_I64(
WASM_ATOMICS_BINOP(wasm_op, WASM_I64_EQ(WASM_I64V(1), WASM_I64V(0)),
WASM_LOCAL_GET(0), MachineRepresentation::kWord32))});
uint64_t initial = 0x1111222233334444, local = 0x5555666677778888;
r.builder().WriteMemory(&memory[0], initial);
@ -538,10 +530,9 @@ WASM_EXEC_TEST(I64AtomicNonConstIndexCompareExchangeNarrow) {
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
r.builder().SetHasSharedMemory();
BUILD(r, WASM_I32_CONVERT_I64(WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange16U,
WASM_I64_EQ(WASM_I64V(1), WASM_I64V(0)), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord16)));
r.Build({WASM_I32_CONVERT_I64(WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange16U, WASM_I64_EQ(WASM_I64V(1), WASM_I64V(0)),
WASM_LOCAL_GET(0), WASM_LOCAL_GET(1), MachineRepresentation::kWord16))});
uint64_t initial = 0x4444333322221111, local = 0x9999888877776666;
r.builder().WriteMemory(&memory[0], initial);
@ -556,10 +547,9 @@ WASM_EXEC_TEST(I64AtomicNonConstIndexCompareExchange) {
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
r.builder().SetHasSharedMemory();
BUILD(r, WASM_I32_CONVERT_I64(WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange,
WASM_I64_EQ(WASM_I64V(1), WASM_I64V(0)), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord16)));
r.Build({WASM_I32_CONVERT_I64(WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange, WASM_I64_EQ(WASM_I64V(1), WASM_I64V(0)),
WASM_LOCAL_GET(0), WASM_LOCAL_GET(1), MachineRepresentation::kWord16))});
uint64_t initial = 4444333322221111, local = 0x9999888877776666;
r.builder().WriteMemory(&memory[0], initial);
@ -573,9 +563,9 @@ WASM_EXEC_TEST(I64AtomicNonConstIndexLoad8U) {
r.builder().SetHasSharedMemory();
uint64_t* memory =
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
BUILD(r, WASM_I32_CONVERT_I64(WASM_ATOMICS_LOAD_OP(
kExprI64AtomicLoad8U, WASM_I64_EQ(WASM_I64V(1), WASM_I64V(0)),
MachineRepresentation::kWord8)));
r.Build({WASM_I32_CONVERT_I64(WASM_ATOMICS_LOAD_OP(
kExprI64AtomicLoad8U, WASM_I64_EQ(WASM_I64V(1), WASM_I64V(0)),
MachineRepresentation::kWord8))});
uint64_t expected = 0xffffeeeeddddcccc;
r.builder().WriteMemory(&memory[0], expected);
@ -587,9 +577,9 @@ WASM_EXEC_TEST(I64AtomicCompareExchangeFail) {
r.builder().SetHasSharedMemory();
uint64_t* memory =
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
BUILD(r, WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange, WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord64));
r.Build({WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange, WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord64)});
uint64_t initial = 0x1111222233334444, local = 0x1111111111111111,
test = 0x2222222222222222;
@ -604,10 +594,9 @@ WASM_EXEC_TEST(I64AtomicCompareExchange32UFail) {
r.builder().SetHasSharedMemory();
uint64_t* memory =
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
BUILD(r, WASM_ATOMICS_TERNARY_OP(kExprI64AtomicCompareExchange32U,
WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1),
MachineRepresentation::kWord32));
r.Build({WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange32U, WASM_I32V_1(0), WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), MachineRepresentation::kWord32)});
uint64_t initial = 0x1111222233334444, test = 0xffffffff, local = 0xeeeeeeee;
r.builder().WriteMemory(&memory[0], initial);
@ -622,10 +611,10 @@ WASM_EXEC_TEST(AtomicStoreNoConsideredEffectful) {
WasmRunner<uint32_t> r(execution_tier);
r.builder().AddMemoryElems<int64_t>(kWasmPageSize / sizeof(int64_t));
r.builder().SetHasSharedMemory();
BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO),
WASM_ATOMICS_STORE_OP(kExprI64AtomicStore, WASM_ZERO, WASM_I64V(20),
MachineRepresentation::kWord64),
kExprI64Eqz);
r.Build({WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO),
WASM_ATOMICS_STORE_OP(kExprI64AtomicStore, WASM_ZERO, WASM_I64V(20),
MachineRepresentation::kWord64),
kExprI64Eqz});
CHECK_EQ(1, r.Call());
}
@ -635,10 +624,10 @@ void RunNoEffectTest(TestExecutionTier execution_tier, WasmOpcode wasm_op) {
WasmRunner<uint32_t> r(execution_tier);
r.builder().AddMemoryElems<int64_t>(kWasmPageSize / sizeof(int64_t));
r.builder().SetHasSharedMemory();
BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO),
WASM_ATOMICS_BINOP(wasm_op, WASM_ZERO, WASM_I64V(20),
MachineRepresentation::kWord64),
WASM_DROP, kExprI64Eqz);
r.Build({WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO),
WASM_ATOMICS_BINOP(wasm_op, WASM_ZERO, WASM_I64V(20),
MachineRepresentation::kWord64),
WASM_DROP, kExprI64Eqz});
CHECK_EQ(1, r.Call());
}
@ -656,11 +645,11 @@ WASM_EXEC_TEST(AtomicCompareExchangeNoConsideredEffectful) {
WasmRunner<uint32_t> r(execution_tier);
r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t));
r.builder().SetHasSharedMemory();
BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO),
WASM_ATOMICS_TERNARY_OP(kExprI64AtomicCompareExchange, WASM_ZERO,
WASM_I64V(0), WASM_I64V(30),
MachineRepresentation::kWord64),
WASM_DROP, kExprI64Eqz);
r.Build({WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO),
WASM_ATOMICS_TERNARY_OP(kExprI64AtomicCompareExchange, WASM_ZERO,
WASM_I64V(0), WASM_I64V(30),
MachineRepresentation::kWord64),
WASM_DROP, kExprI64Eqz});
CHECK_EQ(1, r.Call());
}
@ -672,9 +661,8 @@ WASM_EXEC_TEST(I64AtomicLoadUseOnlyLowWord) {
r.builder().WriteMemory(&memory[1], initial);
r.builder().SetHasSharedMemory();
// Test that we can use just the low word of an I64AtomicLoad.
BUILD(r,
WASM_I32_CONVERT_I64(WASM_ATOMICS_LOAD_OP(
kExprI64AtomicLoad, WASM_I32V(8), MachineRepresentation::kWord64)));
r.Build({WASM_I32_CONVERT_I64(WASM_ATOMICS_LOAD_OP(
kExprI64AtomicLoad, WASM_I32V(8), MachineRepresentation::kWord64))});
CHECK_EQ(0x90abcdef, r.Call());
}
@ -686,10 +674,10 @@ WASM_EXEC_TEST(I64AtomicLoadUseOnlyHighWord) {
r.builder().WriteMemory(&memory[1], initial);
r.builder().SetHasSharedMemory();
// Test that we can use just the high word of an I64AtomicLoad.
BUILD(r, WASM_I32_CONVERT_I64(WASM_I64_ROR(
WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad, WASM_I32V(8),
MachineRepresentation::kWord64),
WASM_I64V(32))));
r.Build({WASM_I32_CONVERT_I64(
WASM_I64_ROR(WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad, WASM_I32V(8),
MachineRepresentation::kWord64),
WASM_I64V(32)))});
CHECK_EQ(0x12345678, r.Call());
}
@ -701,9 +689,9 @@ WASM_EXEC_TEST(I64AtomicAddUseOnlyLowWord) {
r.builder().WriteMemory(&memory[1], initial);
r.builder().SetHasSharedMemory();
// Test that we can use just the low word of an I64AtomicLoad.
BUILD(r, WASM_I32_CONVERT_I64(
WASM_ATOMICS_BINOP(kExprI64AtomicAdd, WASM_I32V(8), WASM_I64V(1),
MachineRepresentation::kWord64)));
r.Build({WASM_I32_CONVERT_I64(
WASM_ATOMICS_BINOP(kExprI64AtomicAdd, WASM_I32V(8), WASM_I64V(1),
MachineRepresentation::kWord64))});
CHECK_EQ(0x90abcdef, r.Call());
}
@ -715,10 +703,10 @@ WASM_EXEC_TEST(I64AtomicAddUseOnlyHighWord) {
r.builder().WriteMemory(&memory[1], initial);
r.builder().SetHasSharedMemory();
// Test that we can use just the high word of an I64AtomicLoad.
BUILD(r, WASM_I32_CONVERT_I64(WASM_I64_ROR(
WASM_ATOMICS_BINOP(kExprI64AtomicAdd, WASM_I32V(8), WASM_I64V(1),
MachineRepresentation::kWord64),
WASM_I64V(32))));
r.Build({WASM_I32_CONVERT_I64(WASM_I64_ROR(
WASM_ATOMICS_BINOP(kExprI64AtomicAdd, WASM_I32V(8), WASM_I64V(1),
MachineRepresentation::kWord64),
WASM_I64V(32)))});
CHECK_EQ(0x12345678, r.Call());
}
@ -730,9 +718,9 @@ WASM_EXEC_TEST(I64AtomicCompareExchangeUseOnlyLowWord) {
r.builder().WriteMemory(&memory[1], initial);
r.builder().SetHasSharedMemory();
// Test that we can use just the low word of an I64AtomicLoad.
BUILD(r, WASM_I32_CONVERT_I64(WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange, WASM_I32V(8), WASM_I64V(1),
WASM_I64V(memory[1]), MachineRepresentation::kWord64)));
r.Build({WASM_I32_CONVERT_I64(WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange, WASM_I32V(8), WASM_I64V(1),
WASM_I64V(memory[1]), MachineRepresentation::kWord64))});
CHECK_EQ(0x90abcdef, r.Call());
}
@ -744,11 +732,11 @@ WASM_EXEC_TEST(I64AtomicCompareExchangeUseOnlyHighWord) {
r.builder().WriteMemory(&memory[1], initial);
r.builder().SetHasSharedMemory();
// Test that we can use just the high word of an I64AtomicLoad.
BUILD(r, WASM_I32_CONVERT_I64(WASM_I64_ROR(
WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange, WASM_I32V(8), WASM_I64V(1),
WASM_I64V(memory[1]), MachineRepresentation::kWord64),
WASM_I64V(32))));
r.Build({WASM_I32_CONVERT_I64(WASM_I64_ROR(
WASM_ATOMICS_TERNARY_OP(kExprI64AtomicCompareExchange, WASM_I32V(8),
WASM_I64V(1), WASM_I64V(memory[1]),
MachineRepresentation::kWord64),
WASM_I64V(32)))});
CHECK_EQ(0x12345678, r.Call());
}
@ -760,9 +748,9 @@ WASM_EXEC_TEST(I64AtomicExchangeUseOnlyLowWord) {
r.builder().WriteMemory(&memory[1], initial);
r.builder().SetHasSharedMemory();
// Test that we can use just the low word of an I64AtomicLoad.
BUILD(r, WASM_I32_CONVERT_I64(WASM_ATOMICS_BINOP(
kExprI64AtomicExchange, WASM_I32V(8), WASM_I64V(1),
MachineRepresentation::kWord64)));
r.Build({WASM_I32_CONVERT_I64(
WASM_ATOMICS_BINOP(kExprI64AtomicExchange, WASM_I32V(8), WASM_I64V(1),
MachineRepresentation::kWord64))});
CHECK_EQ(0x90abcdef, r.Call());
}
@ -774,10 +762,10 @@ WASM_EXEC_TEST(I64AtomicExchangeUseOnlyHighWord) {
r.builder().WriteMemory(&memory[1], initial);
r.builder().SetHasSharedMemory();
// Test that we can use just the high word of an I64AtomicLoad.
BUILD(r, WASM_I32_CONVERT_I64(WASM_I64_ROR(
WASM_ATOMICS_BINOP(kExprI64AtomicExchange, WASM_I32V(8),
WASM_I64V(1), MachineRepresentation::kWord64),
WASM_I64V(32))));
r.Build({WASM_I32_CONVERT_I64(WASM_I64_ROR(
WASM_ATOMICS_BINOP(kExprI64AtomicExchange, WASM_I32V(8), WASM_I64V(1),
MachineRepresentation::kWord64),
WASM_I64V(32)))});
CHECK_EQ(0x12345678, r.Call());
}
@ -789,10 +777,10 @@ WASM_EXEC_TEST(I64AtomicCompareExchange32UZeroExtended) {
r.builder().SetHasSharedMemory();
// Test that the high word of the expected value is cleared in the return
// value.
BUILD(r, WASM_I64_EQZ(WASM_ATOMICS_TERNARY_OP(
kExprI64AtomicCompareExchange32U, WASM_I32V(8),
WASM_I64V(0x1234567800000000), WASM_I64V(0),
MachineRepresentation::kWord32)));
r.Build({WASM_I64_EQZ(
WASM_ATOMICS_TERNARY_OP(kExprI64AtomicCompareExchange32U, WASM_I32V(8),
WASM_I64V(0x1234567800000000), WASM_I64V(0),
MachineRepresentation::kWord32))});
CHECK_EQ(1, r.Call());
}

View File

@ -51,10 +51,9 @@ WASM_EXEC_TEST(MemoryInit) {
r.builder().AddMemory(kWasmPageSize);
const byte data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
r.builder().AddPassiveDataSegment(base::ArrayVector(data));
BUILD(r,
WASM_MEMORY_INIT(0, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOCAL_GET(2)),
kExprI32Const, 0);
r.Build({WASM_MEMORY_INIT(0, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOCAL_GET(2)),
kExprI32Const, 0});
// All zeroes.
CheckMemoryEqualsZero(&r.builder(), 0, kWasmPageSize);
@ -87,10 +86,9 @@ WASM_EXEC_TEST(MemoryInitOutOfBoundsData) {
r.builder().AddMemory(kWasmPageSize);
const byte data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
r.builder().AddPassiveDataSegment(base::ArrayVector(data));
BUILD(r,
WASM_MEMORY_INIT(0, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOCAL_GET(2)),
kExprI32Const, 0);
r.Build({WASM_MEMORY_INIT(0, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOCAL_GET(2)),
kExprI32Const, 0});
const uint32_t last_5_bytes = kWasmPageSize - 5;
@ -108,10 +106,9 @@ WASM_EXEC_TEST(MemoryInitOutOfBounds) {
r.builder().AddMemory(kWasmPageSize);
const byte data[kWasmPageSize] = {};
r.builder().AddPassiveDataSegment(base::ArrayVector(data));
BUILD(r,
WASM_MEMORY_INIT(0, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOCAL_GET(2)),
kExprI32Const, 0);
r.Build({WASM_MEMORY_INIT(0, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOCAL_GET(2)),
kExprI32Const, 0});
// OK, copy the full data segment to memory.
r.Call(0, 0, kWasmPageSize);
@ -137,10 +134,9 @@ WASM_EXEC_TEST(MemoryInitOutOfBounds) {
WASM_EXEC_TEST(MemoryCopy) {
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
byte* mem = r.builder().AddMemory(kWasmPageSize);
BUILD(
r,
WASM_MEMORY_COPY(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)),
kExprI32Const, 0);
r.Build({WASM_MEMORY_COPY(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOCAL_GET(2)),
kExprI32Const, 0});
const byte initial[] = {0, 11, 22, 33, 44, 55, 66, 77};
memcpy(mem, initial, sizeof(initial));
@ -165,10 +161,9 @@ WASM_EXEC_TEST(MemoryCopy) {
WASM_EXEC_TEST(MemoryCopyOverlapping) {
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
byte* mem = r.builder().AddMemory(kWasmPageSize);
BUILD(
r,
WASM_MEMORY_COPY(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)),
kExprI32Const, 0);
r.Build({WASM_MEMORY_COPY(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOCAL_GET(2)),
kExprI32Const, 0});
const byte initial[] = {10, 20, 30};
memcpy(mem, initial, sizeof(initial));
@ -187,10 +182,9 @@ WASM_EXEC_TEST(MemoryCopyOverlapping) {
WASM_EXEC_TEST(MemoryCopyOutOfBoundsData) {
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
byte* mem = r.builder().AddMemory(kWasmPageSize);
BUILD(
r,
WASM_MEMORY_COPY(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)),
kExprI32Const, 0);
r.Build({WASM_MEMORY_COPY(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOCAL_GET(2)),
kExprI32Const, 0});
const byte data[] = {11, 22, 33, 44, 55, 66, 77, 88};
memcpy(mem, data, sizeof(data));
@ -215,10 +209,9 @@ WASM_EXEC_TEST(MemoryCopyOutOfBoundsData) {
WASM_EXEC_TEST(MemoryCopyOutOfBounds) {
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize);
BUILD(
r,
WASM_MEMORY_COPY(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)),
kExprI32Const, 0);
r.Build({WASM_MEMORY_COPY(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOCAL_GET(2)),
kExprI32Const, 0});
// Copy full range is OK.
CHECK_EQ(0, r.Call(0, 0, kWasmPageSize));
@ -244,10 +237,9 @@ WASM_EXEC_TEST(MemoryCopyOutOfBounds) {
WASM_EXEC_TEST(MemoryFill) {
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize);
BUILD(
r,
WASM_MEMORY_FILL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)),
kExprI32Const, 0);
r.Build({WASM_MEMORY_FILL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOCAL_GET(2)),
kExprI32Const, 0});
CHECK_EQ(0, r.Call(1, 33, 5));
CheckMemoryEqualsFollowedByZeroes(&r.builder(), {0, 33, 33, 33, 33, 33});
@ -267,10 +259,9 @@ WASM_EXEC_TEST(MemoryFill) {
WASM_EXEC_TEST(MemoryFillValueWrapsToByte) {
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize);
BUILD(
r,
WASM_MEMORY_FILL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)),
kExprI32Const, 0);
r.Build({WASM_MEMORY_FILL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOCAL_GET(2)),
kExprI32Const, 0});
CHECK_EQ(0, r.Call(0, 1000, 3));
const byte expected = 1000 & 255;
CheckMemoryEqualsFollowedByZeroes(&r.builder(),
@ -280,10 +271,9 @@ WASM_EXEC_TEST(MemoryFillValueWrapsToByte) {
WASM_EXEC_TEST(MemoryFillOutOfBoundsData) {
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize);
BUILD(
r,
WASM_MEMORY_FILL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)),
kExprI32Const, 0);
r.Build({WASM_MEMORY_FILL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOCAL_GET(2)),
kExprI32Const, 0});
const byte v = 123;
CHECK_EQ(0xDEADBEEF, r.Call(kWasmPageSize - 5, v, 999));
CheckMemoryEquals(&r.builder(), kWasmPageSize - 6, {0, 0, 0, 0, 0, 0});
@ -292,10 +282,9 @@ WASM_EXEC_TEST(MemoryFillOutOfBoundsData) {
WASM_EXEC_TEST(MemoryFillOutOfBounds) {
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize);
BUILD(
r,
WASM_MEMORY_FILL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)),
kExprI32Const, 0);
r.Build({WASM_MEMORY_FILL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOCAL_GET(2)),
kExprI32Const, 0});
const byte v = 123;
@ -316,7 +305,7 @@ WASM_EXEC_TEST(DataDropTwice) {
r.builder().AddMemory(kWasmPageSize);
const byte data[] = {0};
r.builder().AddPassiveDataSegment(base::ArrayVector(data));
BUILD(r, WASM_DATA_DROP(0), kExprI32Const, 0);
r.Build({WASM_DATA_DROP(0), kExprI32Const, 0});
CHECK_EQ(0, r.Call());
CHECK_EQ(0, r.Call());
@ -327,9 +316,9 @@ WASM_EXEC_TEST(DataDropThenMemoryInit) {
r.builder().AddMemory(kWasmPageSize);
const byte data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
r.builder().AddPassiveDataSegment(base::ArrayVector(data));
BUILD(r, WASM_DATA_DROP(0),
WASM_MEMORY_INIT(0, WASM_I32V_1(0), WASM_I32V_1(1), WASM_I32V_1(2)),
kExprI32Const, 0);
r.Build({WASM_DATA_DROP(0),
WASM_MEMORY_INIT(0, WASM_I32V_1(0), WASM_I32V_1(1), WASM_I32V_1(2)),
kExprI32Const, 0});
CHECK_EQ(0xDEADBEEF, r.Call());
}
@ -342,10 +331,9 @@ void TestTableCopyInbounds(TestExecutionTier execution_tier, int table_dst,
for (int i = 0; i < 10; ++i) {
r.builder().AddIndirectFunctionTable(nullptr, kTableSize);
}
BUILD(r,
WASM_TABLE_COPY(table_dst, table_src, WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)),
kExprI32Const, 0);
r.Build({WASM_TABLE_COPY(table_dst, table_src, WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)),
kExprI32Const, 0});
for (uint32_t i = 0; i <= kTableSize; ++i) {
r.CheckCallViaJS(0, 0, 0, i); // nop
@ -405,7 +393,7 @@ void TestTableInitElems(TestExecutionTier execution_tier, int table_index) {
for (uint32_t i = 0; i < kTableSize; ++i) {
WasmFunctionCompiler& fn = r.NewFunction(sigs.i_v(), "f");
BUILD(fn, WASM_I32V_1(i));
fn.Build({WASM_I32V_1(i)});
fn.SetSigIndex(sig_index);
function_indexes.push_back(fn.function_index());
}
@ -418,14 +406,13 @@ void TestTableInitElems(TestExecutionTier execution_tier, int table_index) {
r.builder().AddPassiveElementSegment(function_indexes);
WasmFunctionCompiler& call = r.NewFunction(sigs.i_i(), "call");
BUILD(call,
WASM_CALL_INDIRECT_TABLE(table_index, sig_index, WASM_LOCAL_GET(0)));
call.Build(
{WASM_CALL_INDIRECT_TABLE(table_index, sig_index, WASM_LOCAL_GET(0))});
const uint32_t call_index = call.function_index();
BUILD(r,
WASM_TABLE_INIT(table_index, 0, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOCAL_GET(2)),
kExprI32Const, 0);
r.Build({WASM_TABLE_INIT(table_index, 0, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOCAL_GET(2)),
kExprI32Const, 0});
auto table =
handle(WasmTableObject::cast(
@ -478,7 +465,7 @@ void TestTableInitOob(TestExecutionTier execution_tier, int table_index) {
for (uint32_t i = 0; i < kTableSize; ++i) {
WasmFunctionCompiler& fn = r.NewFunction(sigs.i_v(), "f");
BUILD(fn, WASM_I32V_1(i));
fn.Build({WASM_I32V_1(i)});
fn.SetSigIndex(sig_index);
function_indexes.push_back(fn.function_index());
}
@ -489,14 +476,13 @@ void TestTableInitOob(TestExecutionTier execution_tier, int table_index) {
r.builder().AddPassiveElementSegment(function_indexes);
WasmFunctionCompiler& call = r.NewFunction(sigs.i_i(), "call");
BUILD(call,
WASM_CALL_INDIRECT_TABLE(table_index, sig_index, WASM_LOCAL_GET(0)));
call.Build(
{WASM_CALL_INDIRECT_TABLE(table_index, sig_index, WASM_LOCAL_GET(0))});
const uint32_t call_index = call.function_index();
BUILD(r,
WASM_TABLE_INIT(table_index, 0, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOCAL_GET(2)),
kExprI32Const, 0);
r.Build({WASM_TABLE_INIT(table_index, 0, WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOCAL_GET(2)),
kExprI32Const, 0});
auto table =
handle(WasmTableObject::cast(
@ -551,7 +537,7 @@ void TestTableCopyElems(TestExecutionTier execution_tier, int table_dst,
for (uint32_t i = 0; i < kTableSize; ++i) {
WasmFunctionCompiler& fn = r.NewFunction(sigs.i_v(), "f");
BUILD(fn, WASM_I32V_1(i));
fn.Build({WASM_I32V_1(i)});
fn.SetSigIndex(sig_index);
function_indexes[i] = fn.function_index();
}
@ -560,10 +546,9 @@ void TestTableCopyElems(TestExecutionTier execution_tier, int table_dst,
r.builder().AddIndirectFunctionTable(function_indexes, kTableSize);
}
BUILD(r,
WASM_TABLE_COPY(table_dst, table_src, WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)),
kExprI32Const, 0);
r.Build({WASM_TABLE_COPY(table_dst, table_src, WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)),
kExprI32Const, 0});
r.builder().InitializeWrapperCache();
@ -629,7 +614,7 @@ void TestTableCopyCalls(TestExecutionTier execution_tier, int table_dst,
for (uint32_t i = 0; i < kTableSize; ++i) {
WasmFunctionCompiler& fn = r.NewFunction(sigs.i_v(), "f");
BUILD(fn, WASM_I32V_1(i));
fn.Build({WASM_I32V_1(i)});
fn.SetSigIndex(sig_index);
function_indexes[i] = fn.function_index();
}
@ -639,14 +624,13 @@ void TestTableCopyCalls(TestExecutionTier execution_tier, int table_dst,
}
WasmFunctionCompiler& call = r.NewFunction(sigs.i_i(), "call");
BUILD(call,
WASM_CALL_INDIRECT_TABLE(table_dst, sig_index, WASM_LOCAL_GET(0)));
call.Build(
{WASM_CALL_INDIRECT_TABLE(table_dst, sig_index, WASM_LOCAL_GET(0))});
const uint32_t call_index = call.function_index();
BUILD(r,
WASM_TABLE_COPY(table_dst, table_src, WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)),
kExprI32Const, 0);
r.Build({WASM_TABLE_COPY(table_dst, table_src, WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)),
kExprI32Const, 0});
auto table =
handle(WasmTableObject::cast(
@ -700,7 +684,7 @@ void TestTableCopyOobWrites(TestExecutionTier execution_tier, int table_dst,
for (uint32_t i = 0; i < kTableSize; ++i) {
WasmFunctionCompiler& fn = r.NewFunction(sigs.i_v(), "f");
BUILD(fn, WASM_I32V_1(i));
fn.Build({WASM_I32V_1(i)});
fn.SetSigIndex(sig_index);
function_indexes[i] = fn.function_index();
}
@ -709,10 +693,9 @@ void TestTableCopyOobWrites(TestExecutionTier execution_tier, int table_dst,
r.builder().AddIndirectFunctionTable(function_indexes, kTableSize);
}
BUILD(r,
WASM_TABLE_COPY(table_dst, table_src, WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)),
kExprI32Const, 0);
r.Build({WASM_TABLE_COPY(table_dst, table_src, WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)),
kExprI32Const, 0});
r.builder().InitializeWrapperCache();
@ -769,10 +752,9 @@ void TestTableCopyOob1(TestExecutionTier execution_tier, int table_dst,
r.builder().AddIndirectFunctionTable(nullptr, kTableSize);
}
BUILD(r,
WASM_TABLE_COPY(table_dst, table_src, WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)),
kExprI32Const, 0);
r.Build({WASM_TABLE_COPY(table_dst, table_src, WASM_LOCAL_GET(0),
WASM_LOCAL_GET(1), WASM_LOCAL_GET(2)),
kExprI32Const, 0});
r.CheckCallViaJS(0, 0, 0, 1); // nop
r.CheckCallViaJS(0, 0, 0, kTableSize); // nop
@ -819,7 +801,7 @@ WASM_COMPILED_EXEC_TEST(ElemDropTwice) {
WasmRunner<uint32_t> r(execution_tier);
r.builder().AddIndirectFunctionTable(nullptr, 1);
r.builder().AddPassiveElementSegment({});
BUILD(r, WASM_ELEM_DROP(0), kExprI32Const, 0);
r.Build({WASM_ELEM_DROP(0), kExprI32Const, 0});
r.CheckCallViaJS(0);
r.CheckCallViaJS(0);
@ -829,10 +811,10 @@ WASM_COMPILED_EXEC_TEST(ElemDropThenTableInit) {
WasmRunner<uint32_t, uint32_t> r(execution_tier);
r.builder().AddIndirectFunctionTable(nullptr, 1);
r.builder().AddPassiveElementSegment({});
BUILD(
r, WASM_ELEM_DROP(0),
WASM_TABLE_INIT(0, 0, WASM_I32V_1(0), WASM_I32V_1(0), WASM_LOCAL_GET(0)),
kExprI32Const, 0);
r.Build(
{WASM_ELEM_DROP(0),
WASM_TABLE_INIT(0, 0, WASM_I32V_1(0), WASM_I32V_1(0), WASM_LOCAL_GET(0)),
kExprI32Const, 0});
r.CheckCallViaJS(0, 0);
r.CheckCallViaJS(0xDEADBEEF, 1);

View File

@ -21,11 +21,11 @@ WASM_EXEC_TEST(TryCatchThrow) {
constexpr uint32_t kResult1 = 42;
// Build the main test function.
BUILD(r, WASM_TRY_CATCH_T(kWasmI32,
WASM_STMTS(WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_THROW(except))),
WASM_STMTS(WASM_I32V(kResult0)), except));
r.Build({WASM_TRY_CATCH_T(
kWasmI32,
WASM_STMTS(WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)), WASM_THROW(except))),
WASM_STMTS(WASM_I32V(kResult0)), except)});
if (execution_tier != TestExecutionTier::kInterpreter) {
// Need to call through JS to allow for creation of stack traces.
@ -45,12 +45,12 @@ WASM_EXEC_TEST(TryCatchThrowWithValue) {
constexpr uint32_t kResult1 = 42;
// Build the main test function.
BUILD(r, WASM_TRY_CATCH_T(
kWasmI32,
WASM_STMTS(WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_I32V(kResult0), WASM_THROW(except))),
WASM_STMTS(kExprNop), except));
r.Build({WASM_TRY_CATCH_T(
kWasmI32,
WASM_STMTS(WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)), WASM_I32V(kResult0),
WASM_THROW(except))),
WASM_STMTS(kExprNop), except)});
if (execution_tier != TestExecutionTier::kInterpreter) {
// Need to call through JS to allow for creation of stack traces.
@ -72,14 +72,14 @@ WASM_EXEC_TEST(TryMultiCatchThrow) {
constexpr uint32_t kResult2 = 51;
// Build the main test function.
BUILD(
r, kExprTry, static_cast<byte>((kWasmI32).value_type_code()),
WASM_STMTS(WASM_I32V(kResult2),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)), WASM_THROW(except1)),
WASM_IF(WASM_I32_EQ(WASM_LOCAL_GET(0), WASM_I32V(1)),
WASM_THROW(except2))),
kExprCatch, except1, WASM_STMTS(WASM_I32V(kResult0)), kExprCatch, except2,
WASM_STMTS(WASM_I32V(kResult1)), kExprEnd);
r.Build(
{kExprTry, static_cast<byte>((kWasmI32).value_type_code()),
WASM_STMTS(WASM_I32V(kResult2),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)), WASM_THROW(except1)),
WASM_IF(WASM_I32_EQ(WASM_LOCAL_GET(0), WASM_I32V(1)),
WASM_THROW(except2))),
kExprCatch, except1, WASM_STMTS(WASM_I32V(kResult0)), kExprCatch,
except2, WASM_STMTS(WASM_I32V(kResult1)), kExprEnd});
if (execution_tier != TestExecutionTier::kInterpreter) {
// Need to call through JS to allow for creation of stack traces.
@ -101,10 +101,11 @@ WASM_EXEC_TEST(TryCatchAllThrow) {
constexpr uint32_t kResult1 = 42;
// Build the main test function.
BUILD(r, kExprTry, static_cast<byte>((kWasmI32).value_type_code()),
WASM_STMTS(WASM_I32V(kResult1), WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_THROW(except))),
kExprCatchAll, WASM_I32V(kResult0), kExprEnd);
r.Build(
{kExprTry, static_cast<byte>((kWasmI32).value_type_code()),
WASM_STMTS(WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)), WASM_THROW(except))),
kExprCatchAll, WASM_I32V(kResult0), kExprEnd});
if (execution_tier != TestExecutionTier::kInterpreter) {
// Need to call through JS to allow for creation of stack traces.
@ -126,14 +127,14 @@ WASM_EXEC_TEST(TryCatchCatchAllThrow) {
constexpr uint32_t kResult2 = 51;
// Build the main test function.
BUILD(
r, kExprTry, static_cast<byte>((kWasmI32).value_type_code()),
WASM_STMTS(WASM_I32V(kResult2),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)), WASM_THROW(except1)),
WASM_IF(WASM_I32_EQ(WASM_LOCAL_GET(0), WASM_I32V(1)),
WASM_THROW(except2))),
kExprCatch, except1, WASM_I32V(kResult0), kExprCatchAll,
WASM_I32V(kResult1), kExprEnd);
r.Build(
{kExprTry, static_cast<byte>((kWasmI32).value_type_code()),
WASM_STMTS(WASM_I32V(kResult2),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)), WASM_THROW(except1)),
WASM_IF(WASM_I32_EQ(WASM_LOCAL_GET(0), WASM_I32V(1)),
WASM_THROW(except2))),
kExprCatch, except1, WASM_I32V(kResult0), kExprCatchAll,
WASM_I32V(kResult1), kExprEnd});
if (execution_tier != TestExecutionTier::kInterpreter) {
// Need to call through JS to allow for creation of stack traces.
@ -157,15 +158,14 @@ WASM_EXEC_TEST(TryImplicitRethrow) {
constexpr uint32_t kResult2 = 51;
// Build the main test function.
BUILD(r,
WASM_TRY_CATCH_T(
kWasmI32,
WASM_TRY_CATCH_T(kWasmI32,
WASM_STMTS(WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_THROW(except2))),
WASM_STMTS(WASM_I32V(kResult2)), except1),
WASM_I32V(kResult0), except2));
r.Build({WASM_TRY_CATCH_T(
kWasmI32,
WASM_TRY_CATCH_T(kWasmI32,
WASM_STMTS(WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_THROW(except2))),
WASM_STMTS(WASM_I32V(kResult2)), except1),
WASM_I32V(kResult0), except2)});
if (execution_tier != TestExecutionTier::kInterpreter) {
// Need to call through JS to allow for creation of stack traces.
@ -185,15 +185,14 @@ WASM_EXEC_TEST(TryDelegate) {
constexpr uint32_t kResult1 = 42;
// Build the main test function.
BUILD(r,
WASM_TRY_CATCH_T(kWasmI32,
WASM_TRY_DELEGATE_T(
kWasmI32,
WASM_STMTS(WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_THROW(except))),
0),
WASM_I32V(kResult0), except));
r.Build({WASM_TRY_CATCH_T(
kWasmI32,
WASM_TRY_DELEGATE_T(kWasmI32,
WASM_STMTS(WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_THROW(except))),
0),
WASM_I32V(kResult0), except)});
if (execution_tier != TestExecutionTier::kInterpreter) {
// Need to call through JS to allow for creation of stack traces.
@ -209,11 +208,10 @@ WASM_EXEC_TEST(TestCatchlessTry) {
TestSignatures sigs;
WasmRunner<uint32_t> r(execution_tier);
byte except = r.builder().AddException(sigs.v_i());
BUILD(r,
WASM_TRY_CATCH_T(
kWasmI32,
WASM_TRY_T(kWasmI32, WASM_STMTS(WASM_I32V(0), WASM_THROW(except))),
WASM_NOP, except));
r.Build({WASM_TRY_CATCH_T(
kWasmI32,
WASM_TRY_T(kWasmI32, WASM_STMTS(WASM_I32V(0), WASM_THROW(except))),
WASM_NOP, except)});
if (execution_tier != TestExecutionTier::kInterpreter) {
r.CheckCallViaJS(0);
} else {
@ -231,19 +229,18 @@ WASM_EXEC_TEST(TryCatchRethrow) {
constexpr uint32_t kUnreachable = 51;
// Build the main test function.
BUILD(r,
WASM_TRY_CATCH_CATCH_T(
kWasmI32,
WASM_TRY_CATCH_T(
kWasmI32, WASM_THROW(except2),
WASM_TRY_CATCH_T(
kWasmI32, WASM_THROW(except1),
WASM_STMTS(WASM_I32V(kUnreachable),
WASM_IF_ELSE(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_RETHROW(1), WASM_RETHROW(2))),
except1),
except2),
except1, WASM_I32V(kResult0), except2, WASM_I32V(kResult1)));
r.Build({WASM_TRY_CATCH_CATCH_T(
kWasmI32,
WASM_TRY_CATCH_T(
kWasmI32, WASM_THROW(except2),
WASM_TRY_CATCH_T(
kWasmI32, WASM_THROW(except1),
WASM_STMTS(WASM_I32V(kUnreachable),
WASM_IF_ELSE(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_RETHROW(1), WASM_RETHROW(2))),
except1),
except2),
except1, WASM_I32V(kResult0), except2, WASM_I32V(kResult1))});
if (execution_tier != TestExecutionTier::kInterpreter) {
// Need to call through JS to allow for creation of stack traces.
@ -263,15 +260,14 @@ WASM_EXEC_TEST(TryDelegateToCaller) {
constexpr uint32_t kResult1 = 42;
// Build the main test function.
BUILD(r,
WASM_TRY_CATCH_T(kWasmI32,
WASM_TRY_DELEGATE_T(
kWasmI32,
WASM_STMTS(WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_THROW(except))),
1),
WASM_I32V(kResult0), except));
r.Build({WASM_TRY_CATCH_T(
kWasmI32,
WASM_TRY_DELEGATE_T(kWasmI32,
WASM_STMTS(WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_THROW(except))),
1),
WASM_I32V(kResult0), except)});
if (execution_tier != TestExecutionTier::kInterpreter) {
// Need to call through JS to allow for creation of stack traces.
@ -294,18 +290,18 @@ WASM_EXEC_TEST(TryCatchCallDirect) {
// Build a throwing helper function.
WasmFunctionCompiler& throw_func = r.NewFunction(sigs.i_ii());
BUILD(throw_func, WASM_THROW(except));
throw_func.Build({WASM_THROW(except)});
// Build the main test function.
BUILD(r, WASM_TRY_CATCH_T(
kWasmI32,
WASM_STMTS(WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_STMTS(WASM_CALL_FUNCTION(
throw_func.function_index(),
WASM_I32V(7), WASM_I32V(9)),
WASM_DROP))),
WASM_STMTS(WASM_I32V(kResult0)), except));
r.Build({WASM_TRY_CATCH_T(
kWasmI32,
WASM_STMTS(
WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_STMTS(WASM_CALL_FUNCTION(throw_func.function_index(),
WASM_I32V(7), WASM_I32V(9)),
WASM_DROP))),
WASM_STMTS(WASM_I32V(kResult0)), except)});
if (execution_tier != TestExecutionTier::kInterpreter) {
// Need to call through JS to allow for creation of stack traces.
@ -326,18 +322,18 @@ WASM_EXEC_TEST(TryCatchAllCallDirect) {
// Build a throwing helper function.
WasmFunctionCompiler& throw_func = r.NewFunction(sigs.i_ii());
BUILD(throw_func, WASM_THROW(except));
throw_func.Build({WASM_THROW(except)});
// Build the main test function.
BUILD(r, WASM_TRY_CATCH_ALL_T(
kWasmI32,
WASM_STMTS(WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_STMTS(WASM_CALL_FUNCTION(
throw_func.function_index(),
WASM_I32V(7), WASM_I32V(9)),
WASM_DROP))),
WASM_STMTS(WASM_I32V(kResult0))));
r.Build({WASM_TRY_CATCH_ALL_T(
kWasmI32,
WASM_STMTS(
WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_STMTS(WASM_CALL_FUNCTION(throw_func.function_index(),
WASM_I32V(7), WASM_I32V(9)),
WASM_DROP))),
WASM_STMTS(WASM_I32V(kResult0)))});
if (execution_tier != TestExecutionTier::kInterpreter) {
// Need to call through JS to allow for creation of stack traces.
@ -358,7 +354,7 @@ WASM_EXEC_TEST(TryCatchCallIndirect) {
// Build a throwing helper function.
WasmFunctionCompiler& throw_func = r.NewFunction(sigs.i_ii());
BUILD(throw_func, WASM_THROW(except));
throw_func.Build({WASM_THROW(except)});
// Add an indirect function table.
uint16_t indirect_function_table[] = {
@ -367,16 +363,15 @@ WASM_EXEC_TEST(TryCatchCallIndirect) {
arraysize(indirect_function_table));
// Build the main test function.
BUILD(r, WASM_TRY_CATCH_T(
kWasmI32,
WASM_STMTS(
WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_STMTS(WASM_CALL_INDIRECT(
throw_func.sig_index(), WASM_I32V(7),
WASM_I32V(9), WASM_LOCAL_GET(0)),
WASM_DROP))),
WASM_I32V(kResult0), except));
r.Build({WASM_TRY_CATCH_T(
kWasmI32,
WASM_STMTS(WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_STMTS(WASM_CALL_INDIRECT(
throw_func.sig_index(), WASM_I32V(7),
WASM_I32V(9), WASM_LOCAL_GET(0)),
WASM_DROP))),
WASM_I32V(kResult0), except)});
if (execution_tier != TestExecutionTier::kInterpreter) {
// Need to call through JS to allow for creation of stack traces.
@ -397,7 +392,7 @@ WASM_EXEC_TEST(TryCatchAllCallIndirect) {
// Build a throwing helper function.
WasmFunctionCompiler& throw_func = r.NewFunction(sigs.i_ii());
BUILD(throw_func, WASM_THROW(except));
throw_func.Build({WASM_THROW(except)});
// Add an indirect function table.
uint16_t indirect_function_table[] = {
@ -406,16 +401,15 @@ WASM_EXEC_TEST(TryCatchAllCallIndirect) {
arraysize(indirect_function_table));
// Build the main test function.
BUILD(r, WASM_TRY_CATCH_ALL_T(
kWasmI32,
WASM_STMTS(
WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_STMTS(WASM_CALL_INDIRECT(
throw_func.sig_index(), WASM_I32V(7),
WASM_I32V(9), WASM_LOCAL_GET(0)),
WASM_DROP))),
WASM_I32V(kResult0)));
r.Build({WASM_TRY_CATCH_ALL_T(
kWasmI32,
WASM_STMTS(WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_STMTS(WASM_CALL_INDIRECT(
throw_func.sig_index(), WASM_I32V(7),
WASM_I32V(9), WASM_LOCAL_GET(0)),
WASM_DROP))),
WASM_I32V(kResult0))});
if (execution_tier != TestExecutionTier::kInterpreter) {
// Need to call through JS to allow for creation of stack traces.
@ -441,15 +435,14 @@ WASM_COMPILED_EXEC_TEST(TryCatchCallExternal) {
constexpr uint32_t kJSFunc = 0;
// Build the main test function.
BUILD(r, WASM_TRY_CATCH_ALL_T(
kWasmI32,
WASM_STMTS(
WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_STMTS(WASM_CALL_FUNCTION(kJSFunc, WASM_I32V(7),
WASM_I32V(9)),
WASM_DROP))),
WASM_I32V(kResult0)));
r.Build({WASM_TRY_CATCH_ALL_T(
kWasmI32,
WASM_STMTS(WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_STMTS(WASM_CALL_FUNCTION(kJSFunc, WASM_I32V(7),
WASM_I32V(9)),
WASM_DROP))),
WASM_I32V(kResult0))});
// Need to call through JS to allow for creation of stack traces.
r.CheckCallViaJS(kResult0, 0);
@ -470,15 +463,14 @@ WASM_COMPILED_EXEC_TEST(TryCatchAllCallExternal) {
constexpr uint32_t kJSFunc = 0;
// Build the main test function.
BUILD(r, WASM_TRY_CATCH_ALL_T(
kWasmI32,
WASM_STMTS(
WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_STMTS(WASM_CALL_FUNCTION(kJSFunc, WASM_I32V(7),
WASM_I32V(9)),
WASM_DROP))),
WASM_I32V(kResult0)));
r.Build({WASM_TRY_CATCH_ALL_T(
kWasmI32,
WASM_STMTS(WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_LOCAL_GET(0)),
WASM_STMTS(WASM_CALL_FUNCTION(kJSFunc, WASM_I32V(7),
WASM_I32V(9)),
WASM_DROP))),
WASM_I32V(kResult0))});
// Need to call through JS to allow for creation of stack traces.
r.CheckCallViaJS(kResult0, 0);
@ -502,16 +494,16 @@ void TestTrapNotCaught(byte* code, size_t code_size,
// Build a trapping helper function.
WasmFunctionCompiler& trap_func = r.NewFunction(sigs.i_ii());
trap_func.Build(code, code + code_size);
trap_func.Build(base::VectorOf(code, code_size));
// Build the main test function.
BUILD(r, WASM_TRY_CATCH_ALL_T(
kWasmI32,
WASM_STMTS(WASM_I32V(kResultSuccess),
WASM_CALL_FUNCTION(trap_func.function_index(),
WASM_I32V(7), WASM_I32V(9)),
WASM_DROP),
WASM_STMTS(WASM_I32V(kResultCaught))));
r.Build({WASM_TRY_CATCH_ALL_T(
kWasmI32,
WASM_STMTS(WASM_I32V(kResultSuccess),
WASM_CALL_FUNCTION(trap_func.function_index(), WASM_I32V(7),
WASM_I32V(9)),
WASM_DROP),
WASM_STMTS(WASM_I32V(kResultCaught)))});
if (execution_tier != TestExecutionTier::kInterpreter) {
// Need to call through JS to allow for creation of stack traces.
@ -591,17 +583,15 @@ UNINITIALIZED_WASM_EXEC_TEST(TestStackOverflowNotCaught) {
// Build a function that calls itself until stack overflow.
WasmFunctionCompiler& stack_overflow = r.NewFunction(sigs.v_v());
byte stack_overflow_code[] = {
kExprCallFunction, static_cast<byte>(stack_overflow.function_index())};
stack_overflow.Build(stack_overflow_code,
stack_overflow_code + arraysize(stack_overflow_code));
stack_overflow.Build(
{kExprCallFunction, static_cast<byte>(stack_overflow.function_index())});
// Build the main test function.
BUILD(r, WASM_TRY_CATCH_ALL_T(
kWasmI32,
WASM_STMTS(WASM_I32V(1), kExprCallFunction,
static_cast<byte>(stack_overflow.function_index())),
WASM_STMTS(WASM_I32V(1))));
r.Build({WASM_TRY_CATCH_ALL_T(
kWasmI32,
WASM_STMTS(WASM_I32V(1), kExprCallFunction,
static_cast<byte>(stack_overflow.function_index())),
WASM_STMTS(WASM_I32V(1)))});
if (execution_tier != TestExecutionTier::kInterpreter) {
// Need to call through JS to allow for creation of stack traces.
@ -617,11 +607,11 @@ TEST(Regress1180457) {
WasmRunner<uint32_t> r(TestExecutionTier::kInterpreter);
constexpr uint32_t kResult0 = 23;
constexpr uint32_t kUnreachable = 42;
BUILD(r, WASM_TRY_CATCH_ALL_T(
kWasmI32,
WASM_TRY_DELEGATE_T(
kWasmI32, WASM_STMTS(WASM_I32V(kResult0), WASM_BR(0)), 0),
WASM_I32V(kUnreachable)));
r.Build({WASM_TRY_CATCH_ALL_T(
kWasmI32,
WASM_TRY_DELEGATE_T(kWasmI32, WASM_STMTS(WASM_I32V(kResult0), WASM_BR(0)),
0),
WASM_I32V(kUnreachable))});
CHECK_EQ(kResult0, r.CallInterpreter());
}
@ -631,8 +621,8 @@ TEST(Regress1187896) {
WasmRunner<uint32_t> r(TestExecutionTier::kInterpreter);
byte try_sig = r.builder().AddSignature(sigs.v_i());
constexpr uint32_t kResult = 23;
BUILD(r, kExprI32Const, 0, kExprTry, try_sig, kExprDrop, kExprCatchAll,
kExprNop, kExprEnd, kExprI32Const, kResult);
r.Build({kExprI32Const, 0, kExprTry, try_sig, kExprDrop, kExprCatchAll,
kExprNop, kExprEnd, kExprI32Const, kResult});
CHECK_EQ(kResult, r.CallInterpreter());
}
@ -640,8 +630,8 @@ TEST(Regress1190291) {
TestSignatures sigs;
WasmRunner<uint32_t> r(TestExecutionTier::kInterpreter);
byte try_sig = r.builder().AddSignature(sigs.v_i());
BUILD(r, kExprUnreachable, kExprTry, try_sig, kExprCatchAll, kExprEnd,
kExprI32Const, 0);
r.Build({kExprUnreachable, kExprTry, try_sig, kExprCatchAll, kExprEnd,
kExprI32Const, 0});
r.CallInterpreter();
}
@ -649,16 +639,15 @@ TEST(Regress1186795) {
TestSignatures sigs;
WasmRunner<uint32_t> r(TestExecutionTier::kInterpreter);
byte except = r.builder().AddException(sigs.v_i());
BUILD(r,
WASM_TRY_CATCH_T(
kWasmI32,
WASM_STMTS(WASM_I32V(0), WASM_I32V(0), WASM_I32V(0), WASM_I32V(0),
WASM_I32V(0), WASM_I32V(0), WASM_I32V(0),
WASM_TRY_T(kWasmI32,
WASM_STMTS(WASM_I32V(0), WASM_THROW(except))),
WASM_DROP, WASM_DROP, WASM_DROP, WASM_DROP, WASM_DROP,
WASM_DROP, WASM_DROP),
WASM_NOP, except));
r.Build({WASM_TRY_CATCH_T(
kWasmI32,
WASM_STMTS(
WASM_I32V(0), WASM_I32V(0), WASM_I32V(0), WASM_I32V(0), WASM_I32V(0),
WASM_I32V(0), WASM_I32V(0),
WASM_TRY_T(kWasmI32, WASM_STMTS(WASM_I32V(0), WASM_THROW(except))),
WASM_DROP, WASM_DROP, WASM_DROP, WASM_DROP, WASM_DROP, WASM_DROP,
WASM_DROP),
WASM_NOP, except)});
CHECK_EQ(0, r.CallInterpreter());
}
@ -667,9 +656,9 @@ TEST(Regress1197408) {
WasmRunner<int32_t, int32_t, int32_t, int32_t> r(
TestExecutionTier::kInterpreter);
byte sig_id = r.builder().AddSignature(sigs.i_iii());
BUILD(r, WASM_STMTS(WASM_I32V(0), WASM_I32V(0), WASM_I32V(0), kExprTry,
r.Build({WASM_STMTS(WASM_I32V(0), WASM_I32V(0), WASM_I32V(0), kExprTry,
sig_id, kExprTry, sig_id, kExprCallFunction, 0,
kExprDelegate, 0, kExprDelegate, 0));
kExprDelegate, 0, kExprDelegate, 0)});
CHECK_EQ(0, r.CallInterpreter(0, 0, 0));
}
@ -677,16 +666,16 @@ TEST(Regress1212396) {
TestSignatures sigs;
WasmRunner<int32_t> r(TestExecutionTier::kInterpreter);
byte except = r.builder().AddException(sigs.v_v());
BUILD(r, kExprTry, kVoidCode, kExprTry, kVoidCode, kExprI32Const, 0,
kExprThrow, except, kExprDelegate, 0, kExprCatch, except, kExprEnd,
kExprI32Const, 42);
r.Build({kExprTry, kVoidCode, kExprTry, kVoidCode, kExprI32Const, 0,
kExprThrow, except, kExprDelegate, 0, kExprCatch, except, kExprEnd,
kExprI32Const, 42});
CHECK_EQ(42, r.CallInterpreter());
}
TEST(Regress1219746) {
TestSignatures sigs;
WasmRunner<int32_t> r(TestExecutionTier::kInterpreter);
BUILD(r, kExprTry, kVoidCode, kExprI32Const, 0, kExprEnd);
r.Build({kExprTry, kVoidCode, kExprI32Const, 0, kExprEnd});
CHECK_EQ(0, r.CallInterpreter());
}

View File

@ -25,21 +25,21 @@ TEST(Run_WasmInt8Const_i) {
WasmRunner<int32_t> r(TestExecutionTier::kInterpreter);
const byte kExpectedValue = 109;
// return(kExpectedValue)
BUILD(r, WASM_I32V_2(kExpectedValue));
r.Build({WASM_I32V_2(kExpectedValue)});
CHECK_EQ(kExpectedValue, r.Call());
}
TEST(Run_WasmIfElse) {
WasmRunner<int32_t, int32_t> r(TestExecutionTier::kInterpreter);
BUILD(r, WASM_IF_ELSE_I(WASM_LOCAL_GET(0), WASM_I32V_1(9), WASM_I32V_1(10)));
r.Build({WASM_IF_ELSE_I(WASM_LOCAL_GET(0), WASM_I32V_1(9), WASM_I32V_1(10))});
CHECK_EQ(10, r.Call(0));
CHECK_EQ(9, r.Call(1));
}
TEST(Run_WasmIfReturn) {
WasmRunner<int32_t, int32_t> r(TestExecutionTier::kInterpreter);
BUILD(r, WASM_IF(WASM_LOCAL_GET(0), WASM_RETURN(WASM_I32V_2(77))),
WASM_I32V_2(65));
r.Build({WASM_IF(WASM_LOCAL_GET(0), WASM_RETURN(WASM_I32V_2(77))),
WASM_I32V_2(65)});
CHECK_EQ(65, r.Call(0));
CHECK_EQ(77, r.Call(1));
}
@ -130,12 +130,10 @@ TEST(Run_WasmBlockBreakN) {
TEST(Run_Wasm_nested_ifs_i) {
WasmRunner<int32_t, int32_t, int32_t> r(TestExecutionTier::kInterpreter);
BUILD(
r,
WASM_IF_ELSE_I(
WASM_LOCAL_GET(0),
WASM_IF_ELSE_I(WASM_LOCAL_GET(1), WASM_I32V_1(11), WASM_I32V_1(12)),
WASM_IF_ELSE_I(WASM_LOCAL_GET(1), WASM_I32V_1(13), WASM_I32V_1(14))));
r.Build({WASM_IF_ELSE_I(
WASM_LOCAL_GET(0),
WASM_IF_ELSE_I(WASM_LOCAL_GET(1), WASM_I32V_1(11), WASM_I32V_1(12)),
WASM_IF_ELSE_I(WASM_LOCAL_GET(1), WASM_I32V_1(13), WASM_I32V_1(14)))});
CHECK_EQ(11, r.Call(1, 1));
CHECK_EQ(12, r.Call(1, 0));
@ -164,16 +162,15 @@ TEST(Run_Wasm_returnCallFactorial) {
WasmFunctionCompiler& fact_aux_fn =
r.NewFunction<int32_t, int32_t, int32_t>("fact_aux");
BUILD(r, WASM_RETURN_CALL_FUNCTION(fact_aux_fn.function_index(),
WASM_LOCAL_GET(0), WASM_I32V(1)));
r.Build({WASM_RETURN_CALL_FUNCTION(fact_aux_fn.function_index(),
WASM_LOCAL_GET(0), WASM_I32V(1))});
BUILD(fact_aux_fn,
WASM_IF_ELSE_I(
WASM_I32_EQ(WASM_I32V(1), WASM_LOCAL_GET(0)), WASM_LOCAL_GET(1),
WASM_RETURN_CALL_FUNCTION(
fact_aux_fn.function_index(),
WASM_I32_SUB(WASM_LOCAL_GET(0), WASM_I32V(1)),
WASM_I32_MUL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)))));
fact_aux_fn.Build({WASM_IF_ELSE_I(
WASM_I32_EQ(WASM_I32V(1), WASM_LOCAL_GET(0)), WASM_LOCAL_GET(1),
WASM_RETURN_CALL_FUNCTION(
fact_aux_fn.function_index(),
WASM_I32_SUB(WASM_LOCAL_GET(0), WASM_I32V(1)),
WASM_I32_MUL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))))});
// Runs out of stack space without using return call.
uint32_t test_values[] = {1, 2, 5, 10, 20, 20000};
@ -193,17 +190,16 @@ TEST(Run_Wasm_returnCallFactorial64) {
WasmFunctionCompiler& fact_aux_fn =
r.NewFunction<int64_t, int32_t, int64_t>("fact_aux");
BUILD(r, WASM_RETURN_CALL_FUNCTION(fact_aux_fn.function_index(),
WASM_LOCAL_GET(0), WASM_I64V(1)));
r.Build({WASM_RETURN_CALL_FUNCTION(fact_aux_fn.function_index(),
WASM_LOCAL_GET(0), WASM_I64V(1))});
BUILD(fact_aux_fn,
WASM_IF_ELSE_L(
WASM_I32_EQ(WASM_I32V(1), WASM_LOCAL_GET(0)), WASM_LOCAL_GET(1),
WASM_RETURN_CALL_FUNCTION(
fact_aux_fn.function_index(),
WASM_I32_SUB(WASM_LOCAL_GET(0), WASM_I32V(1)),
WASM_I64_MUL(WASM_I64_SCONVERT_I32(WASM_LOCAL_GET(0)),
WASM_LOCAL_GET(1)))));
fact_aux_fn.Build({WASM_IF_ELSE_L(
WASM_I32_EQ(WASM_I32V(1), WASM_LOCAL_GET(0)), WASM_LOCAL_GET(1),
WASM_RETURN_CALL_FUNCTION(
fact_aux_fn.function_index(),
WASM_I32_SUB(WASM_LOCAL_GET(0), WASM_I32V(1)),
WASM_I64_MUL(WASM_I64_SCONVERT_I32(WASM_LOCAL_GET(0)),
WASM_LOCAL_GET(1))))});
for (int32_t v : test_values) {
CHECK_EQ(factorial<int64_t>(v), r.Call(v));
@ -226,17 +222,15 @@ TEST(Run_Wasm_returnCallIndirectFactorial) {
r.builder().AddIndirectFunctionTable(indirect_function_table,
arraysize(indirect_function_table));
BUILD(r, WASM_RETURN_CALL_INDIRECT(fact_aux_fn.sig_index(), WASM_LOCAL_GET(0),
WASM_I32V(1), WASM_ZERO));
r.Build({WASM_RETURN_CALL_INDIRECT(fact_aux_fn.sig_index(), WASM_LOCAL_GET(0),
WASM_I32V(1), WASM_ZERO)});
BUILD(
fact_aux_fn,
WASM_IF_ELSE_I(
WASM_I32_EQ(WASM_I32V(1), WASM_LOCAL_GET(0)), WASM_LOCAL_GET(1),
WASM_RETURN_CALL_INDIRECT(
fact_aux_fn.sig_index(),
WASM_I32_SUB(WASM_LOCAL_GET(0), WASM_I32V(1)),
WASM_I32_MUL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)), WASM_ZERO)));
fact_aux_fn.Build({WASM_IF_ELSE_I(
WASM_I32_EQ(WASM_I32V(1), WASM_LOCAL_GET(0)), WASM_LOCAL_GET(1),
WASM_RETURN_CALL_INDIRECT(
fact_aux_fn.sig_index(),
WASM_I32_SUB(WASM_LOCAL_GET(0), WASM_I32V(1)),
WASM_I32_MUL(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)), WASM_ZERO))});
uint32_t test_values[] = {1, 2, 5, 10, 20};
@ -310,14 +304,14 @@ TEST(MemoryGrow) {
WasmRunner<int32_t, uint32_t> r(TestExecutionTier::kInterpreter);
r.builder().AddMemory(kWasmPageSize);
r.builder().SetMaxMemPages(10);
BUILD(r, WASM_MEMORY_GROW(WASM_LOCAL_GET(0)));
r.Build({WASM_MEMORY_GROW(WASM_LOCAL_GET(0))});
CHECK_EQ(1, r.Call(1));
}
{
WasmRunner<int32_t, uint32_t> r(TestExecutionTier::kInterpreter);
r.builder().AddMemory(kWasmPageSize);
r.builder().SetMaxMemPages(10);
BUILD(r, WASM_MEMORY_GROW(WASM_LOCAL_GET(0)));
r.Build({WASM_MEMORY_GROW(WASM_LOCAL_GET(0))});
CHECK_EQ(-1, r.Call(11));
}
}
@ -327,11 +321,10 @@ TEST(MemoryGrowPreservesData) {
int32_t value = 2335;
WasmRunner<int32_t, uint32_t> r(TestExecutionTier::kInterpreter);
r.builder().AddMemory(kWasmPageSize);
BUILD(
r,
WASM_STORE_MEM(MachineType::Int32(), WASM_I32V(index), WASM_I32V(value)),
WASM_MEMORY_GROW(WASM_LOCAL_GET(0)), WASM_DROP,
WASM_LOAD_MEM(MachineType::Int32(), WASM_I32V(index)));
r.Build(
{WASM_STORE_MEM(MachineType::Int32(), WASM_I32V(index), WASM_I32V(value)),
WASM_MEMORY_GROW(WASM_LOCAL_GET(0)), WASM_DROP,
WASM_LOAD_MEM(MachineType::Int32(), WASM_I32V(index))});
CHECK_EQ(value, r.Call(1));
}
@ -339,26 +332,26 @@ TEST(MemoryGrowInvalidSize) {
// Grow memory by an invalid amount without initial memory.
WasmRunner<int32_t, uint32_t> r(TestExecutionTier::kInterpreter);
r.builder().AddMemory(kWasmPageSize);
BUILD(r, WASM_MEMORY_GROW(WASM_LOCAL_GET(0)));
r.Build({WASM_MEMORY_GROW(WASM_LOCAL_GET(0))});
CHECK_EQ(-1, r.Call(1048575));
}
TEST(ReferenceTypeLocals) {
{
WasmRunner<int32_t> r(TestExecutionTier::kInterpreter);
BUILD(r, WASM_REF_IS_NULL(WASM_REF_NULL(kAnyRefCode)));
r.Build({WASM_REF_IS_NULL(WASM_REF_NULL(kAnyRefCode))});
CHECK_EQ(1, r.Call());
}
{
WasmRunner<int32_t> r(TestExecutionTier::kInterpreter);
r.AllocateLocal(kWasmAnyRef);
BUILD(r, WASM_REF_IS_NULL(WASM_LOCAL_GET(0)));
r.Build({WASM_REF_IS_NULL(WASM_LOCAL_GET(0))});
CHECK_EQ(1, r.Call());
}
{
WasmRunner<int32_t> r(TestExecutionTier::kInterpreter);
r.AllocateLocal(kWasmAnyRef);
BUILD(r, WASM_REF_IS_NULL(WASM_LOCAL_TEE(0, WASM_REF_NULL(kAnyRefCode))));
r.Build({WASM_REF_IS_NULL(WASM_LOCAL_TEE(0, WASM_REF_NULL(kAnyRefCode)))});
CHECK_EQ(1, r.Call());
}
}
@ -366,7 +359,7 @@ TEST(ReferenceTypeLocals) {
TEST(TestPossibleNondeterminism) {
{
WasmRunner<int32_t, float> r(TestExecutionTier::kInterpreter);
BUILD(r, WASM_I32_REINTERPRET_F32(WASM_LOCAL_GET(0)));
r.Build({WASM_I32_REINTERPRET_F32(WASM_LOCAL_GET(0))});
r.Call(1048575.5f);
CHECK(!r.possible_nondeterminism());
r.Call(std::numeric_limits<float>::quiet_NaN());
@ -374,7 +367,7 @@ TEST(TestPossibleNondeterminism) {
}
{
WasmRunner<int64_t, double> r(TestExecutionTier::kInterpreter);
BUILD(r, WASM_I64_REINTERPRET_F64(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_REINTERPRET_F64(WASM_LOCAL_GET(0))});
r.Call(16.0);
CHECK(!r.possible_nondeterminism());
r.Call(std::numeric_limits<double>::quiet_NaN());
@ -382,7 +375,7 @@ TEST(TestPossibleNondeterminism) {
}
{
WasmRunner<float, float> r(TestExecutionTier::kInterpreter);
BUILD(r, WASM_F32_COPYSIGN(WASM_F32(42.0f), WASM_LOCAL_GET(0)));
r.Build({WASM_F32_COPYSIGN(WASM_F32(42.0f), WASM_LOCAL_GET(0))});
r.Call(16.0f);
CHECK(!r.possible_nondeterminism());
r.Call(std::numeric_limits<double>::quiet_NaN());
@ -390,7 +383,7 @@ TEST(TestPossibleNondeterminism) {
}
{
WasmRunner<double, double> r(TestExecutionTier::kInterpreter);
BUILD(r, WASM_F64_COPYSIGN(WASM_F64(42.0), WASM_LOCAL_GET(0)));
r.Build({WASM_F64_COPYSIGN(WASM_F64(42.0), WASM_LOCAL_GET(0))});
r.Call(16.0);
CHECK(!r.possible_nondeterminism());
r.Call(std::numeric_limits<double>::quiet_NaN());
@ -400,10 +393,9 @@ TEST(TestPossibleNondeterminism) {
int32_t index = 16;
WasmRunner<int32_t, float> r(TestExecutionTier::kInterpreter);
r.builder().AddMemory(kWasmPageSize);
BUILD(r,
WASM_STORE_MEM(MachineType::Float32(), WASM_I32V(index),
WASM_LOCAL_GET(0)),
WASM_I32V(index));
r.Build({WASM_STORE_MEM(MachineType::Float32(), WASM_I32V(index),
WASM_LOCAL_GET(0)),
WASM_I32V(index)});
r.Call(1345.3456f);
CHECK(!r.possible_nondeterminism());
r.Call(std::numeric_limits<float>::quiet_NaN());
@ -413,10 +405,9 @@ TEST(TestPossibleNondeterminism) {
int32_t index = 16;
WasmRunner<int32_t, double> r(TestExecutionTier::kInterpreter);
r.builder().AddMemory(kWasmPageSize);
BUILD(r,
WASM_STORE_MEM(MachineType::Float64(), WASM_I32V(index),
WASM_LOCAL_GET(0)),
WASM_I32V(index));
r.Build({WASM_STORE_MEM(MachineType::Float64(), WASM_I32V(index),
WASM_LOCAL_GET(0)),
WASM_I32V(index)});
r.Call(1345.3456);
CHECK(!r.possible_nondeterminism());
r.Call(std::numeric_limits<double>::quiet_NaN());
@ -424,7 +415,7 @@ TEST(TestPossibleNondeterminism) {
}
{
WasmRunner<float, float> r(TestExecutionTier::kInterpreter);
BUILD(r, WASM_F32_ADD(WASM_LOCAL_GET(0), WASM_LOCAL_GET(0)));
r.Build({WASM_F32_ADD(WASM_LOCAL_GET(0), WASM_LOCAL_GET(0))});
r.Call(1048575.5f);
CHECK(!r.possible_nondeterminism());
r.Call(std::numeric_limits<float>::quiet_NaN());
@ -432,7 +423,7 @@ TEST(TestPossibleNondeterminism) {
}
{
WasmRunner<double, double> r(TestExecutionTier::kInterpreter);
BUILD(r, WASM_F64_ADD(WASM_LOCAL_GET(0), WASM_LOCAL_GET(0)));
r.Build({WASM_F64_ADD(WASM_LOCAL_GET(0), WASM_LOCAL_GET(0))});
r.Call(16.0);
CHECK(!r.possible_nondeterminism());
r.Call(std::numeric_limits<double>::quiet_NaN());
@ -440,7 +431,7 @@ TEST(TestPossibleNondeterminism) {
}
{
WasmRunner<int32_t, float> r(TestExecutionTier::kInterpreter);
BUILD(r, WASM_F32_EQ(WASM_LOCAL_GET(0), WASM_LOCAL_GET(0)));
r.Build({WASM_F32_EQ(WASM_LOCAL_GET(0), WASM_LOCAL_GET(0))});
r.Call(16.0);
CHECK(!r.possible_nondeterminism());
r.Call(std::numeric_limits<float>::quiet_NaN());
@ -448,7 +439,7 @@ TEST(TestPossibleNondeterminism) {
}
{
WasmRunner<int32_t, double> r(TestExecutionTier::kInterpreter);
BUILD(r, WASM_F64_EQ(WASM_LOCAL_GET(0), WASM_LOCAL_GET(0)));
r.Build({WASM_F64_EQ(WASM_LOCAL_GET(0), WASM_LOCAL_GET(0))});
r.Call(16.0);
CHECK(!r.possible_nondeterminism());
r.Call(std::numeric_limits<double>::quiet_NaN());
@ -456,7 +447,7 @@ TEST(TestPossibleNondeterminism) {
}
{
WasmRunner<float, float> r(TestExecutionTier::kInterpreter);
BUILD(r, WASM_F32_MIN(WASM_LOCAL_GET(0), WASM_LOCAL_GET(0)));
r.Build({WASM_F32_MIN(WASM_LOCAL_GET(0), WASM_LOCAL_GET(0))});
r.Call(1048575.5f);
CHECK(!r.possible_nondeterminism());
r.Call(std::numeric_limits<float>::quiet_NaN());
@ -464,7 +455,7 @@ TEST(TestPossibleNondeterminism) {
}
{
WasmRunner<double, double> r(TestExecutionTier::kInterpreter);
BUILD(r, WASM_F64_MAX(WASM_LOCAL_GET(0), WASM_LOCAL_GET(0)));
r.Build({WASM_F64_MAX(WASM_LOCAL_GET(0), WASM_LOCAL_GET(0))});
r.Call(16.0);
CHECK(!r.possible_nondeterminism());
r.Call(std::numeric_limits<double>::quiet_NaN());
@ -475,7 +466,7 @@ TEST(TestPossibleNondeterminism) {
TEST(InterpreterLoadWithoutMemory) {
WasmRunner<int32_t, int32_t> r(TestExecutionTier::kInterpreter);
r.builder().AddMemory(0);
BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_LOCAL_GET(0)));
r.Build({WASM_LOAD_MEM(MachineType::Int32(), WASM_LOCAL_GET(0))});
CHECK_TRAP32(r.Call(0));
}
@ -483,28 +474,28 @@ TEST(Regress1111015) {
EXPERIMENTAL_FLAG_SCOPE(return_call);
WasmRunner<uint32_t> r(TestExecutionTier::kInterpreter);
WasmFunctionCompiler& f = r.NewFunction<int32_t>("f");
BUILD(r, WASM_BLOCK_I(WASM_RETURN_CALL_FUNCTION0(f.function_index()),
kExprDrop));
BUILD(f, WASM_I32V(0));
r.Build({WASM_BLOCK_I(WASM_RETURN_CALL_FUNCTION0(f.function_index()),
kExprDrop)});
f.Build({WASM_I32V(0)});
}
TEST(Regress1092130) {
WasmRunner<uint32_t> r(TestExecutionTier::kInterpreter);
TestSignatures sigs;
byte sig_v_i = r.builder().AddSignature(sigs.v_i());
BUILD(r, WASM_I32V(0),
WASM_IF_ELSE_I(
WASM_I32V(0),
WASM_SEQ(WASM_UNREACHABLE, WASM_BLOCK_X(sig_v_i, WASM_NOP)),
WASM_I32V(0)),
WASM_DROP);
r.Build({WASM_I32V(0),
WASM_IF_ELSE_I(
WASM_I32V(0),
WASM_SEQ(WASM_UNREACHABLE, WASM_BLOCK_X(sig_v_i, WASM_NOP)),
WASM_I32V(0)),
WASM_DROP});
r.Call();
}
TEST(Regress1247119) {
WasmRunner<uint32_t> r(TestExecutionTier::kInterpreter);
BUILD(r, kExprLoop, 0, kExprTry, 0, kExprUnreachable, kExprDelegate, 0,
kExprEnd);
r.Build({kExprLoop, 0, kExprTry, 0, kExprUnreachable, kExprDelegate, 0,
kExprEnd});
r.Call();
}
@ -513,16 +504,16 @@ TEST(Regress1246712) {
TestSignatures sigs;
const int kExpected = 1;
uint8_t except = r.builder().AddException(sigs.v_v());
BUILD(r, kExprTry, kWasmI32.value_type_code(), kExprTry,
kWasmI32.value_type_code(), kExprThrow, except, kExprEnd, kExprCatchAll,
kExprI32Const, kExpected, kExprEnd);
r.Build({kExprTry, kWasmI32.value_type_code(), kExprTry,
kWasmI32.value_type_code(), kExprThrow, except, kExprEnd,
kExprCatchAll, kExprI32Const, kExpected, kExprEnd});
CHECK_EQ(kExpected, r.Call());
}
TEST(Regress1249306) {
WasmRunner<uint32_t> r(TestExecutionTier::kInterpreter);
BUILD(r, kExprTry, kVoid, kExprCatchAll, kExprTry, kVoid, kExprDelegate, 0,
kExprEnd, kExprI32Const, 0);
r.Build({kExprTry, kVoid, kExprCatchAll, kExprTry, kVoid, kExprDelegate, 0,
kExprEnd, kExprI32Const, 0});
r.Call();
}
@ -532,11 +523,32 @@ TEST(Regress1251845) {
ValueType reps[] = {kWasmI32, kWasmI32, kWasmI32, kWasmI32};
FunctionSig sig_iii_i(1, 3, reps);
byte sig = r.builder().AddSignature(&sig_iii_i);
BUILD(r, kExprI32Const, 0, kExprI32Const, 0, kExprI32Const, 0, kExprTry, sig,
kExprI32Const, 0, kExprTry, 0, kExprTry, 0, kExprI32Const, 0, kExprTry,
sig, kExprUnreachable, kExprTry, 0, kExprUnreachable, kExprEnd,
kExprTry, sig, kExprUnreachable, kExprEnd, kExprEnd, kExprUnreachable,
kExprEnd, kExprEnd, kExprUnreachable, kExprEnd);
r.Build({
// clang-format off
kExprI32Const, 0,
kExprI32Const, 0,
kExprI32Const, 0,
kExprTry, sig,
kExprI32Const, 0,
kExprTry, 0,
kExprTry, 0,
kExprI32Const, 0,
kExprTry, sig,
kExprUnreachable,
kExprTry, 0,
kExprUnreachable,
kExprEnd,
kExprTry, sig,
kExprUnreachable,
kExprEnd,
kExprEnd,
kExprUnreachable,
kExprEnd,
kExprEnd,
kExprUnreachable,
kExprEnd
// clang-format on
});
r.Call(0, 0, 0);
}

View File

@ -68,7 +68,7 @@ ManuallyImportedJSFunction CreateJSSelector(FunctionSig* sig, int which) {
WASM_COMPILED_EXEC_TEST(Run_Int32Sub_jswrapped) {
WasmRunner<int, int, int> r(execution_tier);
BUILD(r, WASM_I32_SUB(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_I32_SUB(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
r.CheckCallViaJS(33, 44, 11);
r.CheckCallViaJS(-8723487, -8000000, 723487);
@ -76,7 +76,7 @@ WASM_COMPILED_EXEC_TEST(Run_Int32Sub_jswrapped) {
WASM_COMPILED_EXEC_TEST(Run_Float32Div_jswrapped) {
WasmRunner<float, float, float> r(execution_tier);
BUILD(r, WASM_F32_DIV(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_F32_DIV(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
r.CheckCallViaJS(92, 46, 0.5);
r.CheckCallViaJS(64, -16, -0.25);
@ -84,7 +84,7 @@ WASM_COMPILED_EXEC_TEST(Run_Float32Div_jswrapped) {
WASM_COMPILED_EXEC_TEST(Run_Float64Add_jswrapped) {
WasmRunner<double, double, double> r(execution_tier);
BUILD(r, WASM_F64_ADD(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)));
r.Build({WASM_F64_ADD(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1))});
r.CheckCallViaJS(3, 2, 1);
r.CheckCallViaJS(-5.5, -5.25, -0.25);
@ -92,7 +92,7 @@ WASM_COMPILED_EXEC_TEST(Run_Float64Add_jswrapped) {
WASM_COMPILED_EXEC_TEST(Run_I32Popcount_jswrapped) {
WasmRunner<int, int> r(execution_tier);
BUILD(r, WASM_I32_POPCNT(WASM_LOCAL_GET(0)));
r.Build({WASM_I32_POPCNT(WASM_LOCAL_GET(0))});
r.CheckCallViaJS(2, 9);
r.CheckCallViaJS(3, 11);
@ -109,7 +109,7 @@ WASM_COMPILED_EXEC_TEST(Run_CallJS_Add_jswrapped) {
ManuallyImportedJSFunction import = {sigs.i_i(), js_function};
WasmRunner<int, int> r(execution_tier, kWasmOrigin, &import);
uint32_t js_index = 0;
BUILD(r, WASM_CALL_FUNCTION(js_index, WASM_LOCAL_GET(0)));
r.Build({WASM_CALL_FUNCTION(js_index, WASM_LOCAL_GET(0))});
r.CheckCallViaJS(101, 2);
r.CheckCallViaJS(199, 100);
@ -143,7 +143,7 @@ void RunJSSelectTest(TestExecutionTier tier, int which) {
size_t end = code.size();
code.push_back(0);
t.Build(&code[0], &code[end]);
t.Build(base::VectorOf(code.data(), end));
}
double expected = inputs.arg_d(which);
@ -203,7 +203,7 @@ void RunWASMSelectTest(TestExecutionTier tier, int which) {
WasmRunner<void> r(tier);
WasmFunctionCompiler& t = r.NewFunction(&sig);
BUILD(t, WASM_LOCAL_GET(which));
t.Build({WASM_LOCAL_GET(which)});
Handle<Object> args[] = {
isolate->factory()->NewNumber(inputs.arg_d(0)),
@ -275,7 +275,7 @@ void RunWASMSelectAlignTest(TestExecutionTier tier, int num_args,
for (int which = 0; which < num_params; which++) {
WasmRunner<void> r(tier);
WasmFunctionCompiler& t = r.NewFunction(&sig);
BUILD(t, WASM_LOCAL_GET(which));
t.Build({WASM_LOCAL_GET(which)});
Handle<Object> args[] = {isolate->factory()->NewNumber(inputs.arg_d(0)),
isolate->factory()->NewNumber(inputs.arg_d(1)),
@ -389,7 +389,7 @@ void RunJSSelectAlignTest(TestExecutionTier tier, int num_args,
ManuallyImportedJSFunction import = CreateJSSelector(&sig, which);
WasmRunner<void> r(tier, kWasmOrigin, &import);
WasmFunctionCompiler& t = r.NewFunction(&sig);
t.Build(&code[0], &code[end]);
t.Build(base::VectorOf(code.data(), end));
Handle<Object> args[] = {
factory->NewNumber(inputs.arg_d(0)),
@ -505,13 +505,12 @@ void RunPickerTest(TestExecutionTier tier, bool indirect) {
r.builder().AddIndirectFunctionTable(indirect_function_table,
arraysize(indirect_function_table));
BUILD(rc_fn, WASM_RETURN_CALL_INDIRECT(sig_index, WASM_I32V(left),
WASM_I32V(right), WASM_LOCAL_GET(0),
WASM_I32V(js_index)));
rc_fn.Build(
{WASM_RETURN_CALL_INDIRECT(sig_index, WASM_I32V(left), WASM_I32V(right),
WASM_LOCAL_GET(0), WASM_I32V(js_index))});
} else {
BUILD(rc_fn,
WASM_RETURN_CALL_FUNCTION(js_index, WASM_I32V(left), WASM_I32V(right),
WASM_LOCAL_GET(0)));
rc_fn.Build({WASM_RETURN_CALL_FUNCTION(
js_index, WASM_I32V(left), WASM_I32V(right), WASM_LOCAL_GET(0))});
}
Handle<Object> args_left[] = {isolate->factory()->NewNumber(1)};

View File

@ -32,7 +32,7 @@ WASM_EXEC_TEST(Load) {
uint32_t* memory =
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(int32_t));
BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_LOCAL_GET(0)));
r.Build({WASM_LOAD_MEM(MachineType::Int32(), WASM_LOCAL_GET(0))});
CHECK_EQ(0, r.Call(0));
@ -94,7 +94,7 @@ WASM_EXEC_TEST(MemorySize) {
constexpr int kNumPages = 13;
r.builder().AddMemoryElems<uint8_t>(kNumPages * kWasmPageSize);
BUILD(r, WASM_MEMORY_SIZE);
r.Build({WASM_MEMORY_SIZE});
CHECK_EQ(kNumPages, r.Call());
}
@ -107,7 +107,7 @@ WASM_EXEC_TEST(MemoryGrow) {
r.builder().SetMaxMemPages(13);
r.builder().AddMemory(kWasmPageSize);
BUILD(r, WASM_MEMORY_GROW(WASM_LOCAL_GET(0)));
r.Build({WASM_MEMORY_GROW(WASM_LOCAL_GET(0))});
CHECK_EQ(1, r.Call(6));
CHECK_EQ(7, r.Call(1));
CHECK_EQ(-1, r.Call(-1));

View File

@ -137,12 +137,12 @@ WASM_RELAXED_SIMD_TEST(F32x4Qfma) {
float* g = r.builder().AddGlobal<float>(kWasmS128);
// Build fn to splat test values, perform compare op, and write the result.
byte value1 = 0, value2 = 1, value3 = 2;
BUILD(r,
WASM_GLOBAL_SET(0, WASM_SIMD_F32x4_QFMA(
WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value1)),
WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value2)),
WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value3)))),
WASM_ONE);
r.Build(
{WASM_GLOBAL_SET(0, WASM_SIMD_F32x4_QFMA(
WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value1)),
WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value2)),
WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value3)))),
WASM_ONE});
for (FMOperation<float> x : qfma_vector<float>()) {
r.Call(x.a, x.b, x.c);
@ -161,12 +161,12 @@ WASM_RELAXED_SIMD_TEST(F32x4Qfms) {
float* g = r.builder().AddGlobal<float>(kWasmS128);
// Build fn to splat test values, perform compare op, and write the result.
byte value1 = 0, value2 = 1, value3 = 2;
BUILD(r,
WASM_GLOBAL_SET(0, WASM_SIMD_F32x4_QFMS(
WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value1)),
WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value2)),
WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value3)))),
WASM_ONE);
r.Build(
{WASM_GLOBAL_SET(0, WASM_SIMD_F32x4_QFMS(
WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value1)),
WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value2)),
WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value3)))),
WASM_ONE});
for (FMOperation<float> x : qfms_vector<float>()) {
r.Call(x.a, x.b, x.c);
@ -185,12 +185,12 @@ WASM_RELAXED_SIMD_TEST(F64x2Qfma) {
double* g = r.builder().AddGlobal<double>(kWasmS128);
// Build fn to splat test values, perform compare op, and write the result.
byte value1 = 0, value2 = 1, value3 = 2;
BUILD(r,
WASM_GLOBAL_SET(0, WASM_SIMD_F64x2_QFMA(
WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value1)),
WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value2)),
WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value3)))),
WASM_ONE);
r.Build(
{WASM_GLOBAL_SET(0, WASM_SIMD_F64x2_QFMA(
WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value1)),
WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value2)),
WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value3)))),
WASM_ONE});
for (FMOperation<double> x : qfma_vector<double>()) {
r.Call(x.a, x.b, x.c);
@ -209,12 +209,12 @@ WASM_RELAXED_SIMD_TEST(F64x2Qfms) {
double* g = r.builder().AddGlobal<double>(kWasmS128);
// Build fn to splat test values, perform compare op, and write the result.
byte value1 = 0, value2 = 1, value3 = 2;
BUILD(r,
WASM_GLOBAL_SET(0, WASM_SIMD_F64x2_QFMS(
WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value1)),
WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value2)),
WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value3)))),
WASM_ONE);
r.Build(
{WASM_GLOBAL_SET(0, WASM_SIMD_F64x2_QFMS(
WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value1)),
WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value2)),
WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value3)))),
WASM_ONE});
for (FMOperation<double> x : qfms_vector<double>()) {
r.Call(x.a, x.b, x.c);
@ -235,16 +235,16 @@ TEST(RunWasm_RegressFmaReg_liftoff) {
byte local = r.AllocateLocal(kWasmS128);
float* g = r.builder().AddGlobal<float>(kWasmS128);
byte value1 = 0, value2 = 1, value3 = 2;
BUILD(r,
// Get the first arg from a local so that the register is blocked even
// after the arguments have been popped off the stack. This ensures that
// the first source register is not also the destination.
WASM_LOCAL_SET(local, WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value1))),
WASM_GLOBAL_SET(0, WASM_SIMD_F32x4_QFMA(
WASM_LOCAL_GET(local),
WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value2)),
WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value3)))),
WASM_ONE);
r.Build(
{// Get the first arg from a local so that the register is blocked even
// after the arguments have been popped off the stack. This ensures that
// the first source register is not also the destination.
WASM_LOCAL_SET(local, WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value1))),
WASM_GLOBAL_SET(0, WASM_SIMD_F32x4_QFMA(
WASM_LOCAL_GET(local),
WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value2)),
WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value3)))),
WASM_ONE});
for (FMOperation<float> x : qfma_vector<float>()) {
r.Call(x.a, x.b, x.c);
@ -280,11 +280,10 @@ void RelaxedLaneSelectTest(TestExecutionTier execution_tier, const T v1[kElems],
auto mask = as_uint8<T>(s);
WasmRunner<int32_t> r(execution_tier);
T* dst = r.builder().AddGlobal<T>(kWasmS128);
BUILD(r,
WASM_GLOBAL_SET(0, WASM_SIMD_OPN(laneselect, WASM_SIMD_CONSTANT(lhs),
WASM_SIMD_CONSTANT(rhs),
WASM_SIMD_CONSTANT(mask))),
WASM_ONE);
r.Build({WASM_GLOBAL_SET(0, WASM_SIMD_OPN(laneselect, WASM_SIMD_CONSTANT(lhs),
WASM_SIMD_CONSTANT(rhs),
WASM_SIMD_CONSTANT(mask))),
WASM_ONE});
CHECK_EQ(1, r.Call());
for (int i = 0; i < kElems; i++) {
@ -373,11 +372,10 @@ void IntRelaxedTruncFloatTest(TestExecutionTier execution_tier,
constexpr int lanes = kSimd128Size / sizeof(FloatType);
// global[0] = trunc(splat(local[0])).
BUILD(r,
WASM_GLOBAL_SET(
0, WASM_SIMD_UNOP(trunc_op,
WASM_SIMD_UNOP(splat_op, WASM_LOCAL_GET(0)))),
WASM_ONE);
r.Build({WASM_GLOBAL_SET(
0, WASM_SIMD_UNOP(trunc_op,
WASM_SIMD_UNOP(splat_op, WASM_LOCAL_GET(0)))),
WASM_ONE});
for (FloatType x : compiler::ValueHelper::GetVector<FloatType>()) {
if (ShouldSkipTestingConstant<IntType>(x)) continue;
@ -417,11 +415,10 @@ WASM_RELAXED_SIMD_TEST(I8x16RelaxedSwizzle) {
uint8_t* dst = r.builder().AddGlobal<uint8_t>(kWasmS128);
uint8_t* src = r.builder().AddGlobal<uint8_t>(kWasmS128);
uint8_t* indices = r.builder().AddGlobal<uint8_t>(kWasmS128);
BUILD(r,
WASM_GLOBAL_SET(
0, WASM_SIMD_BINOP(kExprI8x16RelaxedSwizzle, WASM_GLOBAL_GET(1),
WASM_GLOBAL_GET(2))),
WASM_ONE);
r.Build({WASM_GLOBAL_SET(
0, WASM_SIMD_BINOP(kExprI8x16RelaxedSwizzle, WASM_GLOBAL_GET(1),
WASM_GLOBAL_GET(2))),
WASM_ONE});
for (int i = 0; i < kElems; i++) {
LANE(src, i) = kElems - i - 1;
LANE(indices, i) = kElems - i - 1;
@ -440,12 +437,12 @@ WASM_RELAXED_SIMD_TEST(I16x8RelaxedQ15MulRS) {
byte value1 = 0, value2 = 1;
byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_LOCAL_SET(temp1, WASM_SIMD_I16x8_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_I16x8_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(
0, WASM_SIMD_BINOP(kExprI16x8RelaxedQ15MulRS, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_I16x8_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_I16x8_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(0, WASM_SIMD_BINOP(kExprI16x8RelaxedQ15MulRS,
WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE});
for (int16_t x : compiler::ValueHelper::GetVector<int16_t>()) {
for (int16_t y : compiler::ValueHelper::GetVector<int16_t>()) {
@ -472,12 +469,12 @@ WASM_RELAXED_SIMD_TEST(I16x8DotI8x16I7x16S) {
byte value1 = 0, value2 = 1;
byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_LOCAL_SET(temp1, WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(
0, WASM_SIMD_BINOP(kExprI16x8DotI8x16I7x16S, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(0, WASM_SIMD_BINOP(kExprI16x8DotI8x16I7x16S,
WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE});
for (int8_t x : compiler::ValueHelper::GetVector<int8_t>()) {
for (int8_t y : compiler::ValueHelper::GetVector<int8_t>()) {
@ -498,14 +495,14 @@ WASM_RELAXED_SIMD_TEST(I32x4DotI8x16I7x16AddS) {
byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128);
byte temp3 = r.AllocateLocal(kWasmS128);
BUILD(
r, WASM_LOCAL_SET(temp1, WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(value2))),
WASM_LOCAL_SET(temp3, WASM_SIMD_I32x4_SPLAT(WASM_LOCAL_GET(value3))),
WASM_GLOBAL_SET(0, WASM_SIMD_TERNOP(
kExprI32x4DotI8x16I7x16AddS, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2), WASM_LOCAL_GET(temp3))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(value2))),
WASM_LOCAL_SET(temp3, WASM_SIMD_I32x4_SPLAT(WASM_LOCAL_GET(value3))),
WASM_GLOBAL_SET(
0, WASM_SIMD_TERNOP(kExprI32x4DotI8x16I7x16AddS,
WASM_LOCAL_GET(temp1), WASM_LOCAL_GET(temp2),
WASM_LOCAL_GET(temp3))),
WASM_ONE});
for (int8_t x : compiler::ValueHelper::GetVector<int8_t>()) {
for (int8_t y : compiler::ValueHelper::GetVector<int8_t>()) {

View File

@ -12,7 +12,7 @@ namespace wasm {
WASM_EXEC_TEST(I32SExtendI8) {
WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, WASM_I32_SIGN_EXT_I8(WASM_LOCAL_GET(0)));
r.Build({WASM_I32_SIGN_EXT_I8(WASM_LOCAL_GET(0))});
CHECK_EQ(0, r.Call(0));
CHECK_EQ(1, r.Call(1));
CHECK_EQ(-1, r.Call(-1));
@ -22,7 +22,7 @@ WASM_EXEC_TEST(I32SExtendI8) {
WASM_EXEC_TEST(I32SExtendI16) {
WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, WASM_I32_SIGN_EXT_I16(WASM_LOCAL_GET(0)));
r.Build({WASM_I32_SIGN_EXT_I16(WASM_LOCAL_GET(0))});
CHECK_EQ(0, r.Call(0));
CHECK_EQ(1, r.Call(1));
CHECK_EQ(-1, r.Call(-1));
@ -32,7 +32,7 @@ WASM_EXEC_TEST(I32SExtendI16) {
WASM_EXEC_TEST(I64SExtendI8) {
WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SIGN_EXT_I8(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_SIGN_EXT_I8(WASM_LOCAL_GET(0))});
CHECK_EQ(0, r.Call(0));
CHECK_EQ(1, r.Call(1));
CHECK_EQ(-1, r.Call(-1));
@ -42,7 +42,7 @@ WASM_EXEC_TEST(I64SExtendI8) {
WASM_EXEC_TEST(I64SExtendI16) {
WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SIGN_EXT_I16(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_SIGN_EXT_I16(WASM_LOCAL_GET(0))});
CHECK_EQ(0, r.Call(0));
CHECK_EQ(1, r.Call(1));
CHECK_EQ(-1, r.Call(-1));
@ -52,7 +52,7 @@ WASM_EXEC_TEST(I64SExtendI16) {
WASM_EXEC_TEST(I64SExtendI32) {
WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SIGN_EXT_I32(WASM_LOCAL_GET(0)));
r.Build({WASM_I64_SIGN_EXT_I32(WASM_LOCAL_GET(0))});
CHECK_EQ(0, r.Call(0));
CHECK_EQ(1, r.Call(1));
CHECK_EQ(-1, r.Call(-1));

View File

@ -24,7 +24,7 @@ namespace test_run_wasm_simd_liftoff {
TEST(S128Local) {
WasmRunner<int32_t> r(TestExecutionTier::kLiftoff);
byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_LOCAL_SET(temp1, WASM_LOCAL_GET(temp1)), WASM_ONE);
r.Build({WASM_LOCAL_SET(temp1, WASM_LOCAL_GET(temp1)), WASM_ONE});
CHECK_EQ(1, r.Call());
}
@ -33,7 +33,7 @@ TEST(S128Global) {
int32_t* g0 = r.builder().AddGlobal<int32_t>(kWasmS128);
int32_t* g1 = r.builder().AddGlobal<int32_t>(kWasmS128);
BUILD(r, WASM_GLOBAL_SET(1, WASM_GLOBAL_GET(0)), WASM_ONE);
r.Build({WASM_GLOBAL_SET(1, WASM_GLOBAL_GET(0)), WASM_ONE});
int32_t expected = 0x1234;
for (int i = 0; i < 4; i++) {
@ -56,10 +56,10 @@ TEST(S128Param) {
// Liftoff does not support any SIMD operations.
byte temp1 = r.AllocateLocal(kWasmS128);
WasmFunctionCompiler& simd_func = r.NewFunction(sigs.i_s());
BUILD(simd_func, WASM_ONE);
simd_func.Build({WASM_ONE});
BUILD(r,
WASM_CALL_FUNCTION(simd_func.function_index(), WASM_LOCAL_GET(temp1)));
r.Build(
{WASM_CALL_FUNCTION(simd_func.function_index(), WASM_LOCAL_GET(temp1))});
CHECK_EQ(1, r.Call());
}
@ -70,10 +70,10 @@ TEST(S128Return) {
TestSignatures sigs;
WasmFunctionCompiler& simd_func = r.NewFunction(sigs.s_i());
byte temp1 = simd_func.AllocateLocal(kWasmS128);
BUILD(simd_func, WASM_LOCAL_GET(temp1));
simd_func.Build({WASM_LOCAL_GET(temp1)});
BUILD(r, WASM_CALL_FUNCTION(simd_func.function_index(), WASM_ONE), kExprDrop,
WASM_ONE);
r.Build({WASM_CALL_FUNCTION(simd_func.function_index(), WASM_ONE), kExprDrop,
WASM_ONE});
CHECK_EQ(1, r.Call());
}
@ -89,11 +89,11 @@ TEST(REGRESS_1088273) {
TestSignatures sigs;
WasmFunctionCompiler& simd_func = r.NewFunction(sigs.s_i());
byte temp1 = simd_func.AllocateLocal(kWasmS128);
BUILD(simd_func, WASM_LOCAL_GET(temp1));
simd_func.Build({WASM_LOCAL_GET(temp1)});
BUILD(r, WASM_SIMD_SPLAT(I8x16, WASM_I32V(0x80)),
WASM_SIMD_SPLAT(I8x16, WASM_I32V(0x92)),
WASM_SIMD_I16x8_EXTRACT_LANE_U(0, WASM_SIMD_OP(kExprI64x2Mul)));
r.Build({WASM_SIMD_SPLAT(I8x16, WASM_I32V(0x80)),
WASM_SIMD_SPLAT(I8x16, WASM_I32V(0x92)),
WASM_SIMD_I16x8_EXTRACT_LANE_U(0, WASM_SIMD_OP(kExprI64x2Mul))});
CHECK_EQ(18688, r.Call());
}
@ -125,13 +125,14 @@ TEST(I8x16Shuffle) {
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 31}};
// Set up locals so shuffle is called with non-adjacent registers v2 and v0.
BUILD(r, WASM_LOCAL_SET(local0, WASM_GLOBAL_GET(1)), // local0 is in v0
WASM_LOCAL_SET(local1, WASM_GLOBAL_GET(0)), // local1 is in v1
WASM_GLOBAL_GET(0), // global0 is in v2
WASM_LOCAL_GET(local0), // local0 is in v0
WASM_GLOBAL_SET(2, WASM_SIMD_I8x16_SHUFFLE_OP(
kExprI8x16Shuffle, pattern, WASM_NOP, WASM_NOP)),
WASM_ONE);
r.Build(
{WASM_LOCAL_SET(local0, WASM_GLOBAL_GET(1)), // local0 is in v0
WASM_LOCAL_SET(local1, WASM_GLOBAL_GET(0)), // local1 is in v1
WASM_GLOBAL_GET(0), // global0 is in v2
WASM_LOCAL_GET(local0), // local0 is in v0
WASM_GLOBAL_SET(2, WASM_SIMD_I8x16_SHUFFLE_OP(kExprI8x16Shuffle, pattern,
WASM_NOP, WASM_NOP)),
WASM_ONE});
r.Call();
@ -163,11 +164,12 @@ TEST(I8x16Shuffle_SingleOperand) {
{31, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}};
// Set up locals so shuffle is called with non-adjacent registers v2 and v0.
BUILD(r, WASM_LOCAL_SET(local0, WASM_GLOBAL_GET(0)), WASM_LOCAL_GET(local0),
WASM_LOCAL_GET(local0),
WASM_GLOBAL_SET(1, WASM_SIMD_I8x16_SHUFFLE_OP(
kExprI8x16Shuffle, pattern, WASM_NOP, WASM_NOP)),
WASM_ONE);
r.Build(
{WASM_LOCAL_SET(local0, WASM_GLOBAL_GET(0)), WASM_LOCAL_GET(local0),
WASM_LOCAL_GET(local0),
WASM_GLOBAL_SET(1, WASM_SIMD_I8x16_SHUFFLE_OP(kExprI8x16Shuffle, pattern,
WASM_NOP, WASM_NOP)),
WASM_ONE});
r.Call();
@ -198,17 +200,41 @@ TEST(FillStackSlotsWithZero_CheckStartOffset) {
// remainder, 8 in this case, so we hit the case where we use str.
simd_func.AllocateLocal(kWasmS128);
simd_func.AllocateLocal(kWasmI64);
BUILD(simd_func, WASM_I64V_1(1));
simd_func.Build({WASM_I64V_1(1)});
BUILD(r, WASM_I64V_1(1), WASM_I64V_1(1), WASM_I64V_1(1), WASM_I64V_1(1),
WASM_I64V_1(1), WASM_I64V_1(1), WASM_I64V_1(1), WASM_I64V_1(1),
WASM_I64V_1(1), WASM_I64V_1(1), WASM_I64V_1(1), WASM_I64V_1(1),
WASM_I64V_1(1), WASM_I64V_1(1), WASM_I64V_1(1), WASM_I64V_1(1),
WASM_I64V_1(1), WASM_I64V_1(1), WASM_I64V_1(1), WASM_I64V_1(1),
WASM_I64V_1(1), WASM_I64V_1(1), WASM_I64V_1(1), WASM_I64V_1(1),
WASM_I64V_1(1), WASM_I64V_1(1), WASM_I64V_1(1), WASM_I64V_1(1),
WASM_I64V_1(1), WASM_I64V_1(1), WASM_I64V_1(1), WASM_I64V_1(1),
WASM_CALL_FUNCTION0(simd_func.function_index()));
r.Build({WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_I64V_1(1),
WASM_CALL_FUNCTION0(simd_func.function_index())});
CHECK_EQ(1, r.Call());
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -284,7 +284,7 @@ int GetIntReturnValue(MaybeHandle<Object> retval) {
WASM_COMPILED_EXEC_TEST(WasmCollectPossibleBreakpoints) {
WasmRunner<int> runner(execution_tier);
BUILD(runner, WASM_NOP, WASM_I32_ADD(WASM_ZERO, WASM_ONE));
runner.Build({WASM_NOP, WASM_I32_ADD(WASM_ZERO, WASM_ONE)});
WasmInstanceObject instance = *runner.builder().instance_object();
NativeModule* native_module = instance.module_object().native_module();
@ -312,7 +312,7 @@ WASM_COMPILED_EXEC_TEST(WasmSimpleBreak) {
WasmRunner<int> runner(execution_tier);
Isolate* isolate = runner.main_isolate();
BUILD(runner, WASM_NOP, WASM_I32_ADD(WASM_I32V_1(11), WASM_I32V_1(3)));
runner.Build({WASM_NOP, WASM_I32_ADD(WASM_I32V_1(11), WASM_I32V_1(3))});
Handle<JSFunction> main_fun_wrapper =
runner.builder().WrapCode(runner.function_index());
@ -330,7 +330,7 @@ WASM_COMPILED_EXEC_TEST(WasmNonBreakablePosition) {
WasmRunner<int> runner(execution_tier);
Isolate* isolate = runner.main_isolate();
BUILD(runner, WASM_RETURN(WASM_I32V_2(1024)));
runner.Build({WASM_RETURN(WASM_I32V_2(1024))});
Handle<JSFunction> main_fun_wrapper =
runner.builder().WrapCode(runner.function_index());
@ -346,7 +346,7 @@ WASM_COMPILED_EXEC_TEST(WasmNonBreakablePosition) {
WASM_COMPILED_EXEC_TEST(WasmSimpleStepping) {
WasmRunner<int> runner(execution_tier);
BUILD(runner, WASM_I32_ADD(WASM_I32V_1(11), WASM_I32V_1(3)));
runner.Build({WASM_I32_ADD(WASM_I32V_1(11), WASM_I32V_1(3))});
Isolate* isolate = runner.main_isolate();
Handle<JSFunction> main_fun_wrapper =
@ -379,15 +379,14 @@ WASM_COMPILED_EXEC_TEST(WasmStepInAndOut) {
// functions in the code section matches the function indexes.
// return arg0
BUILD(runner, WASM_RETURN(WASM_LOCAL_GET(0)));
runner.Build({WASM_RETURN(WASM_LOCAL_GET(0))});
// for (int i = 0; i < 10; ++i) { f2(i); }
BUILD(f2, WASM_LOOP(
WASM_BR_IF(0, WASM_BINOP(kExprI32GeU, WASM_LOCAL_GET(0),
WASM_I32V_1(10))),
WASM_LOCAL_SET(
0, WASM_BINOP(kExprI32Sub, WASM_LOCAL_GET(0), WASM_ONE)),
WASM_CALL_FUNCTION(runner.function_index(), WASM_LOCAL_GET(0)),
WASM_DROP, WASM_BR(1)));
f2.Build({WASM_LOOP(
WASM_BR_IF(0,
WASM_BINOP(kExprI32GeU, WASM_LOCAL_GET(0), WASM_I32V_1(10))),
WASM_LOCAL_SET(0, WASM_BINOP(kExprI32Sub, WASM_LOCAL_GET(0), WASM_ONE)),
WASM_CALL_FUNCTION(runner.function_index(), WASM_LOCAL_GET(0)), WASM_DROP,
WASM_BR(1))});
Isolate* isolate = runner.main_isolate();
Handle<JSFunction> main_fun_wrapper =
@ -415,14 +414,14 @@ WASM_COMPILED_EXEC_TEST(WasmGetLocalsAndStack) {
runner.AllocateLocal(kWasmF32);
runner.AllocateLocal(kWasmF64);
BUILD(runner,
// set [1] to 17
WASM_LOCAL_SET(1, WASM_I64V_1(17)),
// set [2] to <arg0> = 7
WASM_LOCAL_SET(2, WASM_F32_SCONVERT_I32(WASM_LOCAL_GET(0))),
// set [3] to <arg1>/2 = 8.5
WASM_LOCAL_SET(3, WASM_F64_DIV(WASM_F64_SCONVERT_I64(WASM_LOCAL_GET(1)),
WASM_F64(2))));
runner.Build(
{// set [1] to 17
WASM_LOCAL_SET(1, WASM_I64V_1(17)),
// set [2] to <arg0> = 7
WASM_LOCAL_SET(2, WASM_F32_SCONVERT_I32(WASM_LOCAL_GET(0))),
// set [3] to <arg1>/2 = 8.5
WASM_LOCAL_SET(3, WASM_F64_DIV(WASM_F64_SCONVERT_I64(WASM_LOCAL_GET(1)),
WASM_F64(2)))});
Isolate* isolate = runner.main_isolate();
Handle<JSFunction> main_fun_wrapper =
@ -458,8 +457,8 @@ WASM_COMPILED_EXEC_TEST(WasmRemoveBreakPoint) {
WasmRunner<int> runner(execution_tier);
Isolate* isolate = runner.main_isolate();
BUILD(runner, WASM_NOP, WASM_NOP, WASM_NOP, WASM_NOP, WASM_NOP,
WASM_I32V_1(14));
runner.Build(
{WASM_NOP, WASM_NOP, WASM_NOP, WASM_NOP, WASM_NOP, WASM_I32V_1(14)});
Handle<JSFunction> main_fun_wrapper =
runner.builder().WrapCode(runner.function_index());
@ -489,8 +488,8 @@ WASM_COMPILED_EXEC_TEST(WasmRemoveLastBreakPoint) {
WasmRunner<int> runner(execution_tier);
Isolate* isolate = runner.main_isolate();
BUILD(runner, WASM_NOP, WASM_NOP, WASM_NOP, WASM_NOP, WASM_NOP,
WASM_I32V_1(14));
runner.Build(
{WASM_NOP, WASM_NOP, WASM_NOP, WASM_NOP, WASM_NOP, WASM_I32V_1(14)});
Handle<JSFunction> main_fun_wrapper =
runner.builder().WrapCode(runner.function_index());
@ -517,8 +516,8 @@ WASM_COMPILED_EXEC_TEST(WasmRemoveAllBreakPoint) {
WasmRunner<int> runner(execution_tier);
Isolate* isolate = runner.main_isolate();
BUILD(runner, WASM_NOP, WASM_NOP, WASM_NOP, WASM_NOP, WASM_NOP,
WASM_I32V_1(14));
runner.Build(
{WASM_NOP, WASM_NOP, WASM_NOP, WASM_NOP, WASM_NOP, WASM_I32V_1(14)});
Handle<JSFunction> main_fun_wrapper =
runner.builder().WrapCode(runner.function_index());
@ -558,9 +557,9 @@ WASM_COMPILED_EXEC_TEST(WasmBreakInPostMVP) {
constexpr int kReturn = 13;
constexpr int kIgnored = 23;
BUILD(runner,
WASM_BLOCK_X(sig_idx, WASM_I32V_1(kReturn), WASM_I32V_1(kIgnored)),
WASM_DROP);
runner.Build(
{WASM_BLOCK_X(sig_idx, WASM_I32V_1(kReturn), WASM_I32V_1(kIgnored)),
WASM_DROP});
Handle<JSFunction> main_fun_wrapper =
runner.builder().WrapCode(runner.function_index());
@ -578,7 +577,7 @@ WASM_COMPILED_EXEC_TEST(WasmBreakInPostMVP) {
WASM_COMPILED_EXEC_TEST(Regress10889) {
FLAG_SCOPE(print_wasm_code);
WasmRunner<int> runner(execution_tier);
BUILD(runner, WASM_I32V_1(0));
runner.Build({WASM_I32V_1(0)});
SetBreakpoint(&runner, runner.function_index(), 1, 1);
}

View File

@ -133,11 +133,11 @@ WASM_COMPILED_EXEC_TEST(CollectDetailedWasmStack_ExplicitThrowFromJs) {
WasmRunner<void> r(execution_tier, kWasmOrigin, &import);
// Add a nop such that we don't always get position 1.
BUILD(r, WASM_NOP, WASM_CALL_FUNCTION0(js_throwing_index));
r.Build({WASM_NOP, WASM_CALL_FUNCTION0(js_throwing_index)});
uint32_t wasm_index_1 = r.function()->func_index;
WasmFunctionCompiler& f2 = r.NewFunction<void>("call_main");
BUILD(f2, WASM_CALL_FUNCTION0(wasm_index_1));
f2.Build({WASM_CALL_FUNCTION0(wasm_index_1)});
uint32_t wasm_index_2 = f2.function_index();
Handle<JSFunction> js_wasm_wrapper = r.builder().WrapCode(wasm_index_2);
@ -178,7 +178,7 @@ WASM_COMPILED_EXEC_TEST(CollectDetailedWasmStack_WasmUrl) {
r.Build(trap_code.data(), trap_code.data() + trap_code.size());
WasmFunctionCompiler& f = r.NewFunction<int>("call_main");
BUILD(f, WASM_CALL_FUNCTION0(0));
f.Build({WASM_CALL_FUNCTION0(0)});
uint32_t wasm_index = f.function_index();
Handle<JSFunction> js_wasm_wrapper = r.builder().WrapCode(wasm_index);
@ -243,7 +243,7 @@ WASM_COMPILED_EXEC_TEST(CollectDetailedWasmStack_WasmError) {
uint32_t wasm_index_1 = r.function()->func_index;
WasmFunctionCompiler& f2 = r.NewFunction<int>("call_main");
BUILD(f2, WASM_CALL_FUNCTION0(0));
f2.Build({WASM_CALL_FUNCTION0(0)});
uint32_t wasm_index_2 = f2.function_index();
Handle<JSFunction> js_wasm_wrapper = r.builder().WrapCode(wasm_index_2);

View File

@ -72,7 +72,7 @@ WASM_COMPILED_EXEC_TEST(Unreachable) {
kRuntimeExceptionSupport);
TestSignatures sigs;
BUILD(r, WASM_UNREACHABLE);
r.Build({WASM_UNREACHABLE});
uint32_t wasm_index = r.function()->func_index;
Handle<JSFunction> js_wasm_wrapper = r.builder().WrapCode(wasm_index);
@ -108,14 +108,14 @@ WASM_COMPILED_EXEC_TEST(IllegalLoad) {
r.builder().AddMemory(0L);
BUILD(r, WASM_IF(WASM_ONE, WASM_SEQ(WASM_LOAD_MEM(MachineType::Int32(),
WASM_I32V_1(-3)),
WASM_DROP)));
r.Build({WASM_IF(
WASM_ONE, WASM_SEQ(WASM_LOAD_MEM(MachineType::Int32(), WASM_I32V_1(-3)),
WASM_DROP))});
uint32_t wasm_index_1 = r.function()->func_index;
WasmFunctionCompiler& f2 = r.NewFunction<void>("call_main");
// Insert a NOP such that the position of the call is not one.
BUILD(f2, WASM_NOP, WASM_CALL_FUNCTION0(wasm_index_1));
f2.Build({WASM_NOP, WASM_CALL_FUNCTION0(wasm_index_1)});
uint32_t wasm_index_2 = f2.function_index();
Handle<JSFunction> js_wasm_wrapper = r.builder().WrapCode(wasm_index_2);

View File

@ -578,28 +578,26 @@ Handle<Code> WasmFunctionWrapper::GetWrapperCode(Isolate* isolate) {
// This struct is just a type tag for Zone::NewArray<T>(size_t) call.
struct WasmFunctionCompilerBuffer {};
void WasmFunctionCompiler::Build(const byte* start, const byte* end) {
void WasmFunctionCompiler::Build(base::Vector<const uint8_t> bytes) {
size_t locals_size = local_decls.Size();
size_t total_size = end - start + locals_size + 1;
size_t total_size = bytes.size() + locals_size + 1;
byte* buffer = zone()->NewArray<byte, WasmFunctionCompilerBuffer>(total_size);
// Prepend the local decls to the code.
local_decls.Emit(buffer);
// Emit the code.
memcpy(buffer + locals_size, start, end - start);
memcpy(buffer + locals_size, bytes.begin(), bytes.size());
// Append an extra end opcode.
buffer[total_size - 1] = kExprEnd;
start = buffer;
end = buffer + total_size;
bytes = base::VectorOf(buffer, total_size);
CHECK_GE(kMaxInt, end - start);
int len = static_cast<int>(end - start);
function_->code = {builder_->AddBytes(base::Vector<const byte>(start, len)),
static_cast<uint32_t>(len)};
function_->code = {builder_->AddBytes(bytes),
static_cast<uint32_t>(bytes.size())};
if (interpreter_) {
// Add the code to the interpreter; do not generate compiled code.
interpreter_->SetFunctionCodeForTesting(function_, start, end);
interpreter_->SetFunctionCodeForTesting(function_, bytes.begin(),
bytes.end());
return;
}

View File

@ -82,12 +82,6 @@ using compiler::Node;
#define WASM_WRAPPER_RETURN_VALUE 8754
#define BUILD(r, ...) \
do { \
byte __code[] = {__VA_ARGS__}; \
r.Build(__code, __code + arraysize(__code)); \
} while (false)
#define ADD_CODE(vec, ...) \
do { \
byte __buf[] = {__VA_ARGS__}; \
@ -374,7 +368,10 @@ class WasmFunctionCompiler : public compiler::GraphAndBuilders {
uint32_t function_index() { return function_->func_index; }
uint32_t sig_index() { return function_->sig_index; }
void Build(const byte* start, const byte* end);
void Build(std::initializer_list<const uint8_t> bytes) {
Build(base::VectorOf(bytes));
}
void Build(base::Vector<const uint8_t> bytes);
byte AllocateLocal(ValueType type) {
uint32_t index = local_decls.AddLocals(1, type);
@ -430,10 +427,16 @@ class WasmRunnerBase : public InitializedHandleScope {
// Builds a graph from the given Wasm code and generates the machine
// code and call wrapper for that graph. This method must not be called
// more than once.
void Build(const byte* start, const byte* end) {
void Build(const uint8_t* start, const uint8_t* end) {
Build(base::VectorOf(start, end - start));
}
void Build(std::initializer_list<const uint8_t> bytes) {
Build(base::VectorOf(bytes));
}
void Build(base::Vector<const uint8_t> bytes) {
CHECK(!compiled_);
compiled_ = true;
functions_[0]->Build(start, end);
functions_[0]->Build(bytes);
}
// Resets the state for building the next function.

View File

@ -30,9 +30,9 @@ void RunI8x16UnOpTest(TestExecutionTier execution_tier, WasmOpcode opcode,
// Build fn to splat test value, perform unop, and write the result.
byte value = 0;
byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_LOCAL_SET(temp1, WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_UNOP(opcode, WASM_LOCAL_GET(temp1))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_UNOP(opcode, WASM_LOCAL_GET(temp1))),
WASM_ONE});
FOR_INT8_INPUTS(x) {
r.Call(x);
@ -53,11 +53,11 @@ void RunI8x16BinOpTest(TestExecutionTier execution_tier, WasmOpcode opcode,
byte value1 = 0, value2 = 1;
byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_LOCAL_SET(temp1, WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(0, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(0, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE});
for (T x : compiler::ValueHelper::GetVector<T>()) {
for (T y : compiler::ValueHelper::GetVector<T>()) {
@ -88,14 +88,14 @@ void RunI8x16ShiftOpTest(TestExecutionTier execution_tier, WasmOpcode opcode,
byte value = 0;
byte simd = r.AllocateLocal(kWasmS128);
// Shift using an immediate, and shift using a value loaded from memory.
BUILD(
r, WASM_LOCAL_SET(simd, WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_SHIFT_OP(opcode, WASM_LOCAL_GET(simd),
WASM_I32V(shift))),
WASM_GLOBAL_SET(1, WASM_SIMD_SHIFT_OP(
opcode, WASM_LOCAL_GET(simd),
WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(simd, WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_SHIFT_OP(opcode, WASM_LOCAL_GET(simd),
WASM_I32V(shift))),
WASM_GLOBAL_SET(
1, WASM_SIMD_SHIFT_OP(
opcode, WASM_LOCAL_GET(simd),
WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO))),
WASM_ONE});
r.builder().WriteMemory(&memory[0], shift);
FOR_INT8_INPUTS(x) {
@ -116,11 +116,11 @@ void RunI8x16MixedRelationalOpTest(TestExecutionTier execution_tier,
byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128);
byte temp3 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_LOCAL_SET(temp1, WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_I16x8_SPLAT(WASM_LOCAL_GET(value2))),
WASM_LOCAL_SET(temp3, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_SIMD_I8x16_EXTRACT_LANE(0, WASM_LOCAL_GET(temp3)));
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_I16x8_SPLAT(WASM_LOCAL_GET(value2))),
WASM_LOCAL_SET(temp3, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_SIMD_I8x16_EXTRACT_LANE(0, WASM_LOCAL_GET(temp3))});
CHECK_EQ(expected_op(0xff, static_cast<uint8_t>(0x7fff)),
r.Call(0xff, 0x7fff));
@ -138,9 +138,9 @@ void RunI16x8UnOpTest(TestExecutionTier execution_tier, WasmOpcode opcode,
// Build fn to splat test value, perform unop, and write the result.
byte value = 0;
byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_LOCAL_SET(temp1, WASM_SIMD_I16x8_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_UNOP(opcode, WASM_LOCAL_GET(temp1))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_I16x8_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_UNOP(opcode, WASM_LOCAL_GET(temp1))),
WASM_ONE});
FOR_INT16_INPUTS(x) {
r.Call(x);
@ -161,11 +161,11 @@ void RunI16x8BinOpTest(TestExecutionTier execution_tier, WasmOpcode opcode,
byte value1 = 0, value2 = 1;
byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_LOCAL_SET(temp1, WASM_SIMD_I16x8_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_I16x8_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(0, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_I16x8_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_I16x8_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(0, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE});
for (T x : compiler::ValueHelper::GetVector<T>()) {
for (T y : compiler::ValueHelper::GetVector<T>()) {
@ -195,14 +195,14 @@ void RunI16x8ShiftOpTest(TestExecutionTier execution_tier, WasmOpcode opcode,
byte value = 0;
byte simd = r.AllocateLocal(kWasmS128);
// Shift using an immediate, and shift using a value loaded from memory.
BUILD(
r, WASM_LOCAL_SET(simd, WASM_SIMD_I16x8_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_SHIFT_OP(opcode, WASM_LOCAL_GET(simd),
WASM_I32V(shift))),
WASM_GLOBAL_SET(1, WASM_SIMD_SHIFT_OP(
opcode, WASM_LOCAL_GET(simd),
WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(simd, WASM_SIMD_I16x8_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_SHIFT_OP(opcode, WASM_LOCAL_GET(simd),
WASM_I32V(shift))),
WASM_GLOBAL_SET(
1, WASM_SIMD_SHIFT_OP(
opcode, WASM_LOCAL_GET(simd),
WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO))),
WASM_ONE});
r.builder().WriteMemory(&memory[0], shift);
FOR_INT16_INPUTS(x) {
@ -223,11 +223,11 @@ void RunI16x8MixedRelationalOpTest(TestExecutionTier execution_tier,
byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128);
byte temp3 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_LOCAL_SET(temp1, WASM_SIMD_I16x8_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_I32x4_SPLAT(WASM_LOCAL_GET(value2))),
WASM_LOCAL_SET(temp3, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_SIMD_I16x8_EXTRACT_LANE(0, WASM_LOCAL_GET(temp3)));
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_I16x8_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_I32x4_SPLAT(WASM_LOCAL_GET(value2))),
WASM_LOCAL_SET(temp3, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_SIMD_I16x8_EXTRACT_LANE(0, WASM_LOCAL_GET(temp3))});
CHECK_EQ(expected_op(0xffff, static_cast<uint16_t>(0x7fffffff)),
r.Call(0xffff, 0x7fffffff));
@ -245,9 +245,9 @@ void RunI32x4UnOpTest(TestExecutionTier execution_tier, WasmOpcode opcode,
// Build fn to splat test value, perform unop, and write the result.
byte value = 0;
byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_LOCAL_SET(temp1, WASM_SIMD_I32x4_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_UNOP(opcode, WASM_LOCAL_GET(temp1))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_I32x4_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_UNOP(opcode, WASM_LOCAL_GET(temp1))),
WASM_ONE});
FOR_INT32_INPUTS(x) {
r.Call(x);
@ -267,11 +267,11 @@ void RunI32x4BinOpTest(TestExecutionTier execution_tier, WasmOpcode opcode,
byte value1 = 0, value2 = 1;
byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_LOCAL_SET(temp1, WASM_SIMD_I32x4_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_I32x4_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(0, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_I32x4_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_I32x4_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(0, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE});
FOR_INT32_INPUTS(x) {
FOR_INT32_INPUTS(y) {
@ -295,14 +295,14 @@ void RunI32x4ShiftOpTest(TestExecutionTier execution_tier, WasmOpcode opcode,
byte value = 0;
byte simd = r.AllocateLocal(kWasmS128);
// Shift using an immediate, and shift using a value loaded from memory.
BUILD(
r, WASM_LOCAL_SET(simd, WASM_SIMD_I32x4_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_SHIFT_OP(opcode, WASM_LOCAL_GET(simd),
WASM_I32V(shift))),
WASM_GLOBAL_SET(1, WASM_SIMD_SHIFT_OP(
opcode, WASM_LOCAL_GET(simd),
WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(simd, WASM_SIMD_I32x4_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_SHIFT_OP(opcode, WASM_LOCAL_GET(simd),
WASM_I32V(shift))),
WASM_GLOBAL_SET(
1, WASM_SIMD_SHIFT_OP(
opcode, WASM_LOCAL_GET(simd),
WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO))),
WASM_ONE});
r.builder().WriteMemory(&memory[0], shift);
FOR_INT32_INPUTS(x) {
@ -324,9 +324,9 @@ void RunI64x2UnOpTest(TestExecutionTier execution_tier, WasmOpcode opcode,
// Build fn to splat test value, perform unop, and write the result.
byte value = 0;
byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_LOCAL_SET(temp1, WASM_SIMD_I64x2_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_UNOP(opcode, WASM_LOCAL_GET(temp1))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_I64x2_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_UNOP(opcode, WASM_LOCAL_GET(temp1))),
WASM_ONE});
FOR_INT64_INPUTS(x) {
r.Call(x);
@ -346,11 +346,11 @@ void RunI64x2BinOpTest(TestExecutionTier execution_tier, WasmOpcode opcode,
byte value1 = 0, value2 = 1;
byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_LOCAL_SET(temp1, WASM_SIMD_I64x2_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_I64x2_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(0, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_I64x2_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_I64x2_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(0, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE});
FOR_INT64_INPUTS(x) {
FOR_INT64_INPUTS(y) {
@ -374,14 +374,14 @@ void RunI64x2ShiftOpTest(TestExecutionTier execution_tier, WasmOpcode opcode,
byte value = 0;
byte simd = r.AllocateLocal(kWasmS128);
// Shift using an immediate, and shift using a value loaded from memory.
BUILD(
r, WASM_LOCAL_SET(simd, WASM_SIMD_I64x2_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_SHIFT_OP(opcode, WASM_LOCAL_GET(simd),
WASM_I32V(shift))),
WASM_GLOBAL_SET(1, WASM_SIMD_SHIFT_OP(
opcode, WASM_LOCAL_GET(simd),
WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(simd, WASM_SIMD_I64x2_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_SHIFT_OP(opcode, WASM_LOCAL_GET(simd),
WASM_I32V(shift))),
WASM_GLOBAL_SET(
1, WASM_SIMD_SHIFT_OP(
opcode, WASM_LOCAL_GET(simd),
WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO))),
WASM_ONE});
r.builder().WriteMemory(&memory[0], shift);
FOR_INT64_INPUTS(x) {
@ -448,9 +448,9 @@ void RunF32x4UnOpTest(TestExecutionTier execution_tier, WasmOpcode opcode,
// Build fn to splat test value, perform unop, and write the result.
byte value = 0;
byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_LOCAL_SET(temp1, WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_UNOP(opcode, WASM_LOCAL_GET(temp1))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_UNOP(opcode, WASM_LOCAL_GET(temp1))),
WASM_ONE});
FOR_FLOAT32_INPUTS(x) {
if (!PlatformCanRepresent(x)) continue;
@ -508,11 +508,11 @@ void RunF32x4BinOpTest(TestExecutionTier execution_tier, WasmOpcode opcode,
byte value1 = 0, value2 = 1;
byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_LOCAL_SET(temp1, WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(0, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(0, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE});
FOR_FLOAT32_INPUTS(x) {
if (!PlatformCanRepresent(x)) continue;
@ -556,11 +556,11 @@ void RunF32x4CompareOpTest(TestExecutionTier execution_tier, WasmOpcode opcode,
byte value1 = 0, value2 = 1;
byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_LOCAL_SET(temp1, WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(0, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_F32x4_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(0, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE});
FOR_FLOAT32_INPUTS(x) {
if (!PlatformCanRepresent(x)) continue;
@ -630,9 +630,9 @@ void RunF64x2UnOpTest(TestExecutionTier execution_tier, WasmOpcode opcode,
// Build fn to splat test value, perform unop, and write the result.
byte value = 0;
byte temp1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_LOCAL_SET(temp1, WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_UNOP(opcode, WASM_LOCAL_GET(temp1))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value))),
WASM_GLOBAL_SET(0, WASM_SIMD_UNOP(opcode, WASM_LOCAL_GET(temp1))),
WASM_ONE});
FOR_FLOAT64_INPUTS(x) {
if (!PlatformCanRepresent(x)) continue;
@ -675,11 +675,11 @@ void RunF64x2BinOpTest(TestExecutionTier execution_tier, WasmOpcode opcode,
byte value1 = 0, value2 = 1;
byte temp1 = r.AllocateLocal(kWasmS128);
byte temp2 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_LOCAL_SET(temp1, WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(0, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp2, WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(0, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE});
FOR_FLOAT64_INPUTS(x) {
if (!PlatformCanRepresent(x)) continue;
@ -724,14 +724,14 @@ void RunF64x2CompareOpTest(TestExecutionTier execution_tier, WasmOpcode opcode,
byte temp2 = r.AllocateLocal(kWasmS128);
// Make the lanes of each temp compare differently:
// temp1 = y, x and temp2 = y, y.
BUILD(r, WASM_LOCAL_SET(temp1, WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp1,
WASM_SIMD_F64x2_REPLACE_LANE(1, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(value2))),
WASM_LOCAL_SET(temp2, WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(0, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE);
r.Build({WASM_LOCAL_SET(temp1, WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value1))),
WASM_LOCAL_SET(temp1,
WASM_SIMD_F64x2_REPLACE_LANE(1, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(value2))),
WASM_LOCAL_SET(temp2, WASM_SIMD_F64x2_SPLAT(WASM_LOCAL_GET(value2))),
WASM_GLOBAL_SET(0, WASM_SIMD_BINOP(opcode, WASM_LOCAL_GET(temp1),
WASM_LOCAL_GET(temp2))),
WASM_ONE});
FOR_FLOAT64_INPUTS(x) {
if (!PlatformCanRepresent(x)) continue;