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 2654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2665 CHECK_EQ(19, r.Call(0, 1, 9)); | 2665 CHECK_EQ(19, r.Call(0, 1, 9)); |
2666 CHECK_EQ(1, r.Call(1, 0, 2)); | 2666 CHECK_EQ(1, r.Call(1, 0, 2)); |
2667 CHECK_EQ(1, r.Call(1, 0, 9)); | 2667 CHECK_EQ(1, r.Call(1, 0, 9)); |
2668 | 2668 |
2669 CHECK_TRAP(r.Call(0, 2, 1)); | 2669 CHECK_TRAP(r.Call(0, 2, 1)); |
2670 CHECK_TRAP(r.Call(1, 2, 0)); | 2670 CHECK_TRAP(r.Call(1, 2, 0)); |
2671 CHECK_TRAP(r.Call(2, 0, 1)); | 2671 CHECK_TRAP(r.Call(2, 0, 1)); |
2672 CHECK_TRAP(r.Call(2, 1, 0)); | 2672 CHECK_TRAP(r.Call(2, 1, 0)); |
2673 } | 2673 } |
2674 | 2674 |
| 2675 WASM_EXEC_TEST(CallIndirect_NoTable) { |
| 2676 TestSignatures sigs; |
| 2677 TestingModule module(execution_mode); |
| 2678 |
| 2679 // One function. |
| 2680 WasmFunctionCompiler t1(sigs.i_ii(), &module); |
| 2681 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 2682 t1.CompileAndAdd(/*sig_index*/ 1); |
| 2683 |
| 2684 // Signature table. |
| 2685 module.AddSignature(sigs.f_ff()); |
| 2686 module.AddSignature(sigs.i_ii()); |
| 2687 |
| 2688 // Builder the caller function. |
| 2689 WasmRunner<int32_t> r(&module, MachineType::Int32()); |
| 2690 BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I8(66), WASM_I8(22))); |
| 2691 |
| 2692 CHECK_TRAP(r.Call(0)); |
| 2693 CHECK_TRAP(r.Call(1)); |
| 2694 CHECK_TRAP(r.Call(2)); |
| 2695 } |
| 2696 |
2675 WASM_EXEC_TEST(CallIndirect_EmptyTable) { | 2697 WASM_EXEC_TEST(CallIndirect_EmptyTable) { |
2676 TestSignatures sigs; | 2698 TestSignatures sigs; |
2677 TestingModule module(execution_mode); | 2699 TestingModule module(execution_mode); |
2678 | 2700 |
2679 // One function. | 2701 // One function. |
2680 WasmFunctionCompiler t1(sigs.i_ii(), &module); | 2702 WasmFunctionCompiler t1(sigs.i_ii(), &module); |
2681 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 2703 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
2682 t1.CompileAndAdd(/*sig_index*/ 1); | 2704 t1.CompileAndAdd(/*sig_index*/ 1); |
2683 | 2705 |
2684 // Signature table. | 2706 // Signature table. |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2971 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_DROP, | 2993 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_DROP, |
2972 WASM_ZERO); | 2994 WASM_ZERO); |
2973 const int32_t kMin = std::numeric_limits<int32_t>::min(); | 2995 const int32_t kMin = std::numeric_limits<int32_t>::min(); |
2974 CHECK_EQ(0, r.Call(133, 100)); | 2996 CHECK_EQ(0, r.Call(133, 100)); |
2975 CHECK_EQ(0, r.Call(kMin, -1)); | 2997 CHECK_EQ(0, r.Call(kMin, -1)); |
2976 CHECK_EQ(0, r.Call(0, 1)); | 2998 CHECK_EQ(0, r.Call(0, 1)); |
2977 CHECK_TRAP(r.Call(100, 0)); | 2999 CHECK_TRAP(r.Call(100, 0)); |
2978 CHECK_TRAP(r.Call(-1001, 0)); | 3000 CHECK_TRAP(r.Call(-1001, 0)); |
2979 CHECK_TRAP(r.Call(kMin, 0)); | 3001 CHECK_TRAP(r.Call(kMin, 0)); |
2980 } | 3002 } |
OLD | NEW |