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 #include "src/utils.h" | 10 #include "src/utils.h" |
(...skipping 2622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2633 | 2633 |
2634 // Builder the caller function. | 2634 // Builder the caller function. |
2635 WasmRunner<int32_t> r(&module, MachineType::Int32()); | 2635 WasmRunner<int32_t> r(&module, MachineType::Int32()); |
2636 BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I8(66), WASM_I8(22))); | 2636 BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I8(66), WASM_I8(22))); |
2637 | 2637 |
2638 CHECK_TRAP(r.Call(0)); | 2638 CHECK_TRAP(r.Call(0)); |
2639 CHECK_TRAP(r.Call(1)); | 2639 CHECK_TRAP(r.Call(1)); |
2640 CHECK_TRAP(r.Call(2)); | 2640 CHECK_TRAP(r.Call(2)); |
2641 } | 2641 } |
2642 | 2642 |
| 2643 WASM_EXEC_TEST(CallIndirect_EmptyTable) { |
| 2644 TestSignatures sigs; |
| 2645 TestingModule module(execution_mode); |
| 2646 |
| 2647 // One function. |
| 2648 WasmFunctionCompiler t1(sigs.i_ii(), &module); |
| 2649 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 2650 t1.CompileAndAdd(/*sig_index*/ 1); |
| 2651 |
| 2652 // Signature table. |
| 2653 module.AddSignature(sigs.f_ff()); |
| 2654 module.AddSignature(sigs.i_ii()); |
| 2655 module.AddIndirectFunctionTable(nullptr, 0); |
| 2656 |
| 2657 // Builder the caller function. |
| 2658 WasmRunner<int32_t> r(&module, MachineType::Int32()); |
| 2659 BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I8(66), WASM_I8(22))); |
| 2660 |
| 2661 CHECK_TRAP(r.Call(0)); |
| 2662 CHECK_TRAP(r.Call(1)); |
| 2663 CHECK_TRAP(r.Call(2)); |
| 2664 } |
| 2665 |
2643 WASM_EXEC_TEST(CallIndirect_canonical) { | 2666 WASM_EXEC_TEST(CallIndirect_canonical) { |
2644 TestSignatures sigs; | 2667 TestSignatures sigs; |
2645 TestingModule module(execution_mode); | 2668 TestingModule module(execution_mode); |
2646 | 2669 |
2647 WasmFunctionCompiler t1(sigs.i_ii(), &module); | 2670 WasmFunctionCompiler t1(sigs.i_ii(), &module); |
2648 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 2671 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
2649 t1.CompileAndAdd(/*sig_index*/ 0); | 2672 t1.CompileAndAdd(/*sig_index*/ 0); |
2650 | 2673 |
2651 WasmFunctionCompiler t2(sigs.i_ii(), &module); | 2674 WasmFunctionCompiler t2(sigs.i_ii(), &module); |
2652 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 2675 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2916 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_DROP, | 2939 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_DROP, |
2917 WASM_ZERO); | 2940 WASM_ZERO); |
2918 const int32_t kMin = std::numeric_limits<int32_t>::min(); | 2941 const int32_t kMin = std::numeric_limits<int32_t>::min(); |
2919 CHECK_EQ(0, r.Call(133, 100)); | 2942 CHECK_EQ(0, r.Call(133, 100)); |
2920 CHECK_EQ(0, r.Call(kMin, -1)); | 2943 CHECK_EQ(0, r.Call(kMin, -1)); |
2921 CHECK_EQ(0, r.Call(0, 1)); | 2944 CHECK_EQ(0, r.Call(0, 1)); |
2922 CHECK_TRAP(r.Call(100, 0)); | 2945 CHECK_TRAP(r.Call(100, 0)); |
2923 CHECK_TRAP(r.Call(-1001, 0)); | 2946 CHECK_TRAP(r.Call(-1001, 0)); |
2924 CHECK_TRAP(r.Call(kMin, 0)); | 2947 CHECK_TRAP(r.Call(kMin, 0)); |
2925 } | 2948 } |
OLD | NEW |