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

Unified Diff: test/cctest/wasm/test-run-wasm.cc

Issue 1616973004: [wasm] Add utilities to print out WASM ast directly from the bytes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix arm64, use AddIndirectFunctionTable() more. Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/ast-decoder.cc ('k') | test/cctest/wasm/test-signatures.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/wasm/test-run-wasm.cc
diff --git a/test/cctest/wasm/test-run-wasm.cc b/test/cctest/wasm/test-run-wasm.cc
index 4873f570b72eecb66b367cebca7e68c7670a0d8d..2df1516bcb138ee491e06fbbc1c5a34dde986caf 100644
--- a/test/cctest/wasm/test-run-wasm.cc
+++ b/test/cctest/wasm/test-run-wasm.cc
@@ -2837,19 +2837,17 @@ TEST(Run_Wasm_LoadStoreI64_sx) {
TEST(Run_Wasm_SimpleCallIndirect) {
- Isolate* isolate = CcTest::InitIsolateOnce();
-
WasmRunner<int32_t> r(MachineType::Int32());
TestSignatures sigs;
TestingModule module;
r.env()->module = &module;
WasmFunctionCompiler t1(sigs.i_ii());
BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
- t1.CompileAndAdd(&module);
+ t1.CompileAndAdd(&module, /*sig_index*/ 1);
WasmFunctionCompiler t2(sigs.i_ii());
BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
- t2.CompileAndAdd(&module);
+ t2.CompileAndAdd(&module, /*sig_index*/ 1);
// Signature table.
module.AddSignature(sigs.f_ff());
@@ -2857,18 +2855,9 @@ TEST(Run_Wasm_SimpleCallIndirect) {
module.AddSignature(sigs.d_dd());
// Function table.
- int table_size = 2;
- module.module->function_table = new std::vector<uint16_t>;
- module.module->function_table->push_back(0);
- module.module->function_table->push_back(1);
-
- // Function table.
- Handle<FixedArray> fixed = isolate->factory()->NewFixedArray(2 * table_size);
- fixed->set(0, Smi::FromInt(1));
- fixed->set(1, Smi::FromInt(1));
- fixed->set(2, *module.function_code->at(0));
- fixed->set(3, *module.function_code->at(1));
- module.function_table = fixed;
+ int table[] = {0, 1};
+ module.AddIndirectFunctionTable(table, 2);
+ module.PopulateIndirectFunctionTable();
// Builder the caller function.
BUILD(r, WASM_CALL_INDIRECT(1, WASM_GET_LOCAL(0), WASM_I8(66), WASM_I8(22)));
@@ -2880,8 +2869,6 @@ TEST(Run_Wasm_SimpleCallIndirect) {
TEST(Run_Wasm_MultipleCallIndirect) {
- Isolate* isolate = CcTest::InitIsolateOnce();
-
WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32(),
MachineType::Int32());
TestSignatures sigs;
@@ -2889,11 +2876,11 @@ TEST(Run_Wasm_MultipleCallIndirect) {
r.env()->module = &module;
WasmFunctionCompiler t1(sigs.i_ii());
BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
- t1.CompileAndAdd(&module);
+ t1.CompileAndAdd(&module, /*sig_index*/ 1);
WasmFunctionCompiler t2(sigs.i_ii());
BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
- t2.CompileAndAdd(&module);
+ t2.CompileAndAdd(&module, /*sig_index*/ 1);
// Signature table.
module.AddSignature(sigs.f_ff());
@@ -2901,18 +2888,9 @@ TEST(Run_Wasm_MultipleCallIndirect) {
module.AddSignature(sigs.d_dd());
// Function table.
- int table_size = 2;
- module.module->function_table = new std::vector<uint16_t>;
- module.module->function_table->push_back(0);
- module.module->function_table->push_back(1);
-
- // Function table.
- Handle<FixedArray> fixed = isolate->factory()->NewFixedArray(2 * table_size);
- fixed->set(0, Smi::FromInt(1));
- fixed->set(1, Smi::FromInt(1));
- fixed->set(2, *module.function_code->at(0));
- fixed->set(3, *module.function_code->at(1));
- module.function_table = fixed;
+ int table[] = {0, 1};
+ module.AddIndirectFunctionTable(table, 2);
+ module.PopulateIndirectFunctionTable();
// Builder the caller function.
BUILD(r,
@@ -3275,4 +3253,49 @@ TEST(Run_Wasm_F32CopySign) {
}
}
+
+#endif
+
+
+void CompileCallIndirectMany(LocalType param) {
+ // Make sure we don't run out of registers when compiling indirect calls
+ // with many many parameters.
+ TestSignatures sigs;
+ for (byte num_params = 0; num_params < 40; num_params++) {
+ Zone zone;
+ HandleScope scope(CcTest::InitIsolateOnce());
+ TestingModule module;
+ FunctionSig* sig = sigs.many(&zone, kAstStmt, param, num_params);
+
+ module.AddSignature(sig);
+ module.AddSignature(sig);
+ module.AddIndirectFunctionTable(nullptr, 0);
+
+ WasmFunctionCompiler t(sig);
+ t.env.module = &module;
+
+ std::vector<byte> code;
+ ADD_CODE(code, kExprCallIndirect, 1);
+ ADD_CODE(code, kExprI8Const, 0);
+ for (byte p = 0; p < num_params; p++) {
+ ADD_CODE(code, kExprGetLocal, p);
+ }
+
+ t.Build(&code[0], &code[0] + code.size());
+ t.Compile(&module);
+ }
+}
+
+
+TEST(Compile_Wasm_CallIndirect_Many_i32) { CompileCallIndirectMany(kAstI32); }
+
+
+#if WASM_64
+TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); }
#endif
+
+
+TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); }
+
+
+TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); }
« no previous file with comments | « src/wasm/ast-decoder.cc ('k') | test/cctest/wasm/test-signatures.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698