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

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

Issue 2403093002: [wasm] Canonicalize function signature indices for matching in indirect calls. (Closed)
Patch Set: Add TODO for myself Created 4 years, 2 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
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 2614 matching lines...) Expand 10 before | Expand all | Expand 10 after
2625 2625
2626 // Builder the caller function. 2626 // Builder the caller function.
2627 WasmRunner<int32_t> r(&module, MachineType::Int32()); 2627 WasmRunner<int32_t> r(&module, MachineType::Int32());
2628 BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I8(66), WASM_I8(22))); 2628 BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I8(66), WASM_I8(22)));
2629 2629
2630 CHECK_TRAP(r.Call(0)); 2630 CHECK_TRAP(r.Call(0));
2631 CHECK_TRAP(r.Call(1)); 2631 CHECK_TRAP(r.Call(1));
2632 CHECK_TRAP(r.Call(2)); 2632 CHECK_TRAP(r.Call(2));
2633 } 2633 }
2634 2634
2635 WASM_EXEC_TEST(CallIndirect_canonical) {
2636 TestSignatures sigs;
2637 TestingModule module(execution_mode);
2638
2639 WasmFunctionCompiler t1(sigs.i_ii(), &module);
2640 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2641 t1.CompileAndAdd(/*sig_index*/ 0);
2642
2643 WasmFunctionCompiler t2(sigs.i_ii(), &module);
2644 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2645 t2.CompileAndAdd(/*sig_index*/ 1);
2646
2647 // Signature table.
2648 module.AddSignature(sigs.i_ii());
2649 module.AddSignature(sigs.i_ii());
2650
2651 // Function table.
2652 uint16_t indirect_function_table[] = {0, 1, 0, 1};
2653 module.AddIndirectFunctionTable(indirect_function_table,
2654 arraysize(indirect_function_table));
2655 module.PopulateIndirectFunctionTable();
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(77), WASM_I8(11)));
2660
2661 CHECK_EQ(88, r.Call(0));
2662 CHECK_EQ(66, r.Call(1));
2663 CHECK_EQ(88, r.Call(2));
2664 CHECK_EQ(66, r.Call(3));
2665 CHECK_TRAP(r.Call(4));
2666 }
2667
2635 WASM_EXEC_TEST(F32Floor) { 2668 WASM_EXEC_TEST(F32Floor) {
2636 WasmRunner<float> r(execution_mode, MachineType::Float32()); 2669 WasmRunner<float> r(execution_mode, MachineType::Float32());
2637 BUILD(r, WASM_F32_FLOOR(WASM_GET_LOCAL(0))); 2670 BUILD(r, WASM_F32_FLOOR(WASM_GET_LOCAL(0)));
2638 2671
2639 FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(floorf(*i), r.Call(*i)); } 2672 FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(floorf(*i), r.Call(*i)); }
2640 } 2673 }
2641 2674
2642 WASM_EXEC_TEST(F32Ceil) { 2675 WASM_EXEC_TEST(F32Ceil) {
2643 WasmRunner<float> r(execution_mode, MachineType::Float32()); 2676 WasmRunner<float> r(execution_mode, MachineType::Float32());
2644 BUILD(r, WASM_F32_CEIL(WASM_GET_LOCAL(0))); 2677 BUILD(r, WASM_F32_CEIL(WASM_GET_LOCAL(0)));
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2865 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_DROP, 2898 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_DROP,
2866 WASM_ZERO); 2899 WASM_ZERO);
2867 const int32_t kMin = std::numeric_limits<int32_t>::min(); 2900 const int32_t kMin = std::numeric_limits<int32_t>::min();
2868 CHECK_EQ(0, r.Call(133, 100)); 2901 CHECK_EQ(0, r.Call(133, 100));
2869 CHECK_EQ(0, r.Call(kMin, -1)); 2902 CHECK_EQ(0, r.Call(kMin, -1));
2870 CHECK_EQ(0, r.Call(0, 1)); 2903 CHECK_EQ(0, r.Call(0, 1));
2871 CHECK_TRAP(r.Call(100, 0)); 2904 CHECK_TRAP(r.Call(100, 0));
2872 CHECK_TRAP(r.Call(-1001, 0)); 2905 CHECK_TRAP(r.Call(-1001, 0));
2873 CHECK_TRAP(r.Call(kMin, 0)); 2906 CHECK_TRAP(r.Call(kMin, 0));
2874 } 2907 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698