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

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

Issue 2174123002: [wasm] Add support for multiple indirect function tables (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix loop bug, cleanups, style Created 4 years, 4 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 10
(...skipping 2389 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 table[] = {0, 1};
2411 module.AddIndirectFunctionTable(table, 2); 2411 module.AddIndirectFunctionTable(table, arraysize(table));
Mircea Trofin 2016/07/26 03:37:27 rename to "indirect_function_table" for clarity
ddchen 2016/07/26 05:44:44 Done.
2412 module.PopulateIndirectFunctionTable(); 2412 module.PopulateIndirectFunctionTable();
2413 2413
2414 // Builder the caller function. 2414 // Builder the caller function.
2415 WasmRunner<int32_t> r(&module, MachineType::Int32()); 2415 WasmRunner<int32_t> r(&module, MachineType::Int32());
2416 BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I8(66), WASM_I8(22))); 2416 BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I8(66), WASM_I8(22)));
2417 2417
2418 CHECK_EQ(88, r.Call(0)); 2418 CHECK_EQ(88, r.Call(0));
2419 CHECK_EQ(44, r.Call(1)); 2419 CHECK_EQ(44, r.Call(1));
2420 CHECK_TRAP(r.Call(2)); 2420 CHECK_TRAP(r.Call(2));
2421 } 2421 }
2422 2422
2423 WASM_EXEC_TEST(MultipleCallIndirect) { 2423 WASM_EXEC_TEST(MultipleCallIndirect) {
2424 TestSignatures sigs; 2424 TestSignatures sigs;
2425 TestingModule module(execution_mode); 2425 TestingModule module(execution_mode);
2426 2426
2427 WasmFunctionCompiler t1(sigs.i_ii(), &module); 2427 WasmFunctionCompiler t1(sigs.i_ii(), &module);
2428 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2428 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2429 t1.CompileAndAdd(/*sig_index*/ 1); 2429 t1.CompileAndAdd(/*sig_index*/ 1);
2430 2430
2431 WasmFunctionCompiler t2(sigs.i_ii(), &module); 2431 WasmFunctionCompiler t2(sigs.i_ii(), &module);
2432 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2432 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2433 t2.CompileAndAdd(/*sig_index*/ 1); 2433 t2.CompileAndAdd(/*sig_index*/ 1);
2434 2434
2435 // Signature table. 2435 // Signature table.
2436 module.AddSignature(sigs.f_ff()); 2436 module.AddSignature(sigs.f_ff());
2437 module.AddSignature(sigs.i_ii()); 2437 module.AddSignature(sigs.i_ii());
2438 module.AddSignature(sigs.d_dd()); 2438 module.AddSignature(sigs.d_dd());
2439 2439
2440 // Function table. 2440 // Function table.
2441 int table[] = {0, 1}; 2441 uint16_t table[] = {0, 1};
Mircea Trofin 2016/07/26 03:37:27 "indirect_function_table"
ddchen 2016/07/26 05:44:44 Done.
2442 module.AddIndirectFunctionTable(table, 2); 2442 module.AddIndirectFunctionTable(table, arraysize(table));
2443 module.PopulateIndirectFunctionTable(); 2443 module.PopulateIndirectFunctionTable();
2444 2444
2445 // Builder the caller function. 2445 // Builder the caller function.
2446 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32(), 2446 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32(),
2447 MachineType::Int32()); 2447 MachineType::Int32());
2448 BUILD(r, WASM_I32_ADD( 2448 BUILD(r, WASM_I32_ADD(
2449 WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1), 2449 WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1),
2450 WASM_GET_LOCAL(2)), 2450 WASM_GET_LOCAL(2)),
2451 WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(1), WASM_GET_LOCAL(2), 2451 WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(1), WASM_GET_LOCAL(2),
2452 WASM_GET_LOCAL(0)))); 2452 WASM_GET_LOCAL(0))));
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
2838 MachineType::Int32()); 2838 MachineType::Int32());
2839 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_ZERO); 2839 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(); 2840 const int32_t kMin = std::numeric_limits<int32_t>::min();
2841 CHECK_EQ(0, r.Call(133, 100)); 2841 CHECK_EQ(0, r.Call(133, 100));
2842 CHECK_EQ(0, r.Call(kMin, -1)); 2842 CHECK_EQ(0, r.Call(kMin, -1));
2843 CHECK_EQ(0, r.Call(0, 1)); 2843 CHECK_EQ(0, r.Call(0, 1));
2844 CHECK_TRAP(r.Call(100, 0)); 2844 CHECK_TRAP(r.Call(100, 0));
2845 CHECK_TRAP(r.Call(-1001, 0)); 2845 CHECK_TRAP(r.Call(-1001, 0));
2846 CHECK_TRAP(r.Call(kMin, 0)); 2846 CHECK_TRAP(r.Call(kMin, 0));
2847 } 2847 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698