diff options
Diffstat (limited to 'deps/v8/test/cctest/wasm/test-run-wasm-interpreter.cc')
-rw-r--r-- | deps/v8/test/cctest/wasm/test-run-wasm-interpreter.cc | 102 |
1 files changed, 49 insertions, 53 deletions
diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-interpreter.cc b/deps/v8/test/cctest/wasm/test-run-wasm-interpreter.cc index 47d97f4e48..e355b68d19 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-interpreter.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-interpreter.cc @@ -30,20 +30,21 @@ TEST(Run_WasmInt8Const_i) { WasmRunner<int32_t> r(kExecuteInterpreted); const byte kExpectedValue = 109; // return(kExpectedValue) - BUILD(r, WASM_I8(kExpectedValue)); + BUILD(r, WASM_I32V_2(kExpectedValue)); CHECK_EQ(kExpectedValue, r.Call()); } TEST(Run_WasmIfElse) { - WasmRunner<int32_t> r(kExecuteInterpreted, MachineType::Int32()); - BUILD(r, WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_I8(9), WASM_I8(10))); + WasmRunner<int32_t, int32_t> r(kExecuteInterpreted); + BUILD(r, WASM_IF_ELSE_I(WASM_GET_LOCAL(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> r(kExecuteInterpreted, MachineType::Int32()); - BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_RETURN1(WASM_I8(77))), WASM_I8(65)); + WasmRunner<int32_t, int32_t> r(kExecuteInterpreted); + BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_RETURN1(WASM_I32V_2(77))), + WASM_I32V_2(65)); CHECK_EQ(65, r.Call(0)); CHECK_EQ(77, r.Call(1)); } @@ -54,7 +55,7 @@ TEST(Run_WasmNopsN) { for (int nops = 0; nops < kMaxNops; nops++) { byte expected = static_cast<byte>(20 + nops); memset(code, kExprNop, sizeof(code)); - code[nops] = kExprI8Const; + code[nops] = kExprI32Const; code[nops + 1] = expected; WasmRunner<int32_t> r(kExecuteInterpreted); @@ -64,13 +65,13 @@ TEST(Run_WasmNopsN) { } TEST(Run_WasmConstsN) { - const int kMaxConsts = 10; + const int kMaxConsts = 5; byte code[kMaxConsts * 3]; int32_t expected = 0; for (int count = 1; count < kMaxConsts; count++) { for (int i = 0; i < count; i++) { byte val = static_cast<byte>(count * 10 + i); - code[i * 3] = kExprI8Const; + code[i * 3] = kExprI32Const; code[i * 3 + 1] = val; if (i == (count - 1)) { code[i * 3 + 2] = kExprNop; @@ -95,7 +96,7 @@ TEST(Run_WasmBlocksN) { memset(code, kExprNop, sizeof(code)); code[0] = kExprBlock; code[1] = kLocalI32; - code[2 + nops] = kExprI8Const; + code[2 + nops] = kExprI32Const; code[2 + nops + 1] = expected; code[2 + nops + 2] = kExprEnd; @@ -108,6 +109,7 @@ TEST(Run_WasmBlocksN) { TEST(Run_WasmBlockBreakN) { const int kMaxNops = 10; const int kExtra = 6; + int run = 0; byte code[kMaxNops + kExtra]; for (int nops = 0; nops < kMaxNops; nops++) { // Place the break anywhere within the block. @@ -117,8 +119,8 @@ TEST(Run_WasmBlockBreakN) { code[1] = kLocalI32; code[sizeof(code) - 1] = kExprEnd; - int expected = nops * 11 + index; - code[2 + index + 0] = kExprI8Const; + int expected = run++; + code[2 + index + 0] = kExprI32Const; code[2 + index + 1] = static_cast<byte>(expected); code[2 + index + 2] = kExprBr; code[2 + index + 3] = 0; @@ -131,13 +133,14 @@ TEST(Run_WasmBlockBreakN) { } TEST(Run_Wasm_nested_ifs_i) { - WasmRunner<int32_t> r(kExecuteInterpreted, MachineType::Int32(), - MachineType::Int32()); + WasmRunner<int32_t, int32_t, int32_t> r(kExecuteInterpreted); - BUILD(r, WASM_IF_ELSE_I( - 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)))); + BUILD( + r, + WASM_IF_ELSE_I( + WASM_GET_LOCAL(0), + WASM_IF_ELSE_I(WASM_GET_LOCAL(1), WASM_I32V_1(11), WASM_I32V_1(12)), + WASM_IF_ELSE_I(WASM_GET_LOCAL(1), WASM_I32V_1(13), WASM_I32V_1(14)))); CHECK_EQ(11, r.Call(1, 1)); CHECK_EQ(12, r.Call(1, 0)); @@ -180,8 +183,7 @@ TEST(Breakpoint_I32Add) { Find(code, sizeof(code), kNumBreakpoints, kExprGetLocal, kExprGetLocal, kExprI32Add); - WasmRunner<int32_t> r(kExecuteInterpreted, MachineType::Uint32(), - MachineType::Uint32()); + WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteInterpreted); r.Build(code, code + arraysize(code)); @@ -217,11 +219,10 @@ TEST(Breakpoint_I32Add) { } TEST(Step_I32Mul) { - static const int kTraceLength = 4; + static const int kTraceLength = 5; byte code[] = {WASM_I32_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))}; - WasmRunner<int32_t> r(kExecuteInterpreted, MachineType::Uint32(), - MachineType::Uint32()); + WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteInterpreted); r.Build(code, code + arraysize(code)); @@ -259,8 +260,7 @@ TEST(Breakpoint_I32And_disable) { std::unique_ptr<int[]> offsets = Find(code, sizeof(code), kNumBreakpoints, kExprI32And); - WasmRunner<int32_t> r(kExecuteInterpreted, MachineType::Uint32(), - MachineType::Uint32()); + WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteInterpreted); r.Build(code, code + arraysize(code)); @@ -297,19 +297,27 @@ TEST(Breakpoint_I32And_disable) { } TEST(GrowMemory) { - TestingModule module(kExecuteInterpreted); - WasmRunner<int32_t> r(&module, MachineType::Uint32()); - module.AddMemory(WasmModule::kPageSize); - BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0))); - CHECK_EQ(1, r.Call(1)); + { + WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted); + r.module().AddMemory(WasmModule::kPageSize); + r.module().SetMaxMemPages(10); + BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0))); + CHECK_EQ(1, r.Call(1)); + } + { + WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted); + r.module().AddMemory(WasmModule::kPageSize); + r.module().SetMaxMemPages(10); + BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0))); + CHECK_EQ(-1, r.Call(11)); + } } TEST(GrowMemoryPreservesData) { int32_t index = 16; int32_t value = 2335; - TestingModule module(kExecuteInterpreted); - WasmRunner<int32_t> r(&module, MachineType::Uint32()); - module.AddMemory(WasmModule::kPageSize); + WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted); + r.module().AddMemory(WasmModule::kPageSize); BUILD(r, WASM_STORE_MEM(MachineType::Int32(), WASM_I32V(index), WASM_I32V(value)), WASM_GROW_MEMORY(WASM_GET_LOCAL(0)), WASM_DROP, @@ -320,16 +328,14 @@ TEST(GrowMemoryPreservesData) { TEST(GrowMemoryInvalidSize) { { // Grow memory by an invalid amount without initial memory. - TestingModule module(kExecuteInterpreted); - WasmRunner<int32_t> r(&module, MachineType::Uint32()); + WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted); BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0))); CHECK_EQ(-1, r.Call(1048575)); } { // Grow memory by an invalid amount without initial memory. - TestingModule module(kExecuteInterpreted); - WasmRunner<int32_t> r(&module, MachineType::Uint32()); - module.AddMemory(WasmModule::kPageSize); + WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted); + r.module().AddMemory(WasmModule::kPageSize); BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0))); CHECK_EQ(-1, r.Call(1048575)); } @@ -338,9 +344,7 @@ TEST(GrowMemoryInvalidSize) { TEST(TestPossibleNondeterminism) { { // F32Div may produced NaN - TestingModule module(kExecuteInterpreted); - WasmRunner<float> r(&module, MachineType::Float32(), - MachineType::Float32()); + WasmRunner<float, float, float> r(kExecuteInterpreted); BUILD(r, WASM_F32_DIV(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); r.Call(1048575.5f, 2.5f); CHECK(!r.possible_nondeterminism()); @@ -349,8 +353,7 @@ TEST(TestPossibleNondeterminism) { } { // F32Sqrt may produced NaN - TestingModule module(kExecuteInterpreted); - WasmRunner<float> r(&module, MachineType::Float32()); + WasmRunner<float, float> r(kExecuteInterpreted); BUILD(r, WASM_F32_SQRT(WASM_GET_LOCAL(0))); r.Call(16.0f); CHECK(!r.possible_nondeterminism()); @@ -359,9 +362,7 @@ TEST(TestPossibleNondeterminism) { } { // F32Mul may produced NaN - TestingModule module(kExecuteInterpreted); - WasmRunner<float> r(&module, MachineType::Float32(), - MachineType::Float32()); + WasmRunner<float, float, float> r(kExecuteInterpreted); BUILD(r, WASM_F32_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); r.Call(1048575.5f, 2.5f); CHECK(!r.possible_nondeterminism()); @@ -370,9 +371,7 @@ TEST(TestPossibleNondeterminism) { } { // F64Div may produced NaN - TestingModule module(kExecuteInterpreted); - WasmRunner<double> r(&module, MachineType::Float64(), - MachineType::Float64()); + WasmRunner<double, double, double> r(kExecuteInterpreted); BUILD(r, WASM_F64_DIV(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); r.Call(1048575.5, 2.5); CHECK(!r.possible_nondeterminism()); @@ -381,8 +380,7 @@ TEST(TestPossibleNondeterminism) { } { // F64Sqrt may produced NaN - TestingModule module(kExecuteInterpreted); - WasmRunner<double> r(&module, MachineType::Float64()); + WasmRunner<double, double> r(kExecuteInterpreted); BUILD(r, WASM_F64_SQRT(WASM_GET_LOCAL(0))); r.Call(1048575.5); CHECK(!r.possible_nondeterminism()); @@ -391,9 +389,7 @@ TEST(TestPossibleNondeterminism) { } { // F64Mul may produced NaN - TestingModule module(kExecuteInterpreted); - WasmRunner<double> r(&module, MachineType::Float64(), - MachineType::Float64()); + WasmRunner<double, double, double> r(kExecuteInterpreted); BUILD(r, WASM_F64_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); r.Call(1048575.5, 2.5); CHECK(!r.possible_nondeterminism()); |