Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: test/cctest/wasm/test-run-wasm.cc

Issue 2361053004: Revert of [wasm] Master CL for Binary 0xC changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-result.h ('k') | test/cctest/wasm/test-run-wasm-64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/wasm/test-run-wasm.cc
diff --git a/test/cctest/wasm/test-run-wasm.cc b/test/cctest/wasm/test-run-wasm.cc
index 422ced9be95ab6108041a21140bc0bcfbe93c0d0..48dcad51768603b4dc6e7a5657d2d7fabaad9cf5 100644
--- a/test/cctest/wasm/test-run-wasm.cc
+++ b/test/cctest/wasm/test-run-wasm.cc
@@ -21,11 +21,10 @@
using namespace v8::internal::wasm;
// for even shorter tests.
-#define B1(a) WASM_BLOCK(a)
-#define B2(a, b) WASM_BLOCK(a, b)
-#define B3(a, b, c) WASM_BLOCK(a, b, c)
-#define RET(x) x, kExprReturn
-#define RET_I8(x) kExprI8Const, x, kExprReturn
+#define B2(a, b) kExprBlock, a, b, kExprEnd
+#define B1(a) kExprBlock, a, kExprEnd
+#define RET(x) x, kExprReturn, 1
+#define RET_I8(x) kExprI8Const, x, kExprReturn, 1
WASM_EXEC_TEST(Int8Const) {
WasmRunner<int32_t> r(execution_mode);
@@ -35,11 +34,11 @@
CHECK_EQ(kExpectedValue, r.Call());
}
-WASM_EXEC_TEST(Int8Const_end) {
+WASM_EXEC_TEST(Int8Const_fallthru1) {
WasmRunner<int32_t> r(execution_mode);
- const byte kExpectedValue = 121;
- // return(kExpectedValue)
- BUILD(r, WASM_I8(kExpectedValue), kExprEnd);
+ const byte kExpectedValue = 122;
+ // kExpectedValue
+ BUILD(r, WASM_I8(kExpectedValue));
CHECK_EQ(kExpectedValue, r.Call());
}
@@ -47,7 +46,7 @@
WasmRunner<int32_t> r(execution_mode);
const byte kExpectedValue = 123;
// -99 kExpectedValue
- BUILD(r, WASM_I8(-99), WASM_DROP, WASM_I8(kExpectedValue));
+ BUILD(r, WASM_I8(-99), WASM_I8(kExpectedValue));
CHECK_EQ(kExpectedValue, r.Call());
}
@@ -79,20 +78,12 @@
}
}
-WASM_EXEC_TEST(MemorySize1) {
+WASM_EXEC_TEST(MemorySize) {
TestingModule module(execution_mode);
WasmRunner<int32_t> r(&module);
- module.AddMemory(WasmModule::kPageSize * 1);
+ module.AddMemory(1024);
BUILD(r, kExprMemorySize);
- CHECK_EQ(1, r.Call());
-}
-
-WASM_EXEC_TEST(MemorySize2) {
- TestingModule module(execution_mode);
- WasmRunner<int32_t> r(&module);
- module.AddMemory(WasmModule::kPageSize * 3);
- BUILD(r, kExprMemorySize);
- CHECK_EQ(3, r.Call());
+ CHECK_EQ(1024, r.Call());
}
WASM_EXEC_TEST(Int32Param0) {
@@ -138,11 +129,11 @@
FOR_INT32_INPUTS(i) { CHECK_EQ(*i + 13, r.Call(*i)); }
}
-static void RunInt32AddTest(WasmExecutionMode execution_mode, const byte* code,
- size_t size) {
+WASM_EXEC_TEST(Int32Add_P2) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32(),
MachineType::Int32());
- r.Build(code, code + size);
+ // p0 + p1
+ BUILD(r, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) {
int32_t expected = static_cast<int32_t>(static_cast<uint32_t>(*i) +
@@ -150,40 +141,6 @@
CHECK_EQ(expected, r.Call(*i, *j));
}
}
-}
-
-WASM_EXEC_TEST(Int32Add_P2) {
- FLAG_wasm_mv_prototype = true;
- static const byte code[] = {
- WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))};
- RunInt32AddTest(execution_mode, code, sizeof(code));
-}
-
-WASM_EXEC_TEST(Int32Add_block1) {
- FLAG_wasm_mv_prototype = true;
- static const byte code[] = {
- WASM_BLOCK_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)),
- kExprI32Add};
- RunInt32AddTest(execution_mode, code, sizeof(code));
-}
-
-WASM_EXEC_TEST(Int32Add_block2) {
- FLAG_wasm_mv_prototype = true;
- static const byte code[] = {
- WASM_BLOCK_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1),
- kExprBr, DEPTH_0),
- kExprI32Add};
- RunInt32AddTest(execution_mode, code, sizeof(code));
-}
-
-WASM_EXEC_TEST(Int32Add_multi_if) {
- FLAG_wasm_mv_prototype = true;
- static const byte code[] = {
- WASM_IF_ELSE_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0),
- WASM_SEQ(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)),
- WASM_SEQ(WASM_GET_LOCAL(1), WASM_GET_LOCAL(0))),
- kExprI32Add};
- RunInt32AddTest(execution_mode, code, sizeof(code));
}
WASM_EXEC_TEST(Float32Add) {
@@ -476,18 +433,14 @@
module.AddMemoryElems<int32_t>(8);
WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32());
- BUILD(r, WASM_IF_ELSE_I(
- WASM_GET_LOCAL(0),
- WASM_I32_DIVS(
- WASM_BLOCK_I(WASM_STORE_MEM(MachineType::Int8(), WASM_ZERO,
- WASM_GET_LOCAL(0)),
- WASM_GET_LOCAL(0)),
- WASM_GET_LOCAL(1)),
- WASM_I32_DIVS(
- WASM_BLOCK_I(WASM_STORE_MEM(MachineType::Int8(), WASM_ZERO,
- WASM_GET_LOCAL(0)),
- WASM_GET_LOCAL(0)),
- WASM_GET_LOCAL(1))));
+ BUILD(r,
+ WASM_IF_ELSE(WASM_GET_LOCAL(0),
+ WASM_I32_DIVS(WASM_STORE_MEM(MachineType::Int8(),
+ WASM_ZERO, WASM_GET_LOCAL(0)),
+ WASM_GET_LOCAL(1)),
+ WASM_I32_DIVS(WASM_STORE_MEM(MachineType::Int8(),
+ WASM_ZERO, WASM_GET_LOCAL(0)),
+ WASM_GET_LOCAL(1))));
CHECK_EQ(0, r.Call(0, 100));
CHECK_TRAP(r.Call(8, 0));
CHECK_TRAP(r.Call(4, 0));
@@ -665,52 +618,50 @@
WASM_EXEC_TEST(IfElse_P) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
// if (p0) return 11; else return 22;
- BUILD(r, WASM_IF_ELSE_I(WASM_GET_LOCAL(0), // --
- WASM_I8(11), // --
- WASM_I8(22))); // --
+ BUILD(r, WASM_IF_ELSE(WASM_GET_LOCAL(0), // --
+ WASM_I8(11), // --
+ WASM_I8(22))); // --
FOR_INT32_INPUTS(i) {
int32_t expected = *i ? 11 : 22;
CHECK_EQ(expected, r.Call(*i));
}
}
-#define EMPTY
WASM_EXEC_TEST(If_empty1) {
WasmRunner<uint32_t> r(execution_mode, MachineType::Uint32(),
MachineType::Uint32());
- BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, kExprEnd, WASM_GET_LOCAL(1));
+ BUILD(r, WASM_GET_LOCAL(0), kExprIf, kExprEnd, WASM_GET_LOCAL(1));
FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i - 9, *i)); }
}
WASM_EXEC_TEST(IfElse_empty1) {
WasmRunner<uint32_t> r(execution_mode, MachineType::Uint32(),
MachineType::Uint32());
- BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, kExprElse, kExprEnd,
- WASM_GET_LOCAL(1));
+ BUILD(r, WASM_GET_LOCAL(0), kExprIf, kExprElse, kExprEnd, WASM_GET_LOCAL(1));
FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i - 8, *i)); }
}
WASM_EXEC_TEST(IfElse_empty2) {
WasmRunner<uint32_t> r(execution_mode, MachineType::Uint32(),
MachineType::Uint32());
- BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, WASM_NOP, kExprElse,
- kExprEnd, WASM_GET_LOCAL(1));
+ BUILD(r, WASM_GET_LOCAL(0), kExprIf, WASM_ZERO, kExprElse, kExprEnd,
+ WASM_GET_LOCAL(1));
FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i - 7, *i)); }
}
WASM_EXEC_TEST(IfElse_empty3) {
WasmRunner<uint32_t> r(execution_mode, MachineType::Uint32(),
MachineType::Uint32());
- BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, kExprElse, WASM_NOP,
- kExprEnd, WASM_GET_LOCAL(1));
+ BUILD(r, WASM_GET_LOCAL(0), kExprIf, kExprElse, WASM_ZERO, kExprEnd,
+ WASM_GET_LOCAL(1));
FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i - 6, *i)); }
}
-WASM_EXEC_TEST(If_chain1) {
+WASM_EXEC_TEST(If_chain) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
// if (p0) 13; if (p0) 14; 15
- BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_NOP),
- WASM_IF(WASM_GET_LOCAL(0), WASM_NOP), WASM_I8(15));
+ BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_I8(13)),
+ WASM_IF(WASM_GET_LOCAL(0), WASM_I8(14)), WASM_I8(15));
FOR_INT32_INPUTS(i) { CHECK_EQ(15, r.Call(*i)); }
}
@@ -729,20 +680,11 @@
WASM_EXEC_TEST(IfElse_Unreachable1) {
WasmRunner<int32_t> r(execution_mode);
- // 0 ? unreachable : 27
- BUILD(r, WASM_IF_ELSE_I(WASM_ZERO, // --
- WASM_UNREACHABLE, // --
- WASM_I8(27))); // --
+ // if (0) unreachable; else return 22;
+ BUILD(r, WASM_IF_ELSE(WASM_ZERO, // --
+ WASM_UNREACHABLE, // --
+ WASM_I8(27))); // --
CHECK_EQ(27, r.Call());
-}
-
-WASM_EXEC_TEST(IfElse_Unreachable2) {
- WasmRunner<int32_t> r(execution_mode);
- // 1 ? 28 : unreachable
- BUILD(r, WASM_IF_ELSE_I(WASM_I8(1), // --
- WASM_I8(28), // --
- WASM_UNREACHABLE)); // --
- CHECK_EQ(28, r.Call());
}
WASM_EXEC_TEST(Return12) {
@@ -755,7 +697,7 @@
WASM_EXEC_TEST(Return17) {
WasmRunner<int32_t> r(execution_mode);
- BUILD(r, WASM_BLOCK(RET_I8(17)));
+ BUILD(r, B1(RET_I8(17)));
CHECK_EQ(17, r.Call());
}
@@ -812,10 +754,10 @@
WASM_EXEC_TEST(Select_strict1) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
// select(a=0, a=1, a=2); return a
- BUILD(r, WASM_SELECT(WASM_TEE_LOCAL(0, WASM_I8(0)),
- WASM_TEE_LOCAL(0, WASM_I8(1)),
- WASM_TEE_LOCAL(0, WASM_I8(2))),
- WASM_DROP, WASM_GET_LOCAL(0));
+ BUILD(r, B2(WASM_SELECT(WASM_SET_LOCAL(0, WASM_I8(0)),
+ WASM_SET_LOCAL(0, WASM_I8(1)),
+ WASM_SET_LOCAL(0, WASM_I8(2))),
+ WASM_GET_LOCAL(0)));
FOR_INT32_INPUTS(i) { CHECK_EQ(2, r.Call(*i)); }
}
@@ -824,8 +766,8 @@
r.AllocateLocal(kAstI32);
r.AllocateLocal(kAstI32);
// select(b=5, c=6, a)
- BUILD(r, WASM_SELECT(WASM_TEE_LOCAL(1, WASM_I8(5)),
- WASM_TEE_LOCAL(2, WASM_I8(6)), WASM_GET_LOCAL(0)));
+ BUILD(r, WASM_SELECT(WASM_SET_LOCAL(1, WASM_I8(5)),
+ WASM_SET_LOCAL(2, WASM_I8(6)), WASM_GET_LOCAL(0)));
FOR_INT32_INPUTS(i) {
int32_t expected = *i ? 5 : 6;
CHECK_EQ(expected, r.Call(*i));
@@ -837,9 +779,9 @@
r.AllocateLocal(kAstI32);
r.AllocateLocal(kAstI32);
// select(b=5, c=6, a=b)
- BUILD(r, WASM_SELECT(WASM_TEE_LOCAL(1, WASM_I8(5)),
- WASM_TEE_LOCAL(2, WASM_I8(6)),
- WASM_TEE_LOCAL(0, WASM_GET_LOCAL(1))));
+ BUILD(r, WASM_SELECT(WASM_SET_LOCAL(1, WASM_I8(5)),
+ WASM_SET_LOCAL(2, WASM_I8(6)),
+ WASM_SET_LOCAL(0, WASM_GET_LOCAL(1))));
FOR_INT32_INPUTS(i) {
int32_t expected = 5;
CHECK_EQ(expected, r.Call(*i));
@@ -848,48 +790,36 @@
WASM_EXEC_TEST(BrIf_strict) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_BLOCK_I(WASM_BRV_IF(0, WASM_GET_LOCAL(0),
- WASM_TEE_LOCAL(0, WASM_I8(99)))));
-
- FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
-}
-
-WASM_EXEC_TEST(Br_height) {
- WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r,
- WASM_BLOCK_I(
- WASM_BLOCK_I(WASM_BRV_IFD(0, WASM_GET_LOCAL(0), WASM_GET_LOCAL(0)),
- WASM_RETURN1(WASM_I8(9)), WASM_I8(7), WASM_I8(7)),
- WASM_BRV(0, WASM_I8(8))));
-
- for (int32_t i = 0; i < 5; i++) {
- int32_t expected = i != 0 ? 8 : 9;
- CHECK_EQ(expected, r.Call(i));
- }
-}
-
-WASM_EXEC_TEST(BrTable0a) {
- WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, B1(B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 0, BR_TARGET(0)))),
- WASM_I8(91));
- FOR_INT32_INPUTS(i) { CHECK_EQ(91, r.Call(*i)); }
-}
-
-WASM_EXEC_TEST(BrTable0b) {
- WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r,
- B1(B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 1, BR_TARGET(0), BR_TARGET(0)))),
- WASM_I8(92));
- FOR_INT32_INPUTS(i) { CHECK_EQ(92, r.Call(*i)); }
-}
-
-WASM_EXEC_TEST(BrTable0c) {
- WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
BUILD(
r,
- B1(B2(B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 1, BR_TARGET(0), BR_TARGET(1))),
- RET_I8(76))),
- WASM_I8(77));
+ B2(B1(WASM_BRV_IF(0, WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_I8(99)))),
+ WASM_GET_LOCAL(0)));
+
+ FOR_INT32_INPUTS(i) { CHECK_EQ(99, r.Call(*i)); }
+}
+
+WASM_EXEC_TEST(BrTable0a) {
+ WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
+ BUILD(r,
+ B2(B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 0, BR_TARGET(0))), WASM_I8(91)));
+ FOR_INT32_INPUTS(i) { CHECK_EQ(91, r.Call(*i)); }
+}
+
+WASM_EXEC_TEST(BrTable0b) {
+ WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
+ BUILD(r,
+ B2(B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 1, BR_TARGET(0), BR_TARGET(0))),
+ WASM_I8(92)));
+ FOR_INT32_INPUTS(i) { CHECK_EQ(92, r.Call(*i)); }
+}
+
+WASM_EXEC_TEST(BrTable0c) {
+ WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
+ BUILD(
+ r,
+ B2(B2(B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 1, BR_TARGET(0), BR_TARGET(1))),
+ RET_I8(76)),
+ WASM_I8(77)));
FOR_INT32_INPUTS(i) {
int32_t expected = *i == 0 ? 76 : 77;
CHECK_EQ(expected, r.Call(*i));
@@ -904,10 +834,9 @@
WASM_EXEC_TEST(BrTable_loop) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r,
- B2(B1(WASM_LOOP(WASM_BR_TABLE(WASM_INC_LOCAL_BYV(0, 1), 2, BR_TARGET(2),
- BR_TARGET(1), BR_TARGET(0)))),
- RET_I8(99)),
+ BUILD(r, B2(WASM_LOOP(WASM_BR_TABLE(WASM_INC_LOCAL_BY(0, 1), 2, BR_TARGET(2),
+ BR_TARGET(1), BR_TARGET(0))),
+ RET_I8(99)),
WASM_I8(98));
CHECK_EQ(99, r.Call(0));
CHECK_EQ(98, r.Call(-1));
@@ -1052,9 +981,10 @@
int32_t* memory = module.AddMemoryElems<int32_t>(8);
WasmRunner<int32_t> r(&module, MachineType::Int32());
- BUILD(r, WASM_STORE_MEM(MachineType::Float32(), WASM_ZERO,
- WASM_F32_REINTERPRET_I32(WASM_GET_LOCAL(0))),
- WASM_I8(107));
+ BUILD(r,
+ WASM_BLOCK(WASM_STORE_MEM(MachineType::Float32(), WASM_ZERO,
+ WASM_F32_REINTERPRET_I32(WASM_GET_LOCAL(0))),
+ WASM_I8(107)));
FOR_INT32_INPUTS(i) {
int32_t expected = *i;
@@ -1063,14 +993,13 @@
}
}
-WASM_EXEC_TEST(LoadStoreLoad) {
+WASM_EXEC_TEST(ReturnStore) {
TestingModule module(execution_mode);
int32_t* memory = module.AddMemoryElems<int32_t>(8);
WasmRunner<int32_t> r(&module);
BUILD(r, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO,
- WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)),
- WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO));
+ WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)));
FOR_INT32_INPUTS(i) {
int32_t expected = *i;
@@ -1092,7 +1021,7 @@
const int32_t kExpected = -414444;
// Build the calling function.
WasmRunner<int32_t> r(&module);
- BUILD(r, WASM_CALL_FUNCTION0(index), WASM_I32V_3(kExpected));
+ BUILD(r, B2(WASM_CALL_FUNCTION0(index), WASM_I32V_3(kExpected)));
int32_t result = r.Call();
CHECK_EQ(kExpected, result);
@@ -1110,27 +1039,15 @@
const int32_t kExpected = -414444;
// Build the calling function.
WasmRunner<int32_t> r(&module);
- BUILD(r, B1(WASM_CALL_FUNCTION0(index)), WASM_I32V_3(kExpected));
+ BUILD(r, B2(WASM_CALL_FUNCTION0(index), WASM_I32V_3(kExpected)));
int32_t result = r.Call();
CHECK_EQ(kExpected, result);
}
-WASM_EXEC_TEST(BrEmpty) {
- WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_BRV(0, WASM_GET_LOCAL(0)));
- FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
-}
-
-WASM_EXEC_TEST(BrIfEmpty) {
- WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_BRV_IF(0, WASM_GET_LOCAL(0), WASM_GET_LOCAL(0)));
- FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
-}
-
WASM_EXEC_TEST(Block_empty) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, kExprBlock, kLocalVoid, kExprEnd, WASM_GET_LOCAL(0));
+ BUILD(r, kExprBlock, kExprEnd, WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
}
@@ -1142,45 +1059,27 @@
WASM_EXEC_TEST(Block_empty_brif1) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_BLOCK(WASM_BR_IF(0, WASM_ZERO)), WASM_GET_LOCAL(0));
+ BUILD(r, B1(WASM_BR_IF(0, WASM_ZERO)), WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
}
WASM_EXEC_TEST(Block_empty_brif2) {
WasmRunner<uint32_t> r(execution_mode, MachineType::Uint32(),
MachineType::Uint32());
- BUILD(r, WASM_BLOCK(WASM_BR_IF(0, WASM_GET_LOCAL(1))), WASM_GET_LOCAL(0));
+ BUILD(r, B1(WASM_BR_IF(0, WASM_GET_LOCAL(1))), WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i, *i + 1)); }
}
-WASM_EXEC_TEST(Block_i) {
- WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_BLOCK_I(WASM_GET_LOCAL(0)));
- FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
-}
-
-WASM_EXEC_TEST(Block_f) {
- WasmRunner<float> r(execution_mode, MachineType::Float32());
- BUILD(r, WASM_BLOCK_F(WASM_GET_LOCAL(0)));
- FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(*i, r.Call(*i)); }
-}
-
-WASM_EXEC_TEST(Block_d) {
- WasmRunner<double> r(execution_mode, MachineType::Float64());
- BUILD(r, WASM_BLOCK_D(WASM_GET_LOCAL(0)));
- FOR_FLOAT64_INPUTS(i) { CHECK_FLOAT_EQ(*i, r.Call(*i)); }
-}
-
WASM_EXEC_TEST(Block_br2) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0))));
+ BUILD(r, B1(WASM_BRV(0, WASM_GET_LOCAL(0))));
FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
}
WASM_EXEC_TEST(Block_If_P) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- // block { if (p0) break 51; 52; }
- BUILD(r, WASM_BLOCK_I( // --
+ // { if (p0) return 51; return 52; }
+ BUILD(r, B2( // --
WASM_IF(WASM_GET_LOCAL(0), // --
WASM_BRV(1, WASM_I8(51))), // --
WASM_I8(52))); // --
@@ -1192,64 +1091,32 @@
WASM_EXEC_TEST(Loop_empty) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, kExprLoop, kLocalVoid, kExprEnd, WASM_GET_LOCAL(0));
+ BUILD(r, kExprLoop, kExprEnd, WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
}
-WASM_EXEC_TEST(Loop_i) {
- WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_LOOP_I(WASM_GET_LOCAL(0)));
+WASM_EXEC_TEST(Loop_empty_br1) {
+ WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
+ BUILD(r, WASM_LOOP(WASM_BR(1)), WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
}
-WASM_EXEC_TEST(Loop_f) {
- WasmRunner<float> r(execution_mode, MachineType::Float32());
- BUILD(r, WASM_LOOP_F(WASM_GET_LOCAL(0)));
- FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(*i, r.Call(*i)); }
-}
-
-WASM_EXEC_TEST(Loop_d) {
- WasmRunner<double> r(execution_mode, MachineType::Float64());
- BUILD(r, WASM_LOOP_D(WASM_GET_LOCAL(0)));
- FOR_FLOAT64_INPUTS(i) { CHECK_FLOAT_EQ(*i, r.Call(*i)); }
-}
-
-WASM_EXEC_TEST(Loop_empty_br1) {
- WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, B1(WASM_LOOP(WASM_BR(1))), WASM_GET_LOCAL(0));
- FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
-}
-
WASM_EXEC_TEST(Loop_empty_brif1) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, B1(WASM_LOOP(WASM_BR_IF(1, WASM_ZERO))), WASM_GET_LOCAL(0));
+ BUILD(r, WASM_LOOP(WASM_BR_IF(1, WASM_ZERO)), WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
}
WASM_EXEC_TEST(Loop_empty_brif2) {
WasmRunner<uint32_t> r(execution_mode, MachineType::Uint32(),
MachineType::Uint32());
- BUILD(r, WASM_LOOP_I(WASM_BRV_IF(1, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))));
+ BUILD(r, WASM_LOOP(WASM_BR_IF(1, WASM_GET_LOCAL(1))), WASM_GET_LOCAL(0));
FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i, *i + 1)); }
}
-WASM_EXEC_TEST(Loop_empty_brif3) {
- WasmRunner<uint32_t> r(execution_mode, MachineType::Uint32(),
- MachineType::Uint32(), MachineType::Uint32());
- BUILD(r, WASM_LOOP(WASM_BRV_IFD(1, WASM_GET_LOCAL(2), WASM_GET_LOCAL(0))),
- WASM_GET_LOCAL(1));
- FOR_UINT32_INPUTS(i) {
- FOR_UINT32_INPUTS(j) {
- CHECK_EQ(*i, r.Call(0, *i, *j));
- CHECK_EQ(*j, r.Call(1, *i, *j));
- }
- }
-}
-
WASM_EXEC_TEST(Block_BrIf_P) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_BLOCK_I(WASM_BRV_IFD(0, WASM_I8(51), WASM_GET_LOCAL(0)),
- WASM_I8(52)));
+ BUILD(r, B2(WASM_BRV_IF(0, WASM_I8(51), WASM_GET_LOCAL(0)), WASM_I8(52)));
FOR_INT32_INPUTS(i) {
int32_t expected = *i ? 51 : 52;
CHECK_EQ(expected, r.Call(*i));
@@ -1259,11 +1126,11 @@
WASM_EXEC_TEST(Block_IfElse_P_assign) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
// { if (p0) p0 = 71; else p0 = 72; return p0; }
- BUILD(r, // --
- WASM_IF_ELSE(WASM_GET_LOCAL(0), // --
- WASM_SET_LOCAL(0, WASM_I8(71)), // --
- WASM_SET_LOCAL(0, WASM_I8(72))), // --
- WASM_GET_LOCAL(0));
+ BUILD(r, B2( // --
+ WASM_IF_ELSE(WASM_GET_LOCAL(0), // --
+ WASM_SET_LOCAL(0, WASM_I8(71)), // --
+ WASM_SET_LOCAL(0, WASM_I8(72))), // --
+ WASM_GET_LOCAL(0)));
FOR_INT32_INPUTS(i) {
int32_t expected = *i ? 71 : 72;
CHECK_EQ(expected, r.Call(*i));
@@ -1286,8 +1153,9 @@
WASM_EXEC_TEST(Block_If_P_assign) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
// { if (p0) p0 = 61; p0; }
- BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_I8(61))),
- WASM_GET_LOCAL(0));
+ BUILD(r,
+ WASM_BLOCK(WASM_IF(WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_I8(61))),
+ WASM_GET_LOCAL(0)));
FOR_INT32_INPUTS(i) {
int32_t expected = *i ? 61 : *i;
CHECK_EQ(expected, r.Call(*i));
@@ -1304,22 +1172,35 @@
WASM_EXEC_TEST(ExprIf_P) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
// p0 ? 11 : 22;
- BUILD(r, WASM_IF_ELSE_I(WASM_GET_LOCAL(0), // --
- WASM_I8(11), // --
- WASM_I8(22))); // --
+ BUILD(r, WASM_IF_ELSE(WASM_GET_LOCAL(0), // --
+ WASM_I8(11), // --
+ WASM_I8(22))); // --
FOR_INT32_INPUTS(i) {
int32_t expected = *i ? 11 : 22;
CHECK_EQ(expected, r.Call(*i));
}
}
+WASM_EXEC_TEST(ExprIf_P_fallthru) {
+ WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
+ // p0 ? 11 : 22;
+ BUILD(r, WASM_IF_ELSE(WASM_GET_LOCAL(0), // --
+ WASM_I8(11), // --
+ WASM_I8(22))); // --
+ FOR_INT32_INPUTS(i) {
+ int32_t expected = *i ? 11 : 22;
+ CHECK_EQ(expected, r.Call(*i));
+ }
+}
+
WASM_EXEC_TEST(CountDown) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_LOOP(WASM_IFB(
- WASM_GET_LOCAL(0),
- WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(1))),
- WASM_BR(1))),
- WASM_GET_LOCAL(0));
+ BUILD(r, WASM_BLOCK(
+ WASM_LOOP(WASM_IF(
+ WASM_GET_LOCAL(0),
+ WASM_BRV(1, WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0),
+ WASM_I8(1)))))),
+ WASM_GET_LOCAL(0)));
CHECK_EQ(0, r.Call(1));
CHECK_EQ(0, r.Call(10));
CHECK_EQ(0, r.Call(100));
@@ -1327,12 +1208,12 @@
WASM_EXEC_TEST(CountDown_fallthru) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_LOOP(
- WASM_IF(WASM_NOT(WASM_GET_LOCAL(0)),
- WASM_BRV(2, WASM_GET_LOCAL(0))),
- WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(1))),
- WASM_CONTINUE(0)),
- WASM_GET_LOCAL(0));
+ BUILD(r, WASM_BLOCK(
+ WASM_LOOP(WASM_IF(WASM_NOT(WASM_GET_LOCAL(0)), WASM_BREAK(1)),
+ WASM_SET_LOCAL(
+ 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(1))),
+ WASM_CONTINUE(0)),
+ WASM_GET_LOCAL(0)));
CHECK_EQ(0, r.Call(1));
CHECK_EQ(0, r.Call(10));
CHECK_EQ(0, r.Call(100));
@@ -1340,42 +1221,41 @@
WASM_EXEC_TEST(WhileCountDown) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_WHILE(
- WASM_GET_LOCAL(0),
- WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(1)))),
- WASM_GET_LOCAL(0));
+ BUILD(r,
+ WASM_BLOCK(WASM_WHILE(WASM_GET_LOCAL(0),
+ WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0),
+ WASM_I8(1)))),
+ WASM_GET_LOCAL(0)));
CHECK_EQ(0, r.Call(1));
CHECK_EQ(0, r.Call(10));
CHECK_EQ(0, r.Call(100));
}
WASM_EXEC_TEST(Loop_if_break1) {
- WasmRunner<int32_t> r(execution_mode, MachineType::Int32(),
- MachineType::Int32());
- BUILD(r, WASM_LOOP(WASM_IF(WASM_GET_LOCAL(0), WASM_BRV(2, WASM_GET_LOCAL(1))),
- WASM_SET_LOCAL(0, WASM_I8(99))),
- WASM_GET_LOCAL(0));
- CHECK_EQ(99, r.Call(0, 11));
- CHECK_EQ(65, r.Call(3, 65));
- CHECK_EQ(10001, r.Call(10000, 10001));
- CHECK_EQ(-29, r.Call(-28, -29));
+ WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
+ BUILD(r, B2(WASM_LOOP(WASM_IF(WASM_GET_LOCAL(0), WASM_BREAK(1)),
+ WASM_SET_LOCAL(0, WASM_I8(99))),
+ WASM_GET_LOCAL(0)));
+ CHECK_EQ(99, r.Call(0));
+ CHECK_EQ(3, r.Call(3));
+ CHECK_EQ(10000, r.Call(10000));
+ CHECK_EQ(-29, r.Call(-29));
}
WASM_EXEC_TEST(Loop_if_break2) {
- WasmRunner<int32_t> r(execution_mode, MachineType::Int32(),
- MachineType::Int32());
- BUILD(r, WASM_LOOP(WASM_BRV_IF(1, WASM_GET_LOCAL(1), WASM_GET_LOCAL(0)),
- WASM_DROP, WASM_SET_LOCAL(0, WASM_I8(99))),
- WASM_GET_LOCAL(0));
- CHECK_EQ(99, r.Call(0, 33));
- CHECK_EQ(3, r.Call(1, 3));
- CHECK_EQ(10000, r.Call(99, 10000));
- CHECK_EQ(-29, r.Call(-11, -29));
+ WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
+ BUILD(r, B2(WASM_LOOP(WASM_BR_IF(1, WASM_GET_LOCAL(0)),
+ WASM_SET_LOCAL(0, WASM_I8(99))),
+ WASM_GET_LOCAL(0)));
+ CHECK_EQ(99, r.Call(0));
+ CHECK_EQ(3, r.Call(3));
+ CHECK_EQ(10000, r.Call(10000));
+ CHECK_EQ(-29, r.Call(-29));
}
WASM_EXEC_TEST(Loop_if_break_fallthru) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, B1(WASM_LOOP(WASM_IF(WASM_GET_LOCAL(0), WASM_BR(2)),
+ BUILD(r, B1(WASM_LOOP(WASM_IF(WASM_GET_LOCAL(0), WASM_BREAK(1)),
WASM_SET_LOCAL(0, WASM_I8(93)))),
WASM_GET_LOCAL(0));
CHECK_EQ(93, r.Call(0));
@@ -1384,17 +1264,6 @@
CHECK_EQ(-22, r.Call(-22));
}
-WASM_EXEC_TEST(Loop_if_break_fallthru2) {
- WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, B1(B1(WASM_LOOP(WASM_IF(WASM_GET_LOCAL(0), WASM_BR(2)),
- WASM_SET_LOCAL(0, WASM_I8(93))))),
- WASM_GET_LOCAL(0));
- CHECK_EQ(93, r.Call(0));
- CHECK_EQ(3, r.Call(3));
- CHECK_EQ(10001, r.Call(10001));
- CHECK_EQ(-22, r.Call(-22));
-}
-
WASM_EXEC_TEST(IfBreak1) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_SEQ(WASM_BR(0), WASM_UNREACHABLE)),
@@ -1487,7 +1356,7 @@
uint32_t boundary = 24 - WasmOpcodes::MemSize(machineTypes[m]);
BUILD(r, WASM_LOAD_MEM_OFFSET(machineTypes[m], 8, WASM_GET_LOCAL(0)),
- WASM_DROP, WASM_ZERO);
+ WASM_ZERO);
CHECK_EQ(0, r.Call(boundary)); // in bounds.
@@ -1575,8 +1444,7 @@
for (byte i = 0; i <= 2; ++i) {
WasmRunner<int32_t> r(&module, MachineType::Int32());
BUILD(r, WASM_STORE_MEM_ALIGNMENT(MachineType::Int32(), WASM_ZERO, i,
- WASM_GET_LOCAL(0)),
- WASM_GET_LOCAL(0));
+ WASM_GET_LOCAL(0)));
module.RandomizeMemory(1111);
memory[0] = 0;
@@ -1592,8 +1460,7 @@
const int32_t kWritten = 0xaabbccdd;
BUILD(r, WASM_STORE_MEM_OFFSET(MachineType::Int32(), 4, WASM_GET_LOCAL(0),
- WASM_I32V_5(kWritten)),
- WASM_I32V_5(kWritten));
+ WASM_I32V_5(kWritten)));
for (int i = 0; i < 2; ++i) {
module.RandomizeMemory(1111);
@@ -1659,17 +1526,18 @@
WasmRunner<uint32_t> r(&module, MachineType::Int32());
const byte kSum = r.AllocateLocal(kAstI32);
- BUILD(
- r,
- WASM_WHILE(
- WASM_GET_LOCAL(0),
- WASM_BLOCK(
- WASM_SET_LOCAL(kSum,
- WASM_I32_ADD(WASM_GET_LOCAL(kSum),
- WASM_LOAD_MEM(MachineType::Int32(),
- WASM_GET_LOCAL(0)))),
- WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(4))))),
- WASM_GET_LOCAL(1));
+ BUILD(r,
+ WASM_BLOCK(
+ WASM_WHILE(
+ WASM_GET_LOCAL(0),
+ WASM_BLOCK(
+ WASM_SET_LOCAL(
+ kSum, WASM_I32_ADD(WASM_GET_LOCAL(kSum),
+ WASM_LOAD_MEM(MachineType::Int32(),
+ WASM_GET_LOCAL(0)))),
+ WASM_SET_LOCAL(
+ 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(4))))),
+ WASM_GET_LOCAL(1)));
// Run 4 trials.
for (int i = 0; i < 3; ++i) {
@@ -1689,24 +1557,10 @@
module.AddMemoryElems<uint32_t>(kNumElems);
WasmRunner<uint32_t> r(&module, MachineType::Int32());
- BUILD(r, // --
- /**/ kExprLoop, kLocalVoid, // --
- /* */ kExprGetLocal, 0, // --
- /* */ kExprIf, kLocalVoid, // --
- /* */ kExprGetLocal, 0, // --
- /* */ kExprI32LoadMem, 0, 0, // --
- /* */ kExprIf, kLocalVoid, // --
- /* */ kExprI8Const, 255, // --
- /* */ kExprReturn, // --
- /* */ kExprEnd, // --
- /* */ kExprGetLocal, 0, // --
- /* */ kExprI8Const, 4, // --
- /* */ kExprI32Sub, // --
- /* */ kExprTeeLocal, 0, // --
- /* */ kExprBr, DEPTH_0, // --
- /* */ kExprEnd, // --
- /**/ kExprEnd, // --
- /**/ kExprI8Const, 0); // --
+ BUILD(r, kExprLoop, kExprGetLocal, 0, kExprIf, kExprGetLocal, 0,
+ kExprI32LoadMem, 0, 0, kExprIf, kExprI8Const, 255, kExprReturn, ARITY_1,
+ kExprEnd, kExprGetLocal, 0, kExprI8Const, 4, kExprI32Sub, kExprSetLocal,
+ 0, kExprBr, ARITY_1, DEPTH_0, kExprEnd, kExprEnd, kExprI8Const, 0);
module.BlankMemory();
CHECK_EQ(0, r.Call((kNumElems - 1) * 4));
@@ -1725,18 +1579,20 @@
WasmRunner<int32_t> r(&module, MachineType::Int32());
const byte kSum = r.AllocateLocal(kAstF32);
- BUILD(
- r,
- WASM_WHILE(
- WASM_GET_LOCAL(0),
- WASM_BLOCK(
- WASM_SET_LOCAL(kSum,
- WASM_F32_ADD(WASM_GET_LOCAL(kSum),
- WASM_LOAD_MEM(MachineType::Float32(),
- WASM_GET_LOCAL(0)))),
- WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(4))))),
- WASM_STORE_MEM(MachineType::Float32(), WASM_ZERO, WASM_GET_LOCAL(kSum)),
- WASM_GET_LOCAL(0));
+ BUILD(r,
+ WASM_BLOCK(
+ WASM_WHILE(
+ WASM_GET_LOCAL(0),
+ WASM_BLOCK(
+ WASM_SET_LOCAL(
+ kSum, WASM_F32_ADD(WASM_GET_LOCAL(kSum),
+ WASM_LOAD_MEM(MachineType::Float32(),
+ WASM_GET_LOCAL(0)))),
+ WASM_SET_LOCAL(
+ 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(4))))),
+ WASM_STORE_MEM(MachineType::Float32(), WASM_ZERO,
+ WASM_GET_LOCAL(kSum)),
+ WASM_GET_LOCAL(0)));
CHECK_EQ(0, r.Call(4 * (kSize - 1)));
CHECK_NE(-99.25f, module.ReadMemory(&buffer[0]));
@@ -1755,17 +1611,19 @@
WasmRunner<int32_t> r(&module, MachineType::Int32());
const byte kAccum = r.AllocateLocal(astType);
- BUILD(r, WASM_SET_LOCAL(kAccum, WASM_LOAD_MEM(memType, WASM_ZERO)),
- WASM_WHILE(
- WASM_GET_LOCAL(0),
- WASM_BLOCK(WASM_SET_LOCAL(
+ BUILD(r, WASM_BLOCK(
+ WASM_SET_LOCAL(kAccum, WASM_LOAD_MEM(memType, WASM_ZERO)),
+ WASM_WHILE(
+ WASM_GET_LOCAL(0),
+ WASM_BLOCK(
+ WASM_SET_LOCAL(
kAccum, WASM_BINOP(binop, WASM_GET_LOCAL(kAccum),
WASM_LOAD_MEM(
memType, WASM_GET_LOCAL(0)))),
WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0),
WASM_I8(sizeof(T)))))),
- WASM_STORE_MEM(memType, WASM_ZERO, WASM_GET_LOCAL(kAccum)),
- WASM_GET_LOCAL(0));
+ WASM_STORE_MEM(memType, WASM_ZERO, WASM_GET_LOCAL(kAccum)),
+ WASM_GET_LOCAL(0)));
r.Call(static_cast<int>(sizeof(T) * (size - 1)));
return module.ReadMemory(&memory[0]);
}
@@ -1791,20 +1649,19 @@
WasmRunner<int32_t> r(&module, MachineType::Int32());
// Only build the graph and compile, don't run.
- BUILD(r, WASM_LOOP(WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO), WASM_DROP),
- WASM_ZERO);
+ BUILD(r, WASM_LOOP(WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)));
}
WASM_EXEC_TEST(Unreachable0a) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_BLOCK_I(WASM_BRV(0, WASM_I8(9)), RET(WASM_GET_LOCAL(0))));
+ BUILD(r, B2(WASM_BRV(0, WASM_I8(9)), RET(WASM_GET_LOCAL(0))));
CHECK_EQ(9, r.Call(0));
CHECK_EQ(9, r.Call(1));
}
WASM_EXEC_TEST(Unreachable0b) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_BLOCK_I(WASM_BRV(0, WASM_I8(7)), WASM_UNREACHABLE));
+ BUILD(r, B2(WASM_BRV(0, WASM_I8(7)), WASM_UNREACHABLE));
CHECK_EQ(7, r.Call(0));
CHECK_EQ(7, r.Call(1));
}
@@ -1837,32 +1694,31 @@
WASM_EXEC_TEST(Unreachable_Load) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0)),
- WASM_LOAD_MEM(MachineType::Int8(), WASM_GET_LOCAL(0))));
+ BUILD(r, B2(WASM_BRV(0, WASM_GET_LOCAL(0)),
+ WASM_LOAD_MEM(MachineType::Int8(), WASM_GET_LOCAL(0))));
CHECK_EQ(11, r.Call(11));
CHECK_EQ(21, r.Call(21));
}
WASM_EXEC_TEST(Infinite_Loop_not_taken1) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_INFINITE_LOOP), WASM_I8(45));
+ BUILD(r, B2(WASM_IF(WASM_GET_LOCAL(0), WASM_INFINITE_LOOP), WASM_I8(45)));
// Run the code, but don't go into the infinite loop.
CHECK_EQ(45, r.Call(0));
}
WASM_EXEC_TEST(Infinite_Loop_not_taken2) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r,
- WASM_BLOCK_I(WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_BRV(1, WASM_I8(45)),
- WASM_INFINITE_LOOP)));
+ BUILD(r, B1(WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_BRV(1, WASM_I8(45)),
+ WASM_INFINITE_LOOP)));
// Run the code, but don't go into the infinite loop.
CHECK_EQ(45, r.Call(1));
}
WASM_EXEC_TEST(Infinite_Loop_not_taken2_brif) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_BLOCK_I(WASM_BRV_IF(0, WASM_I8(45), WASM_GET_LOCAL(0)),
- WASM_INFINITE_LOOP));
+ BUILD(r,
+ B2(WASM_BRV_IF(0, WASM_I8(45), WASM_GET_LOCAL(0)), WASM_INFINITE_LOOP));
// Run the code, but don't go into the infinite loop.
CHECK_EQ(45, r.Call(1));
}
@@ -1965,9 +1821,8 @@
int32_t* global = module.AddGlobal<int32_t>(kAstI32);
WasmRunner<int32_t> r(&module, MachineType::Int32());
// global = global + p0
- BUILD(r,
- WASM_SET_GLOBAL(0, WASM_I32_ADD(WASM_GET_GLOBAL(0), WASM_GET_LOCAL(0))),
- WASM_ZERO);
+ BUILD(r, WASM_SET_GLOBAL(
+ 0, WASM_I32_ADD(WASM_GET_GLOBAL(0), WASM_GET_LOCAL(0))));
*global = 116;
for (int i = 9; i < 444444; i += 111111) {
@@ -1988,8 +1843,7 @@
// global = global + p0
WasmRunner<int32_t> r(&module, MachineType::Int32());
BUILD(r, WASM_SET_GLOBAL(
- g, WASM_I32_ADD(WASM_GET_GLOBAL(g), WASM_GET_LOCAL(0))),
- WASM_GET_GLOBAL(g));
+ g, WASM_I32_ADD(WASM_GET_GLOBAL(g), WASM_GET_LOCAL(0))));
// Check that reading/writing global number {g} doesn't alter the others.
*globals[g] = 116 * g;
@@ -1997,8 +1851,7 @@
for (int i = 9; i < 444444; i += 111113) {
int32_t sum = *globals[g] + i;
for (int j = 0; j < kNumGlobals; ++j) before[j] = *globals[j];
- int32_t result = r.Call(i);
- CHECK_EQ(sum, result);
+ r.Call(i);
for (int j = 0; j < kNumGlobals; ++j) {
int32_t expected = j == g ? sum : before[j];
CHECK_EQ(expected, *globals[j]);
@@ -2012,10 +1865,10 @@
float* global = module.AddGlobal<float>(kAstF32);
WasmRunner<int32_t> r(&module, MachineType::Int32());
// global = global + p0
- BUILD(r, WASM_SET_GLOBAL(
- 0, WASM_F32_ADD(WASM_GET_GLOBAL(0),
- WASM_F32_SCONVERT_I32(WASM_GET_LOCAL(0)))),
- WASM_ZERO);
+ BUILD(r, B2(WASM_SET_GLOBAL(
+ 0, WASM_F32_ADD(WASM_GET_GLOBAL(0),
+ WASM_F32_SCONVERT_I32(WASM_GET_LOCAL(0)))),
+ WASM_ZERO));
*global = 1.25;
for (int i = 9; i < 4444; i += 1111) {
@@ -2030,10 +1883,10 @@
double* global = module.AddGlobal<double>(kAstF64);
WasmRunner<int32_t> r(&module, MachineType::Int32());
// global = global + p0
- BUILD(r, WASM_SET_GLOBAL(
- 0, WASM_F64_ADD(WASM_GET_GLOBAL(0),
- WASM_F64_SCONVERT_I32(WASM_GET_LOCAL(0)))),
- WASM_ZERO);
+ BUILD(r, B2(WASM_SET_GLOBAL(
+ 0, WASM_F64_ADD(WASM_GET_GLOBAL(0),
+ WASM_F64_SCONVERT_I32(WASM_GET_LOCAL(0)))),
+ WASM_ZERO));
*global = 1.25;
for (int i = 9; i < 4444; i += 1111) {
@@ -2055,11 +1908,14 @@
WasmRunner<int32_t> r(&module, MachineType::Int32());
- BUILD(r, WASM_SET_GLOBAL(1, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)),
- WASM_SET_GLOBAL(2, WASM_LOAD_MEM(MachineType::Uint32(), WASM_ZERO)),
- WASM_SET_GLOBAL(3, WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO)),
- WASM_SET_GLOBAL(4, WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO)),
- WASM_ZERO);
+ BUILD(
+ r,
+ WASM_BLOCK(
+ WASM_SET_GLOBAL(1, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)),
+ WASM_SET_GLOBAL(2, WASM_LOAD_MEM(MachineType::Uint32(), WASM_ZERO)),
+ WASM_SET_GLOBAL(3, WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO)),
+ WASM_SET_GLOBAL(4, WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO)),
+ WASM_ZERO));
memory[0] = 0xaa;
memory[1] = 0xcc;
@@ -2108,8 +1964,8 @@
// Build the calling function.
WasmRunner<float> r(&module);
- BUILD(r, WASM_CALL_FUNCTION(
- index, WASM_F32(1.0f), WASM_F32(2.0f), WASM_F32(4.0f),
+ BUILD(r, WASM_CALL_FUNCTIONN(
+ 19, index, WASM_F32(1.0f), WASM_F32(2.0f), WASM_F32(4.0f),
WASM_F32(8.0f), WASM_F32(16.0f), WASM_F32(32.0f),
WASM_F32(64.0f), WASM_F32(128.0f), WASM_F32(256.0f),
WASM_F32(1.5f), WASM_F32(2.5f), WASM_F32(4.5f), WASM_F32(8.5f),
@@ -2132,13 +1988,13 @@
// Build the calling function.
WasmRunner<double> r(&module);
- BUILD(r, WASM_CALL_FUNCTION(index, WASM_F64(1.0), WASM_F64(2.0),
- WASM_F64(4.0), WASM_F64(8.0), WASM_F64(16.0),
- WASM_F64(32.0), WASM_F64(64.0), WASM_F64(128.0),
- WASM_F64(256.0), WASM_F64(1.5), WASM_F64(2.5),
- WASM_F64(4.5), WASM_F64(8.5), WASM_F64(16.5),
- WASM_F64(32.5), WASM_F64(64.5), WASM_F64(128.5),
- WASM_F64(256.5), WASM_F64(512.5)));
+ BUILD(r, WASM_CALL_FUNCTIONN(19, index, WASM_F64(1.0), WASM_F64(2.0),
+ WASM_F64(4.0), WASM_F64(8.0), WASM_F64(16.0),
+ WASM_F64(32.0), WASM_F64(64.0), WASM_F64(128.0),
+ WASM_F64(256.0), WASM_F64(1.5), WASM_F64(2.5),
+ WASM_F64(4.5), WASM_F64(8.5), WASM_F64(16.5),
+ WASM_F64(32.5), WASM_F64(64.5), WASM_F64(128.5),
+ WASM_F64(256.5), WASM_F64(512.5)));
float result = r.Call();
CHECK_EQ(256.5, result);
@@ -2179,7 +2035,7 @@
// Build the caller function.
WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32());
- BUILD(r, WASM_CALL_FUNCTION(index, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
+ BUILD(r, WASM_CALL_FUNCTION2(index, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) {
@@ -2201,7 +2057,7 @@
// Builder the caller function.
WasmRunner<float> r(&module, MachineType::Float32(), MachineType::Float32());
- BUILD(r, WASM_CALL_FUNCTION(index, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
+ BUILD(r, WASM_CALL_FUNCTION2(index, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_FLOAT32_INPUTS(i) {
FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i - *j, r.Call(*i, *j)); }
@@ -2213,11 +2069,13 @@
double* memory = module.AddMemoryElems<double>(16);
WasmRunner<int32_t> r(&module);
- BUILD(r, WASM_STORE_MEM(
- MachineType::Float64(), WASM_ZERO,
- WASM_F64_SUB(WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO),
- WASM_LOAD_MEM(MachineType::Float64(), WASM_I8(8)))),
- WASM_I8(107));
+ BUILD(r,
+ WASM_BLOCK(WASM_STORE_MEM(
+ MachineType::Float64(), WASM_ZERO,
+ WASM_F64_SUB(
+ WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO),
+ WASM_LOAD_MEM(MachineType::Float64(), WASM_I8(8)))),
+ WASM_I8(107)));
FOR_FLOAT64_INPUTS(i) {
FOR_FLOAT64_INPUTS(j) {
@@ -2291,7 +2149,8 @@
}
// Call the selector function.
- ADD_CODE(code, kExprCallFunction, static_cast<byte>(index));
+ ADD_CODE(code, kExprCallFunction, static_cast<byte>(num_params),
+ static_cast<byte>(index));
// Store the result in memory.
ADD_CODE(code,
@@ -2333,149 +2192,71 @@
WasmRunner<int32_t> r(&module, MachineType::Int32());
byte local = r.AllocateLocal(kAstI32);
- BUILD(r, WASM_SET_LOCAL(local, WASM_I8(99)),
- WASM_I32_ADD(WASM_CALL_FUNCTION(t1.function_index(), WASM_GET_LOCAL(0),
- WASM_GET_LOCAL(0)),
- WASM_CALL_FUNCTION(t1.function_index(), WASM_GET_LOCAL(1),
- WASM_GET_LOCAL(local))));
+ BUILD(r, B2(WASM_SET_LOCAL(local, WASM_I8(99)),
+ WASM_I32_ADD(
+ WASM_CALL_FUNCTION2(t1.function_index(), WASM_GET_LOCAL(0),
+ WASM_GET_LOCAL(0)),
+ WASM_CALL_FUNCTION2(t1.function_index(), WASM_GET_LOCAL(1),
+ WASM_GET_LOCAL(local)))));
CHECK_EQ(198, r.Call(0));
CHECK_EQ(200, r.Call(1));
CHECK_EQ(100, r.Call(-49));
}
-WASM_EXEC_TEST(MultiReturnSub) {
- FLAG_wasm_mv_prototype = true;
- LocalType storage[] = {kAstI32, kAstI32, kAstI32, kAstI32};
- FunctionSig sig_ii_ii(2, 2, storage);
- TestingModule module(execution_mode);
- WasmFunctionCompiler t1(&sig_ii_ii, &module);
- BUILD(t1, WASM_GET_LOCAL(1), WASM_GET_LOCAL(0));
- t1.CompileAndAdd();
-
- WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32());
- BUILD(r, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1), kExprCallFunction, 0,
- kExprI32Sub);
-
- FOR_INT32_INPUTS(i) {
- FOR_INT32_INPUTS(j) {
- int32_t expected = static_cast<int32_t>(static_cast<uint32_t>(*j) -
- static_cast<uint32_t>(*i));
- CHECK_EQ(expected, r.Call(*i, *j));
- }
- }
-}
-
-template <typename T>
-void RunMultiReturnSelect(WasmExecutionMode execution_mode, LocalType type,
- const T* inputs) {
- FLAG_wasm_mv_prototype = true;
- LocalType storage[] = {type, type, type, type, type, type};
- const size_t kNumReturns = 2;
- const size_t kNumParams = arraysize(storage) - kNumReturns;
- FunctionSig sig(kNumReturns, kNumParams, storage);
-
- for (size_t i = 0; i < kNumParams; i++) {
- for (size_t j = 0; j < kNumParams; j++) {
- for (int k = 0; k < 2; k++) {
- TestingModule module(execution_mode);
- WasmFunctionCompiler r1(&sig, &module);
-
- BUILD(r1, WASM_GET_LOCAL(i), WASM_GET_LOCAL(j));
- r1.CompileAndAdd();
-
- MachineType machine_type = WasmOpcodes::MachineTypeFor(type);
- WasmRunner<T> r2(&module, machine_type, machine_type, machine_type,
- machine_type);
-
- if (k == 0) {
- BUILD(r2, WASM_CALL_FUNCTION(r1.function_index(), WASM_GET_LOCAL(0),
- WASM_GET_LOCAL(1), WASM_GET_LOCAL(2),
- WASM_GET_LOCAL(3)),
- WASM_DROP);
- } else {
- BUILD(r2, WASM_CALL_FUNCTION(r1.function_index(), WASM_GET_LOCAL(0),
- WASM_GET_LOCAL(1), WASM_GET_LOCAL(2),
- WASM_GET_LOCAL(3)),
- kExprSetLocal, 0, WASM_DROP, WASM_GET_LOCAL(0));
- }
-
- T expected = inputs[k == 0 ? i : j];
- CHECK_EQ(expected, r2.Call(inputs[0], inputs[1], inputs[2], inputs[3]));
- }
- }
- }
-}
-
-WASM_EXEC_TEST(MultiReturnSelect_i32) {
- static const int32_t inputs[] = {3333333, 4444444, -55555555, -7777777};
- RunMultiReturnSelect<int32_t>(execution_mode, kAstI32, inputs);
-}
-
-WASM_EXEC_TEST(MultiReturnSelect_f32) {
- static const float inputs[] = {33.33333f, 444.4444f, -55555.555f, -77777.77f};
- RunMultiReturnSelect<float>(execution_mode, kAstF32, inputs);
-}
-
-WASM_EXEC_TEST(MultiReturnSelect_i64) {
-#if !V8_TARGET_ARCH_32_BIT || V8_TARGET_ARCH_X64
- // TODO(titzer): implement int64-lowering for multiple return values
- static const int64_t inputs[] = {33333338888, 44444446666, -555555553333,
- -77777771111};
- RunMultiReturnSelect<int64_t>(execution_mode, kAstI64, inputs);
-#endif
-}
-
-WASM_EXEC_TEST(MultiReturnSelect_f64) {
- static const double inputs[] = {3.333333, 44444.44, -55.555555, -7777.777};
- RunMultiReturnSelect<double>(execution_mode, kAstF64, inputs);
+WASM_EXEC_TEST(CountDown_expr) {
+ WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
+ BUILD(r, WASM_LOOP(
+ WASM_IF(WASM_NOT(WASM_GET_LOCAL(0)),
+ WASM_BREAKV(1, WASM_GET_LOCAL(0))),
+ WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(1))),
+ WASM_CONTINUE(0)));
+ CHECK_EQ(0, r.Call(1));
+ CHECK_EQ(0, r.Call(10));
+ CHECK_EQ(0, r.Call(100));
}
WASM_EXEC_TEST(ExprBlock2a) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_BLOCK_I(WASM_IF(WASM_GET_LOCAL(0), WASM_BRV(1, WASM_I8(1))),
- WASM_I8(1)));
+ BUILD(r, B2(WASM_IF(WASM_GET_LOCAL(0), WASM_BRV(1, WASM_I8(1))), WASM_I8(1)));
CHECK_EQ(1, r.Call(0));
CHECK_EQ(1, r.Call(1));
}
WASM_EXEC_TEST(ExprBlock2b) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_BLOCK_I(WASM_IF(WASM_GET_LOCAL(0), WASM_BRV(1, WASM_I8(1))),
- WASM_I8(2)));
+ BUILD(r, B2(WASM_IF(WASM_GET_LOCAL(0), WASM_BRV(1, WASM_I8(1))), WASM_I8(2)));
CHECK_EQ(2, r.Call(0));
CHECK_EQ(1, r.Call(1));
}
WASM_EXEC_TEST(ExprBlock2c) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_BLOCK_I(WASM_BRV_IFD(0, WASM_I8(1), WASM_GET_LOCAL(0)),
- WASM_I8(1)));
+ BUILD(r, B2(WASM_BRV_IF(0, WASM_I8(1), WASM_GET_LOCAL(0)), WASM_I8(1)));
CHECK_EQ(1, r.Call(0));
CHECK_EQ(1, r.Call(1));
}
WASM_EXEC_TEST(ExprBlock2d) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_BLOCK_I(WASM_BRV_IFD(0, WASM_I8(1), WASM_GET_LOCAL(0)),
- WASM_I8(2)));
+ BUILD(r, B2(WASM_BRV_IF(0, WASM_I8(1), WASM_GET_LOCAL(0)), WASM_I8(2)));
CHECK_EQ(2, r.Call(0));
CHECK_EQ(1, r.Call(1));
}
WASM_EXEC_TEST(ExprBlock_ManualSwitch) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r, WASM_BLOCK_I(WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(1)),
- WASM_BRV(1, WASM_I8(11))),
- WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(2)),
- WASM_BRV(1, WASM_I8(12))),
- WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(3)),
- WASM_BRV(1, WASM_I8(13))),
- WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(4)),
- WASM_BRV(1, WASM_I8(14))),
- WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(5)),
- WASM_BRV(1, WASM_I8(15))),
- WASM_I8(99)));
+ BUILD(r, WASM_BLOCK(WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(1)),
+ WASM_BRV(1, WASM_I8(11))),
+ WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(2)),
+ WASM_BRV(1, WASM_I8(12))),
+ WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(3)),
+ WASM_BRV(1, WASM_I8(13))),
+ WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(4)),
+ WASM_BRV(1, WASM_I8(14))),
+ WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(5)),
+ WASM_BRV(1, WASM_I8(15))),
+ WASM_I8(99)));
CHECK_EQ(99, r.Call(0));
CHECK_EQ(11, r.Call(1));
CHECK_EQ(12, r.Call(2));
@@ -2487,18 +2268,17 @@
WASM_EXEC_TEST(ExprBlock_ManualSwitch_brif) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r,
- WASM_BLOCK_I(WASM_BRV_IFD(0, WASM_I8(11),
+ BUILD(r, WASM_BLOCK(WASM_BRV_IF(0, WASM_I8(11),
WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(1))),
- WASM_BRV_IFD(0, WASM_I8(12),
+ WASM_BRV_IF(0, WASM_I8(12),
WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(2))),
- WASM_BRV_IFD(0, WASM_I8(13),
+ WASM_BRV_IF(0, WASM_I8(13),
WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(3))),
- WASM_BRV_IFD(0, WASM_I8(14),
+ WASM_BRV_IF(0, WASM_I8(14),
WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(4))),
- WASM_BRV_IFD(0, WASM_I8(15),
+ WASM_BRV_IF(0, WASM_I8(15),
WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(5))),
- WASM_I8(99)));
+ WASM_I8(99)));
CHECK_EQ(99, r.Call(0));
CHECK_EQ(11, r.Call(1));
CHECK_EQ(12, r.Call(2));
@@ -2508,14 +2288,14 @@
CHECK_EQ(99, r.Call(6));
}
-WASM_EXEC_TEST(If_nested) {
+WASM_EXEC_TEST(nested_ifs) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32(),
MachineType::Int32());
- BUILD(r, WASM_IF_ELSE_I(
+ BUILD(r, WASM_IF_ELSE(
WASM_GET_LOCAL(0),
- WASM_IF_ELSE_I(WASM_GET_LOCAL(1), WASM_I8(11), WASM_I8(12)),
- WASM_IF_ELSE_I(WASM_GET_LOCAL(1), WASM_I8(13), WASM_I8(14))));
+ WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_I8(11), WASM_I8(12)),
+ WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_I8(13), WASM_I8(14))));
CHECK_EQ(11, r.Call(1, 1));
CHECK_EQ(12, r.Call(1, 0));
@@ -2526,9 +2306,8 @@
WASM_EXEC_TEST(ExprBlock_if) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
- BUILD(r,
- WASM_BLOCK_I(WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_BRV(0, WASM_I8(11)),
- WASM_BRV(1, WASM_I8(14)))));
+ BUILD(r, B1(WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_BRV(0, WASM_I8(11)),
+ WASM_BRV(1, WASM_I8(14)))));
CHECK_EQ(11, r.Call(1));
CHECK_EQ(14, r.Call(0));
@@ -2538,12 +2317,29 @@
WasmRunner<int32_t> r(execution_mode, MachineType::Int32(),
MachineType::Int32());
- BUILD(r, WASM_BLOCK_I(WASM_IF_ELSE_I(
+ BUILD(r, WASM_BLOCK(WASM_IF_ELSE(
WASM_GET_LOCAL(0),
- WASM_IF_ELSE_I(WASM_GET_LOCAL(1), WASM_BRV(0, WASM_I8(11)),
- WASM_BRV(1, WASM_I8(12))),
- WASM_IF_ELSE_I(WASM_GET_LOCAL(1), WASM_BRV(0, WASM_I8(13)),
- WASM_BRV(1, WASM_I8(14))))));
+ WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(0, WASM_I8(11)),
+ WASM_BRV(1, WASM_I8(12))),
+ WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(0, WASM_I8(13)),
+ WASM_BRV(1, WASM_I8(14))))));
+
+ CHECK_EQ(11, r.Call(1, 1));
+ CHECK_EQ(12, r.Call(1, 0));
+ CHECK_EQ(13, r.Call(0, 1));
+ CHECK_EQ(14, r.Call(0, 0));
+}
+
+WASM_EXEC_TEST(ExprLoop_nested_ifs) {
+ WasmRunner<int32_t> r(execution_mode, MachineType::Int32(),
+ MachineType::Int32());
+
+ BUILD(r, WASM_LOOP(WASM_IF_ELSE(
+ WASM_GET_LOCAL(0),
+ WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(1, WASM_I8(11)),
+ WASM_BRV(3, WASM_I8(12))),
+ WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(1, WASM_I8(13)),
+ WASM_BRV(3, WASM_I8(14))))));
CHECK_EQ(11, r.Call(1, 1));
CHECK_EQ(12, r.Call(1, 0));
@@ -2858,11 +2654,11 @@
WasmFunctionCompiler t(sig, &module);
std::vector<byte> code;
+ ADD_CODE(code, kExprI8Const, 0);
for (byte p = 0; p < num_params; ++p) {
ADD_CODE(code, kExprGetLocal, p);
}
- ADD_CODE(code, kExprI8Const, 0);
- ADD_CODE(code, kExprCallIndirect, 1);
+ ADD_CODE(code, kExprCallIndirect, static_cast<byte>(num_params), 1);
t.Build(&code[0], &code[0] + code.size());
t.Compile();
@@ -2878,8 +2674,7 @@
WASM_EXEC_TEST(Int32RemS_dead) {
WasmRunner<int32_t> r(execution_mode, MachineType::Int32(),
MachineType::Int32());
- BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_DROP,
- WASM_ZERO);
+ BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_ZERO);
const int32_t kMin = std::numeric_limits<int32_t>::min();
CHECK_EQ(0, r.Call(133, 100));
CHECK_EQ(0, r.Call(kMin, -1));
« no previous file with comments | « src/wasm/wasm-result.h ('k') | test/cctest/wasm/test-run-wasm-64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698