| Index: test/cctest/wasm/test-run-wasm-interpreter.cc
|
| diff --git a/test/cctest/wasm/test-run-wasm-interpreter.cc b/test/cctest/wasm/test-run-wasm-interpreter.cc
|
| index db5bb2a786c6891fc7f890fb48c3ca5222d8faa7..218ee956c03fec4a5a1f895c085db40c8aa17072 100644
|
| --- a/test/cctest/wasm/test-run-wasm-interpreter.cc
|
| +++ b/test/cctest/wasm/test-run-wasm-interpreter.cc
|
| @@ -36,7 +36,7 @@ TEST(Run_WasmInt8Const_i) {
|
|
|
| TEST(Run_WasmIfElse) {
|
| WasmRunner<int32_t> r(kExecuteInterpreted, MachineType::Int32());
|
| - BUILD(r, WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_I8(9), WASM_I8(10)));
|
| + BUILD(r, WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_I8(9), WASM_I8(10)));
|
| CHECK_EQ(10, r.Call(0));
|
| CHECK_EQ(9, r.Call(1));
|
| }
|
| @@ -65,31 +65,39 @@ TEST(Run_WasmNopsN) {
|
|
|
| TEST(Run_WasmConstsN) {
|
| const int kMaxConsts = 10;
|
| - byte code[kMaxConsts * 2];
|
| + byte code[kMaxConsts * 3];
|
| + int32_t expected = 0;
|
| for (int count = 1; count < kMaxConsts; count++) {
|
| for (int i = 0; i < count; i++) {
|
| - code[i * 2] = kExprI8Const;
|
| - code[i * 2 + 1] = static_cast<byte>(count * 10 + i);
|
| + byte val = static_cast<byte>(count * 10 + i);
|
| + code[i * 3] = kExprI8Const;
|
| + code[i * 3 + 1] = val;
|
| + if (i == (count - 1)) {
|
| + code[i * 3 + 2] = kExprNop;
|
| + expected = val;
|
| + } else {
|
| + code[i * 3 + 2] = kExprDrop;
|
| + }
|
| }
|
| - byte expected = static_cast<byte>(count * 11 - 1);
|
|
|
| WasmRunner<int32_t> r(kExecuteInterpreted);
|
| - r.Build(code, code + (count * 2));
|
| + r.Build(code, code + (count * 3));
|
| CHECK_EQ(expected, r.Call());
|
| }
|
| }
|
|
|
| TEST(Run_WasmBlocksN) {
|
| const int kMaxNops = 10;
|
| - const int kExtra = 4;
|
| + const int kExtra = 5;
|
| byte code[kMaxNops + kExtra];
|
| for (int nops = 0; nops < kMaxNops; nops++) {
|
| byte expected = static_cast<byte>(30 + nops);
|
| memset(code, kExprNop, sizeof(code));
|
| code[0] = kExprBlock;
|
| - code[1 + nops] = kExprI8Const;
|
| - code[1 + nops + 1] = expected;
|
| - code[1 + nops + 2] = kExprEnd;
|
| + code[1] = kLocalI32;
|
| + code[2 + nops] = kExprI8Const;
|
| + code[2 + nops + 1] = expected;
|
| + code[2 + nops + 2] = kExprEnd;
|
|
|
| WasmRunner<int32_t> r(kExecuteInterpreted);
|
| r.Build(code, code + nops + kExtra);
|
| @@ -106,14 +114,14 @@ TEST(Run_WasmBlockBreakN) {
|
| for (int index = 0; index < nops; index++) {
|
| memset(code, kExprNop, sizeof(code));
|
| code[0] = kExprBlock;
|
| + code[1] = kLocalI32;
|
| code[sizeof(code) - 1] = kExprEnd;
|
|
|
| int expected = nops * 11 + index;
|
| - code[1 + index + 0] = kExprI8Const;
|
| - code[1 + index + 1] = static_cast<byte>(expected);
|
| - code[1 + index + 2] = kExprBr;
|
| - code[1 + index + 3] = ARITY_1;
|
| - code[1 + index + 4] = 0;
|
| + code[2 + index + 0] = kExprI8Const;
|
| + code[2 + index + 1] = static_cast<byte>(expected);
|
| + code[2 + index + 2] = kExprBr;
|
| + code[2 + index + 3] = 0;
|
|
|
| WasmRunner<int32_t> r(kExecuteInterpreted);
|
| r.Build(code, code + kMaxNops + kExtra);
|
| @@ -126,10 +134,10 @@ TEST(Run_Wasm_nested_ifs_i) {
|
| WasmRunner<int32_t> r(kExecuteInterpreted, MachineType::Int32(),
|
| MachineType::Int32());
|
|
|
| - BUILD(r, WASM_IF_ELSE(
|
| + BUILD(r, WASM_IF_ELSE_I(
|
| WASM_GET_LOCAL(0),
|
| - 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))));
|
| + 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))));
|
|
|
| CHECK_EQ(11, r.Call(1, 1));
|
| CHECK_EQ(12, r.Call(1, 0));
|
| @@ -300,10 +308,10 @@ TEST(GrowMemoryPreservesData) {
|
| TestingModule module(kExecuteInterpreted);
|
| WasmRunner<int32_t> r(&module, MachineType::Uint32());
|
| module.AddMemory(WasmModule::kPageSize);
|
| - BUILD(r, WASM_BLOCK(WASM_STORE_MEM(MachineType::Int32(), WASM_I32V(index),
|
| - WASM_I32V(value)),
|
| - WASM_GROW_MEMORY(WASM_GET_LOCAL(0)),
|
| - WASM_LOAD_MEM(MachineType::Int32(), WASM_I32V(index))));
|
| + BUILD(r, WASM_STORE_MEM(MachineType::Int32(), WASM_I32V(index),
|
| + WASM_I32V(value)),
|
| + WASM_GROW_MEMORY(WASM_GET_LOCAL(0)), WASM_DROP,
|
| + WASM_LOAD_MEM(MachineType::Int32(), WASM_I32V(index)));
|
| CHECK_EQ(value, r.Call(1));
|
| }
|
|
|
| @@ -312,7 +320,7 @@ TEST(GrowMemoryInvalidSize) {
|
| // Grow memory by an invalid amount without initial memory.
|
| TestingModule module(kExecuteInterpreted);
|
| WasmRunner<int32_t> r(&module, MachineType::Uint32());
|
| - BUILD(r, WASM_BLOCK(WASM_GROW_MEMORY(WASM_GET_LOCAL(0))));
|
| + BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0)));
|
| CHECK_EQ(-1, r.Call(1048575));
|
| }
|
| {
|
| @@ -320,7 +328,7 @@ TEST(GrowMemoryInvalidSize) {
|
| TestingModule module(kExecuteInterpreted);
|
| WasmRunner<int32_t> r(&module, MachineType::Uint32());
|
| module.AddMemory(WasmModule::kPageSize);
|
| - BUILD(r, WASM_BLOCK(WASM_GROW_MEMORY(WASM_GET_LOCAL(0))));
|
| + BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0)));
|
| CHECK_EQ(-1, r.Call(1048575));
|
| }
|
| }
|
|
|