OLD | NEW |
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 2389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2400 WasmFunctionCompiler t2(sigs.i_ii(), &module); | 2400 WasmFunctionCompiler t2(sigs.i_ii(), &module); |
2401 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 2401 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
2402 t2.CompileAndAdd(/*sig_index*/ 1); | 2402 t2.CompileAndAdd(/*sig_index*/ 1); |
2403 | 2403 |
2404 // Signature table. | 2404 // Signature table. |
2405 module.AddSignature(sigs.f_ff()); | 2405 module.AddSignature(sigs.f_ff()); |
2406 module.AddSignature(sigs.i_ii()); | 2406 module.AddSignature(sigs.i_ii()); |
2407 module.AddSignature(sigs.d_dd()); | 2407 module.AddSignature(sigs.d_dd()); |
2408 | 2408 |
2409 // Function table. | 2409 // Function table. |
2410 int table[] = {0, 1}; | 2410 uint16_t indirect_function_table[] = {0, 1}; |
2411 module.AddIndirectFunctionTable(table, 2); | 2411 module.AddIndirectFunctionTable(indirect_function_table, |
| 2412 arraysize(indirect_function_table)); |
2412 module.PopulateIndirectFunctionTable(); | 2413 module.PopulateIndirectFunctionTable(); |
2413 | 2414 |
2414 // Builder the caller function. | 2415 // Builder the caller function. |
2415 WasmRunner<int32_t> r(&module, MachineType::Int32()); | 2416 WasmRunner<int32_t> r(&module, MachineType::Int32()); |
2416 BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I8(66), WASM_I8(22))); | 2417 BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I8(66), WASM_I8(22))); |
2417 | 2418 |
2418 CHECK_EQ(88, r.Call(0)); | 2419 CHECK_EQ(88, r.Call(0)); |
2419 CHECK_EQ(44, r.Call(1)); | 2420 CHECK_EQ(44, r.Call(1)); |
2420 CHECK_TRAP(r.Call(2)); | 2421 CHECK_TRAP(r.Call(2)); |
2421 } | 2422 } |
2422 | 2423 |
2423 WASM_EXEC_TEST(MultipleCallIndirect) { | 2424 WASM_EXEC_TEST(MultipleCallIndirect) { |
2424 TestSignatures sigs; | 2425 TestSignatures sigs; |
2425 TestingModule module(execution_mode); | 2426 TestingModule module(execution_mode); |
2426 | 2427 |
2427 WasmFunctionCompiler t1(sigs.i_ii(), &module); | 2428 WasmFunctionCompiler t1(sigs.i_ii(), &module); |
2428 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 2429 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
2429 t1.CompileAndAdd(/*sig_index*/ 1); | 2430 t1.CompileAndAdd(/*sig_index*/ 1); |
2430 | 2431 |
2431 WasmFunctionCompiler t2(sigs.i_ii(), &module); | 2432 WasmFunctionCompiler t2(sigs.i_ii(), &module); |
2432 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 2433 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
2433 t2.CompileAndAdd(/*sig_index*/ 1); | 2434 t2.CompileAndAdd(/*sig_index*/ 1); |
2434 | 2435 |
2435 // Signature table. | 2436 // Signature table. |
2436 module.AddSignature(sigs.f_ff()); | 2437 module.AddSignature(sigs.f_ff()); |
2437 module.AddSignature(sigs.i_ii()); | 2438 module.AddSignature(sigs.i_ii()); |
2438 module.AddSignature(sigs.d_dd()); | 2439 module.AddSignature(sigs.d_dd()); |
2439 | 2440 |
2440 // Function table. | 2441 // Function table. |
2441 int table[] = {0, 1}; | 2442 uint16_t indirect_function_table[] = {0, 1}; |
2442 module.AddIndirectFunctionTable(table, 2); | 2443 module.AddIndirectFunctionTable(indirect_function_table, |
| 2444 arraysize(indirect_function_table)); |
2443 module.PopulateIndirectFunctionTable(); | 2445 module.PopulateIndirectFunctionTable(); |
2444 | 2446 |
2445 // Builder the caller function. | 2447 // Builder the caller function. |
2446 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32(), | 2448 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32(), |
2447 MachineType::Int32()); | 2449 MachineType::Int32()); |
2448 BUILD(r, WASM_I32_ADD( | 2450 BUILD(r, WASM_I32_ADD( |
2449 WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1), | 2451 WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1), |
2450 WASM_GET_LOCAL(2)), | 2452 WASM_GET_LOCAL(2)), |
2451 WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(1), WASM_GET_LOCAL(2), | 2453 WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(1), WASM_GET_LOCAL(2), |
2452 WASM_GET_LOCAL(0)))); | 2454 WASM_GET_LOCAL(0)))); |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2838 MachineType::Int32()); | 2840 MachineType::Int32()); |
2839 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_ZERO); | 2841 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_ZERO); |
2840 const int32_t kMin = std::numeric_limits<int32_t>::min(); | 2842 const int32_t kMin = std::numeric_limits<int32_t>::min(); |
2841 CHECK_EQ(0, r.Call(133, 100)); | 2843 CHECK_EQ(0, r.Call(133, 100)); |
2842 CHECK_EQ(0, r.Call(kMin, -1)); | 2844 CHECK_EQ(0, r.Call(kMin, -1)); |
2843 CHECK_EQ(0, r.Call(0, 1)); | 2845 CHECK_EQ(0, r.Call(0, 1)); |
2844 CHECK_TRAP(r.Call(100, 0)); | 2846 CHECK_TRAP(r.Call(100, 0)); |
2845 CHECK_TRAP(r.Call(-1001, 0)); | 2847 CHECK_TRAP(r.Call(-1001, 0)); |
2846 CHECK_TRAP(r.Call(kMin, 0)); | 2848 CHECK_TRAP(r.Call(kMin, 0)); |
2847 } | 2849 } |
OLD | NEW |