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

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

Issue 2484623002: [wasm] Indirect calls without function table cause validation errors. (Closed)
Patch Set: try to export symbols Created 4 years, 1 month 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/signature-map.h ('k') | test/mjsunit/wasm/trap-location.js » ('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 #include "src/utils.h" 10 #include "src/utils.h"
(...skipping 2654 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
2697 WASM_EXEC_TEST(CallIndirect_EmptyTable) { 2675 WASM_EXEC_TEST(CallIndirect_EmptyTable) {
2698 TestSignatures sigs; 2676 TestSignatures sigs;
2699 TestingModule module(execution_mode); 2677 TestingModule module(execution_mode);
2700 2678
2701 // One function. 2679 // One function.
2702 WasmFunctionCompiler t1(sigs.i_ii(), &module); 2680 WasmFunctionCompiler t1(sigs.i_ii(), &module);
2703 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2681 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2704 t1.CompileAndAdd(/*sig_index*/ 1); 2682 t1.CompileAndAdd(/*sig_index*/ 1);
2705 2683
2706 // Signature table. 2684 // Signature table.
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
2993 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_DROP, 2971 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_DROP,
2994 WASM_ZERO); 2972 WASM_ZERO);
2995 const int32_t kMin = std::numeric_limits<int32_t>::min(); 2973 const int32_t kMin = std::numeric_limits<int32_t>::min();
2996 CHECK_EQ(0, r.Call(133, 100)); 2974 CHECK_EQ(0, r.Call(133, 100));
2997 CHECK_EQ(0, r.Call(kMin, -1)); 2975 CHECK_EQ(0, r.Call(kMin, -1));
2998 CHECK_EQ(0, r.Call(0, 1)); 2976 CHECK_EQ(0, r.Call(0, 1));
2999 CHECK_TRAP(r.Call(100, 0)); 2977 CHECK_TRAP(r.Call(100, 0));
3000 CHECK_TRAP(r.Call(-1001, 0)); 2978 CHECK_TRAP(r.Call(-1001, 0));
3001 CHECK_TRAP(r.Call(kMin, 0)); 2979 CHECK_TRAP(r.Call(kMin, 0));
3002 } 2980 }
OLDNEW
« no previous file with comments | « src/wasm/signature-map.h ('k') | test/mjsunit/wasm/trap-location.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698