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

Side by Side Diff: test/cctest/wasm/test-run-wasm.cc

Issue 2230063002: [wasm] Experimental: Add support for multiple non-homogeneous tables Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | test/cctest/wasm/test-run-wasm-64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdint.h> 5 #include <stdint.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "src/base/platform/elapsed-timer.h" 9 #include "src/base/platform/elapsed-timer.h"
10 10
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 WASM_GET_LOCAL(0), 3, BR_TARGET(cases[0]), 923 WASM_GET_LOCAL(0), 3, BR_TARGET(cases[0]),
924 BR_TARGET(cases[1]), BR_TARGET(cases[2]), 924 BR_TARGET(cases[1]), BR_TARGET(cases[2]),
925 BR_TARGET(cases[3]))), 925 BR_TARGET(cases[3]))),
926 RET_I8(70)), 926 RET_I8(70)),
927 RET_I8(71)), 927 RET_I8(71)),
928 RET_I8(72)), 928 RET_I8(72)),
929 RET_I8(73)), 929 RET_I8(73)),
930 WASM_I8(75)}; 930 WASM_I8(75)};
931 931
932 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 932 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
933 r.Build(code, code + arraysize(code)); 933 r.Build(code, code + arraysize(code), false);
934 934
935 for (int x = -3; x < 50; ++x) { 935 for (int x = -3; x < 50; ++x) {
936 int index = (x > 3 || x < 0) ? 3 : x; 936 int index = (x > 3 || x < 0) ? 3 : x;
937 int32_t expected = 70 + cases[index]; 937 int32_t expected = 70 + cases[index];
938 CHECK_EQ(expected, r.Call(x)); 938 CHECK_EQ(expected, r.Call(x));
939 } 939 }
940 } 940 }
941 } 941 }
942 } 942 }
943 943
944 WASM_EXEC_TEST(BrTable4x4) { 944 WASM_EXEC_TEST(BrTable4x4) {
945 for (byte a = 0; a < 4; ++a) { 945 for (byte a = 0; a < 4; ++a) {
946 for (byte b = 0; b < 4; ++b) { 946 for (byte b = 0; b < 4; ++b) {
947 for (byte c = 0; c < 4; ++c) { 947 for (byte c = 0; c < 4; ++c) {
948 for (byte d = 0; d < 4; ++d) { 948 for (byte d = 0; d < 4; ++d) {
949 for (int i = 0; i < 4; ++i) { 949 for (int i = 0; i < 4; ++i) {
950 uint32_t cases[] = {a, b, c, d}; 950 uint32_t cases[] = {a, b, c, d};
951 byte code[] = { 951 byte code[] = {
952 B2(B2(B2(B2(B1(WASM_BR_TABLE( 952 B2(B2(B2(B2(B1(WASM_BR_TABLE(
953 WASM_GET_LOCAL(0), 3, BR_TARGET(cases[0]), 953 WASM_GET_LOCAL(0), 3, BR_TARGET(cases[0]),
954 BR_TARGET(cases[1]), BR_TARGET(cases[2]), 954 BR_TARGET(cases[1]), BR_TARGET(cases[2]),
955 BR_TARGET(cases[3]))), 955 BR_TARGET(cases[3]))),
956 RET_I8(50)), 956 RET_I8(50)),
957 RET_I8(51)), 957 RET_I8(51)),
958 RET_I8(52)), 958 RET_I8(52)),
959 RET_I8(53)), 959 RET_I8(53)),
960 WASM_I8(55)}; 960 WASM_I8(55)};
961 961
962 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 962 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
963 r.Build(code, code + arraysize(code)); 963 r.Build(code, code + arraysize(code), false);
964 964
965 for (int x = -6; x < 47; ++x) { 965 for (int x = -6; x < 47; ++x) {
966 int index = (x > 3 || x < 0) ? 3 : x; 966 int index = (x > 3 || x < 0) ? 3 : x;
967 int32_t expected = 50 + cases[index]; 967 int32_t expected = 50 + cases[index];
968 CHECK_EQ(expected, r.Call(x)); 968 CHECK_EQ(expected, r.Call(x));
969 } 969 }
970 } 970 }
971 } 971 }
972 } 972 }
973 } 973 }
974 } 974 }
975 } 975 }
976 976
977 WASM_EXEC_TEST(BrTable4_fallthru) { 977 WASM_EXEC_TEST(BrTable4_fallthru) {
978 byte code[] = { 978 byte code[] = {
979 B2(B2(B2(B2(B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 3, BR_TARGET(0), 979 B2(B2(B2(B2(B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 3, BR_TARGET(0),
980 BR_TARGET(1), BR_TARGET(2), BR_TARGET(3))), 980 BR_TARGET(1), BR_TARGET(2), BR_TARGET(3))),
981 WASM_INC_LOCAL_BY(1, 1)), 981 WASM_INC_LOCAL_BY(1, 1)),
982 WASM_INC_LOCAL_BY(1, 2)), 982 WASM_INC_LOCAL_BY(1, 2)),
983 WASM_INC_LOCAL_BY(1, 4)), 983 WASM_INC_LOCAL_BY(1, 4)),
984 WASM_INC_LOCAL_BY(1, 8)), 984 WASM_INC_LOCAL_BY(1, 8)),
985 WASM_GET_LOCAL(1)}; 985 WASM_GET_LOCAL(1)};
986 986
987 WasmRunner<int32_t> r(execution_mode, MachineType::Int32(), 987 WasmRunner<int32_t> r(execution_mode, MachineType::Int32(),
988 MachineType::Int32()); 988 MachineType::Int32());
989 r.Build(code, code + arraysize(code)); 989 r.Build(code, code + arraysize(code), false);
990 990
991 CHECK_EQ(15, r.Call(0, 0)); 991 CHECK_EQ(15, r.Call(0, 0));
992 CHECK_EQ(14, r.Call(1, 0)); 992 CHECK_EQ(14, r.Call(1, 0));
993 CHECK_EQ(12, r.Call(2, 0)); 993 CHECK_EQ(12, r.Call(2, 0));
994 CHECK_EQ(8, r.Call(3, 0)); 994 CHECK_EQ(8, r.Call(3, 0));
995 CHECK_EQ(8, r.Call(4, 0)); 995 CHECK_EQ(8, r.Call(4, 0));
996 996
997 CHECK_EQ(115, r.Call(0, 100)); 997 CHECK_EQ(115, r.Call(0, 100));
998 CHECK_EQ(114, r.Call(1, 100)); 998 CHECK_EQ(114, r.Call(1, 100));
999 CHECK_EQ(112, r.Call(2, 100)); 999 CHECK_EQ(112, r.Call(2, 100));
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 CommonOperatorBuilder common(&zone); 1771 CommonOperatorBuilder common(&zone);
1772 MachineOperatorBuilder machine(&zone, MachineType::PointerRepresentation(), 1772 MachineOperatorBuilder machine(&zone, MachineType::PointerRepresentation(),
1773 MachineOperatorBuilder::kAllOptionalOps); 1773 MachineOperatorBuilder::kAllOptionalOps);
1774 Graph graph(&zone); 1774 Graph graph(&zone);
1775 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); 1775 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine);
1776 FunctionSig* sig = WasmOpcodes::Signature(opcode); 1776 FunctionSig* sig = WasmOpcodes::Signature(opcode);
1777 1777
1778 if (sig->parameter_count() == 1) { 1778 if (sig->parameter_count() == 1) {
1779 byte code[] = {WASM_NO_LOCALS, kExprGetLocal, 0, static_cast<byte>(opcode)}; 1779 byte code[] = {WASM_NO_LOCALS, kExprGetLocal, 0, static_cast<byte>(opcode)};
1780 TestBuildingGraph(&zone, &jsgraph, nullptr, sig, nullptr, code, 1780 TestBuildingGraph(&zone, &jsgraph, nullptr, sig, nullptr, code,
1781 code + arraysize(code)); 1781 code + arraysize(code), false);
1782 } else { 1782 } else {
1783 CHECK_EQ(2, sig->parameter_count()); 1783 CHECK_EQ(2, sig->parameter_count());
1784 byte code[] = {WASM_NO_LOCALS, kExprGetLocal, 0, kExprGetLocal, 1, 1784 byte code[] = {WASM_NO_LOCALS, kExprGetLocal, 0, kExprGetLocal, 1,
1785 static_cast<byte>(opcode)}; 1785 static_cast<byte>(opcode)};
1786 TestBuildingGraph(&zone, &jsgraph, nullptr, sig, nullptr, code, 1786 TestBuildingGraph(&zone, &jsgraph, nullptr, sig, nullptr, code,
1787 code + arraysize(code)); 1787 code + arraysize(code), false);
1788 } 1788 }
1789 } 1789 }
1790 1790
1791 TEST(Build_Wasm_SimpleExprs) { 1791 TEST(Build_Wasm_SimpleExprs) {
1792 // Test that the decoder can build a graph for all supported simple expressions. 1792 // Test that the decoder can build a graph for all supported simple expressions.
1793 #define GRAPH_BUILD_TEST(name, opcode, sig) \ 1793 #define GRAPH_BUILD_TEST(name, opcode, sig) \
1794 TestBuildGraphForSimpleExpression(kExpr##name); 1794 TestBuildGraphForSimpleExpression(kExpr##name);
1795 1795
1796 FOREACH_SIMPLE_OPCODE(GRAPH_BUILD_TEST); 1796 FOREACH_SIMPLE_OPCODE(GRAPH_BUILD_TEST);
1797 1797
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
2193 static_cast<byte>(index)); 2193 static_cast<byte>(index));
2194 2194
2195 // Store the result in memory. 2195 // Store the result in memory.
2196 ADD_CODE(code, 2196 ADD_CODE(code,
2197 static_cast<byte>(WasmOpcodes::LoadStoreOpcodeOf(result, true)), 2197 static_cast<byte>(WasmOpcodes::LoadStoreOpcodeOf(result, true)),
2198 ZERO_ALIGNMENT, ZERO_OFFSET); 2198 ZERO_ALIGNMENT, ZERO_OFFSET);
2199 2199
2200 // Return the expected value. 2200 // Return the expected value.
2201 ADD_CODE(code, WASM_I32V_2(kExpected)); 2201 ADD_CODE(code, WASM_I32V_2(kExpected));
2202 2202
2203 r.Build(&code[0], &code[0] + code.size()); 2203 r.Build(&code[0], &code[0] + code.size(), false);
2204 2204
2205 // Run the code. 2205 // Run the code.
2206 for (int t = 0; t < 10; ++t) { 2206 for (int t = 0; t < 10; ++t) {
2207 module.RandomizeMemory(); 2207 module.RandomizeMemory();
2208 CHECK_EQ(kExpected, r.Call()); 2208 CHECK_EQ(kExpected, r.Call());
2209 2209
2210 int size = WasmOpcodes::MemSize(result); 2210 int size = WasmOpcodes::MemSize(result);
2211 for (int i = 0; i < size; ++i) { 2211 for (int i = 0; i < size; ++i) {
2212 int base = (which + 1) * kElemSize; 2212 int base = (which + 1) * kElemSize;
2213 byte expected = module.raw_mem_at<byte>(base + i); 2213 byte expected = module.raw_mem_at<byte>(base + i);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
2394 WasmFunctionCompiler t1(sigs.i_ii(), &module); 2394 WasmFunctionCompiler t1(sigs.i_ii(), &module);
2395 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2395 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2396 t1.CompileAndAdd(/*sig_index*/ 1); 2396 t1.CompileAndAdd(/*sig_index*/ 1);
2397 2397
2398 WasmFunctionCompiler t2(sigs.i_ii(), &module); 2398 WasmFunctionCompiler t2(sigs.i_ii(), &module);
2399 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2399 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2400 t2.CompileAndAdd(/*sig_index*/ 1); 2400 t2.CompileAndAdd(/*sig_index*/ 1);
2401 2401
2402 // Signature table. 2402 // Signature table.
2403 module.AddSignature(sigs.f_ff()); 2403 module.AddSignature(sigs.f_ff());
2404 module.AddSignature(sigs.i_ii()); 2404 byte index = module.AddSignature(sigs.i_ii());
2405 module.AddSignature(sigs.d_dd()); 2405 module.AddSignature(sigs.d_dd());
2406 2406
2407 // Function table. 2407 // Function table.
2408 uint16_t indirect_function_table[] = {0, 1}; 2408 uint16_t indirect_function_table[] = {0, 1};
2409 module.AddIndirectFunctionTable(indirect_function_table, 2409 module.AddIndirectFunctionTable(sigs.i_ii(), index, indirect_function_table,
2410 arraysize(indirect_function_table)); 2410 arraysize(indirect_function_table));
2411 module.PopulateIndirectFunctionTable(); 2411 module.PopulateIndirectFunctionTable();
2412 2412
2413 // Builder the caller function. 2413 // Builder the caller function.
2414 WasmRunner<int32_t> r(&module, MachineType::Int32()); 2414 WasmRunner<int32_t> r(&module, MachineType::Int32());
2415 BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I8(66), WASM_I8(22))); 2415 BUILD(r,
2416 WASM_CALL_INDIRECT2(1, 0, WASM_GET_LOCAL(0), WASM_I8(66), WASM_I8(22)));
2416 2417
2417 CHECK_EQ(88, r.Call(0)); 2418 CHECK_EQ(88, r.Call(0));
2418 CHECK_EQ(44, r.Call(1)); 2419 CHECK_EQ(44, r.Call(1));
2419 CHECK_TRAP(r.Call(2)); 2420 CHECK_TRAP(r.Call(2));
2420 } 2421 }
2421 2422
2422 WASM_EXEC_TEST(MultipleCallIndirect) { 2423 WASM_EXEC_TEST(MultipleCallIndirect) {
2423 TestSignatures sigs; 2424 TestSignatures sigs;
2424 TestingModule module(execution_mode); 2425 TestingModule module(execution_mode);
2425 2426
2426 WasmFunctionCompiler t1(sigs.i_ii(), &module); 2427 WasmFunctionCompiler t1(sigs.i_ii(), &module);
2427 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2428 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2428 t1.CompileAndAdd(/*sig_index*/ 1); 2429 t1.CompileAndAdd(/*sig_index*/ 1);
2429 2430
2430 WasmFunctionCompiler t2(sigs.i_ii(), &module); 2431 WasmFunctionCompiler t2(sigs.i_ii(), &module);
2431 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2432 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2432 t2.CompileAndAdd(/*sig_index*/ 1); 2433 t2.CompileAndAdd(/*sig_index*/ 1);
2433 2434
2434 // Signature table. 2435 // Signature table.
2435 module.AddSignature(sigs.f_ff()); 2436 module.AddSignature(sigs.f_ff());
2436 module.AddSignature(sigs.i_ii()); 2437 byte index = module.AddSignature(sigs.i_ii());
2437 module.AddSignature(sigs.d_dd()); 2438 module.AddSignature(sigs.d_dd());
2438 2439
2439 // Function table. 2440 // Function table.
2440 uint16_t indirect_function_table[] = {0, 1}; 2441 uint16_t indirect_function_table[] = {0, 1};
2441 module.AddIndirectFunctionTable(indirect_function_table, 2442 module.AddIndirectFunctionTable(sigs.i_ii(), index, indirect_function_table,
2442 arraysize(indirect_function_table)); 2443 arraysize(indirect_function_table));
2443 module.PopulateIndirectFunctionTable(); 2444 module.PopulateIndirectFunctionTable();
2444 2445
2445 // Builder the caller function. 2446 // Builder the caller function.
2446 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32(), 2447 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32(),
2447 MachineType::Int32()); 2448 MachineType::Int32());
2448 BUILD(r, WASM_I32_ADD( 2449 BUILD(r, WASM_I32_ADD(
2449 WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1), 2450 WASM_CALL_INDIRECT2(1, 0, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1),
2450 WASM_GET_LOCAL(2)), 2451 WASM_GET_LOCAL(2)),
2451 WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(1), WASM_GET_LOCAL(2), 2452 WASM_CALL_INDIRECT2(1, 0, WASM_GET_LOCAL(1), WASM_GET_LOCAL(2),
2452 WASM_GET_LOCAL(0)))); 2453 WASM_GET_LOCAL(0))));
2453 2454
2454 CHECK_EQ(5, r.Call(0, 1, 2)); 2455 CHECK_EQ(5, r.Call(0, 1, 2));
2455 CHECK_EQ(19, r.Call(0, 1, 9)); 2456 CHECK_EQ(19, r.Call(0, 1, 9));
2456 CHECK_EQ(1, r.Call(1, 0, 2)); 2457 CHECK_EQ(1, r.Call(1, 0, 2));
2457 CHECK_EQ(1, r.Call(1, 0, 9)); 2458 CHECK_EQ(1, r.Call(1, 0, 9));
2458 2459
2459 CHECK_TRAP(r.Call(0, 2, 1)); 2460 CHECK_TRAP(r.Call(0, 2, 1));
2460 CHECK_TRAP(r.Call(1, 2, 0)); 2461 CHECK_TRAP(r.Call(1, 2, 0));
2461 CHECK_TRAP(r.Call(2, 0, 1)); 2462 CHECK_TRAP(r.Call(2, 0, 1));
2462 CHECK_TRAP(r.Call(2, 1, 0)); 2463 CHECK_TRAP(r.Call(2, 1, 0));
2463 } 2464 }
2464 2465
2465 WASM_EXEC_TEST(CallIndirect_NoTable) { 2466 WASM_EXEC_TEST(CallIndirect_NoTable) {
2466 TestSignatures sigs; 2467 TestSignatures sigs;
2467 TestingModule module(execution_mode); 2468 TestingModule module(execution_mode);
2468 2469
2469 // One function. 2470 // One function.
2470 WasmFunctionCompiler t1(sigs.i_ii(), &module); 2471 WasmFunctionCompiler t1(sigs.i_ii(), &module);
2471 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2472 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2472 t1.CompileAndAdd(/*sig_index*/ 1); 2473 t1.CompileAndAdd(/*sig_index*/ 1);
2473 2474
2474 // Signature table. 2475 // Signature table.
2475 module.AddSignature(sigs.f_ff()); 2476 module.AddSignature(sigs.f_ff());
2476 module.AddSignature(sigs.i_ii()); 2477 module.AddSignature(sigs.i_ii());
2477 2478
2478 // Builder the caller function. 2479 // Builder the caller function.
2479 WasmRunner<int32_t> r(&module, MachineType::Int32()); 2480 WasmRunner<int32_t> r(&module, MachineType::Int32());
2480 BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I8(66), WASM_I8(22))); 2481 BUILD_FAIL(r, WASM_CALL_INDIRECT2(1, 0, WASM_GET_LOCAL(0), WASM_I8(66),
2481 2482 WASM_I8(22)));
2482 CHECK_TRAP(r.Call(0));
2483 CHECK_TRAP(r.Call(1));
2484 CHECK_TRAP(r.Call(2));
2485 } 2483 }
2486 2484
2487 WASM_EXEC_TEST(F32Floor) { 2485 WASM_EXEC_TEST(F32Floor) {
2488 WasmRunner<float> r(execution_mode, MachineType::Float32()); 2486 WasmRunner<float> r(execution_mode, MachineType::Float32());
2489 BUILD(r, WASM_F32_FLOOR(WASM_GET_LOCAL(0))); 2487 BUILD(r, WASM_F32_FLOOR(WASM_GET_LOCAL(0)));
2490 2488
2491 FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(floorf(*i), r.Call(*i)); } 2489 FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(floorf(*i), r.Call(*i)); }
2492 } 2490 }
2493 2491
2494 WASM_EXEC_TEST(F32Ceil) { 2492 WASM_EXEC_TEST(F32Ceil) {
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
2733 // Make sure we don't run out of registers when compiling indirect calls 2731 // Make sure we don't run out of registers when compiling indirect calls
2734 // with many many parameters. 2732 // with many many parameters.
2735 TestSignatures sigs; 2733 TestSignatures sigs;
2736 for (byte num_params = 0; num_params < 40; ++num_params) { 2734 for (byte num_params = 0; num_params < 40; ++num_params) {
2737 v8::base::AccountingAllocator allocator; 2735 v8::base::AccountingAllocator allocator;
2738 Zone zone(&allocator); 2736 Zone zone(&allocator);
2739 HandleScope scope(CcTest::InitIsolateOnce()); 2737 HandleScope scope(CcTest::InitIsolateOnce());
2740 TestingModule module(kExecuteCompiled); 2738 TestingModule module(kExecuteCompiled);
2741 FunctionSig* sig = sigs.many(&zone, kAstStmt, param, num_params); 2739 FunctionSig* sig = sigs.many(&zone, kAstStmt, param, num_params);
2742 2740
2743 module.AddSignature(sig); 2741 byte index = module.AddSignature(sig);
2744 module.AddSignature(sig); 2742 module.AddIndirectFunctionTable(sig, index, nullptr, 0);
2745 module.AddIndirectFunctionTable(nullptr, 0);
2746 2743
2747 WasmFunctionCompiler t(sig, &module); 2744 WasmFunctionCompiler t(sig, &module);
2748 2745
2749 std::vector<byte> code; 2746 std::vector<byte> code;
2750 ADD_CODE(code, kExprI8Const, 0); 2747 ADD_CODE(code, kExprI8Const, 0);
2751 for (byte p = 0; p < num_params; ++p) { 2748 for (byte p = 0; p < num_params; ++p) {
2752 ADD_CODE(code, kExprGetLocal, p); 2749 ADD_CODE(code, kExprGetLocal, p);
2753 } 2750 }
2754 ADD_CODE(code, kExprCallIndirect, static_cast<byte>(num_params), 1); 2751 ADD_CODE(code, kExprCallIndirect, static_cast<byte>(num_params), index, 0);
2755 2752
2756 t.Build(&code[0], &code[0] + code.size()); 2753 t.Build(&code[0], &code[0] + code.size(), false);
2757 t.Compile(); 2754 t.Compile();
2758 } 2755 }
2759 } 2756 }
2760 2757
2761 TEST(Compile_Wasm_CallIndirect_Many_i32) { CompileCallIndirectMany(kAstI32); } 2758 TEST(Compile_Wasm_CallIndirect_Many_i32) { CompileCallIndirectMany(kAstI32); }
2762 2759
2763 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } 2760 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); }
2764 2761
2765 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } 2762 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); }
2766 2763
2767 WASM_EXEC_TEST(Int32RemS_dead) { 2764 WASM_EXEC_TEST(Int32RemS_dead) {
2768 WasmRunner<int32_t> r(execution_mode, MachineType::Int32(), 2765 WasmRunner<int32_t> r(execution_mode, MachineType::Int32(),
2769 MachineType::Int32()); 2766 MachineType::Int32());
2770 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_ZERO); 2767 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_ZERO);
2771 const int32_t kMin = std::numeric_limits<int32_t>::min(); 2768 const int32_t kMin = std::numeric_limits<int32_t>::min();
2772 CHECK_EQ(0, r.Call(133, 100)); 2769 CHECK_EQ(0, r.Call(133, 100));
2773 CHECK_EQ(0, r.Call(kMin, -1)); 2770 CHECK_EQ(0, r.Call(kMin, -1));
2774 CHECK_EQ(0, r.Call(0, 1)); 2771 CHECK_EQ(0, r.Call(0, 1));
2775 CHECK_TRAP(r.Call(100, 0)); 2772 CHECK_TRAP(r.Call(100, 0));
2776 CHECK_TRAP(r.Call(-1001, 0)); 2773 CHECK_TRAP(r.Call(-1001, 0));
2777 CHECK_TRAP(r.Call(kMin, 0)); 2774 CHECK_TRAP(r.Call(kMin, 0));
2778 } 2775 }
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | test/cctest/wasm/test-run-wasm-64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698