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 9891cb631f8f8e2406acf0c0412dd14c90a23f32..911d490e38ef38f8f5ee4551a64917431f0fb452 100644 |
--- a/test/cctest/wasm/test-run-wasm.cc |
+++ b/test/cctest/wasm/test-run-wasm.cc |
@@ -874,10 +874,9 @@ WASM_EXEC_TEST(BrTable1) { |
WASM_EXEC_TEST(BrTable_loop) { |
WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); |
- BUILD(r, |
- B2(WASM_LOOP(1, WASM_BR_TABLE(WASM_INC_LOCAL_BY(0, 1), 2, BR_TARGET(2), |
+ 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)), |
+ RET_I8(99)), |
WASM_I8(98)); |
CHECK_EQ(99, r.Call(0)); |
CHECK_EQ(98, r.Call(-1)); |
@@ -1022,10 +1021,10 @@ WASM_EXEC_TEST(I32ReinterpretF32) { |
int32_t* memory = module.AddMemoryElems<int32_t>(8); |
WasmRunner<int32_t> r(&module, MachineType::Int32()); |
- BUILD(r, WASM_BLOCK( |
- 2, 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; |
@@ -1138,20 +1137,20 @@ WASM_EXEC_TEST(Loop_empty) { |
WASM_EXEC_TEST(Loop_empty_br1) { |
WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); |
- BUILD(r, WASM_LOOP(1, WASM_BR(1)), WASM_GET_LOCAL(0)); |
+ 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_empty_brif1) { |
WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); |
- BUILD(r, WASM_LOOP(1, 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(1, WASM_BR_IF(1, WASM_GET_LOCAL(1))), WASM_GET_LOCAL(0)); |
+ 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)); } |
} |
@@ -1194,9 +1193,9 @@ WASM_EXEC_TEST(Block_IfElse_P_return) { |
WASM_EXEC_TEST(Block_If_P_assign) { |
WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); |
// { if (p0) p0 = 61; p0; } |
- BUILD(r, WASM_BLOCK( |
- 2, 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)); |
@@ -1236,14 +1235,12 @@ WASM_EXEC_TEST(ExprIf_P_fallthru) { |
WASM_EXEC_TEST(CountDown) { |
WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); |
- BUILD(r, |
- WASM_BLOCK( |
- 2, WASM_LOOP( |
- 1, WASM_IF(WASM_GET_LOCAL(0), |
- WASM_BRV(1, WASM_SET_LOCAL( |
- 0, WASM_I32_SUB(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))); |
+ WASM_GET_LOCAL(0))); |
CHECK_EQ(0, r.Call(1)); |
CHECK_EQ(0, r.Call(10)); |
CHECK_EQ(0, r.Call(100)); |
@@ -1251,13 +1248,12 @@ WASM_EXEC_TEST(CountDown) { |
WASM_EXEC_TEST(CountDown_fallthru) { |
WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); |
- BUILD(r, |
- WASM_BLOCK( |
- 2, WASM_LOOP(3, WASM_IF(WASM_NOT(WASM_GET_LOCAL(0)), WASM_BREAK(1)), |
+ 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))); |
+ WASM_GET_LOCAL(0))); |
CHECK_EQ(0, r.Call(1)); |
CHECK_EQ(0, r.Call(10)); |
CHECK_EQ(0, r.Call(100)); |
@@ -1265,11 +1261,11 @@ WASM_EXEC_TEST(CountDown_fallthru) { |
WASM_EXEC_TEST(WhileCountDown) { |
WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); |
- BUILD(r, WASM_BLOCK( |
- 2, 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)); |
@@ -1277,7 +1273,7 @@ WASM_EXEC_TEST(WhileCountDown) { |
WASM_EXEC_TEST(Loop_if_break1) { |
WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); |
- BUILD(r, B2(WASM_LOOP(2, WASM_IF(WASM_GET_LOCAL(0), WASM_BREAK(1)), |
+ 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)); |
@@ -1288,7 +1284,7 @@ WASM_EXEC_TEST(Loop_if_break1) { |
WASM_EXEC_TEST(Loop_if_break2) { |
WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); |
- BUILD(r, B2(WASM_LOOP(2, WASM_BR_IF(1, WASM_GET_LOCAL(0)), |
+ 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)); |
@@ -1299,7 +1295,7 @@ WASM_EXEC_TEST(Loop_if_break2) { |
WASM_EXEC_TEST(Loop_if_break_fallthru) { |
WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); |
- BUILD(r, B1(WASM_LOOP(2, WASM_IF(WASM_GET_LOCAL(0), WASM_BREAK(1)), |
+ 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)); |
@@ -1570,18 +1566,18 @@ WASM_EXEC_TEST(MemI32_Sum) { |
WasmRunner<uint32_t> r(&module, MachineType::Int32()); |
const byte kSum = r.AllocateLocal(kAstI32); |
- BUILD(r, WASM_BLOCK( |
- 2, WASM_WHILE( |
- WASM_GET_LOCAL(0), |
- WASM_BLOCK( |
- 2, WASM_SET_LOCAL( |
- kSum, WASM_I32_ADD( |
- WASM_GET_LOCAL(kSum), |
+ 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))); |
+ 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) { |
@@ -1623,20 +1619,20 @@ WASM_EXEC_TEST(MemF32_Sum) { |
WasmRunner<int32_t> r(&module, MachineType::Int32()); |
const byte kSum = r.AllocateLocal(kAstF32); |
- BUILD(r, WASM_BLOCK( |
- 3, WASM_WHILE( |
- WASM_GET_LOCAL(0), |
- WASM_BLOCK( |
- 2, WASM_SET_LOCAL( |
- kSum, WASM_F32_ADD( |
- WASM_GET_LOCAL(kSum), |
+ 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))); |
+ 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])); |
@@ -1655,21 +1651,19 @@ T GenerateAndRunFold(WasmExecutionMode execution_mode, WasmOpcode binop, |
WasmRunner<int32_t> r(&module, MachineType::Int32()); |
const byte kAccum = r.AllocateLocal(astType); |
- BUILD( |
- r, |
- WASM_BLOCK( |
- 4, WASM_SET_LOCAL(kAccum, WASM_LOAD_MEM(memType, WASM_ZERO)), |
- WASM_WHILE( |
- WASM_GET_LOCAL(0), |
- WASM_BLOCK( |
- 2, 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))); |
+ 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))); |
r.Call(static_cast<int>(sizeof(T) * (size - 1))); |
return module.ReadMemory(&memory[0]); |
} |
@@ -1695,7 +1689,7 @@ WASM_EXEC_TEST(Build_Wasm_Infinite_Loop_effect) { |
WasmRunner<int32_t> r(&module, MachineType::Int32()); |
// Only build the graph and compile, don't run. |
- BUILD(r, WASM_LOOP(1, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO))); |
+ BUILD(r, WASM_LOOP(WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO))); |
} |
WASM_EXEC_TEST(Unreachable0a) { |
@@ -1961,7 +1955,6 @@ WASM_EXEC_TEST(MixedGlobals) { |
BUILD( |
r, |
WASM_BLOCK( |
- 9, |
WASM_STORE_GLOBAL(1, WASM_LOAD_MEM(MachineType::Int8(), WASM_ZERO)), |
WASM_STORE_GLOBAL(2, WASM_LOAD_MEM(MachineType::Uint8(), WASM_ZERO)), |
WASM_STORE_GLOBAL(3, WASM_LOAD_MEM(MachineType::Int16(), WASM_ZERO)), |
@@ -2130,13 +2123,13 @@ WASM_EXEC_TEST(Call_Float64Sub) { |
double* memory = module.AddMemoryElems<double>(16); |
WasmRunner<int32_t> r(&module); |
- BUILD(r, WASM_BLOCK( |
- 2, 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) { |
@@ -2268,8 +2261,8 @@ WASM_EXEC_TEST(AddCall) { |
WASM_EXEC_TEST(CountDown_expr) { |
WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); |
BUILD(r, WASM_LOOP( |
- 3, WASM_IF(WASM_NOT(WASM_GET_LOCAL(0)), |
- WASM_BREAKV(1, WASM_GET_LOCAL(0))), |
+ 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)); |
@@ -2307,8 +2300,8 @@ WASM_EXEC_TEST(ExprBlock2d) { |
WASM_EXEC_TEST(ExprBlock_ManualSwitch) { |
WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); |
- BUILD(r, WASM_BLOCK(6, WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(1)), |
- WASM_BRV(1, WASM_I8(11))), |
+ 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)), |
@@ -2329,18 +2322,17 @@ WASM_EXEC_TEST(ExprBlock_ManualSwitch) { |
WASM_EXEC_TEST(ExprBlock_ManualSwitch_brif) { |
WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); |
- BUILD(r, |
- WASM_BLOCK(6, WASM_BRV_IF(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_IF(0, WASM_I8(12), |
- WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(2))), |
- WASM_BRV_IF(0, WASM_I8(13), |
- WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(3))), |
- WASM_BRV_IF(0, WASM_I8(14), |
- WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(4))), |
- WASM_BRV_IF(0, WASM_I8(15), |
- WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(5))), |
- WASM_I8(99))); |
+ WASM_BRV_IF(0, WASM_I8(12), |
+ WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(2))), |
+ WASM_BRV_IF(0, WASM_I8(13), |
+ WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(3))), |
+ WASM_BRV_IF(0, WASM_I8(14), |
+ WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(4))), |
+ WASM_BRV_IF(0, WASM_I8(15), |
+ WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(5))), |
+ WASM_I8(99))); |
CHECK_EQ(99, r.Call(0)); |
CHECK_EQ(11, r.Call(1)); |
CHECK_EQ(12, r.Call(2)); |
@@ -2379,13 +2371,12 @@ WASM_EXEC_TEST(ExprBlock_nested_ifs) { |
WasmRunner<int32_t> r(execution_mode, MachineType::Int32(), |
MachineType::Int32()); |
- BUILD(r, WASM_BLOCK( |
- 1, WASM_IF_ELSE( |
- WASM_GET_LOCAL(0), |
- 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)))))); |
+ BUILD(r, WASM_BLOCK(WASM_IF_ELSE( |
+ WASM_GET_LOCAL(0), |
+ 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)); |
@@ -2397,13 +2388,12 @@ WASM_EXEC_TEST(ExprLoop_nested_ifs) { |
WasmRunner<int32_t> r(execution_mode, MachineType::Int32(), |
MachineType::Int32()); |
- BUILD(r, WASM_LOOP( |
- 1, 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)))))); |
+ 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)); |