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

Unified Diff: test/cctest/wasm/wasm-run-utils.h

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 | « test/cctest/wasm/test-signatures.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/wasm/wasm-run-utils.h
diff --git a/test/cctest/wasm/wasm-run-utils.h b/test/cctest/wasm/wasm-run-utils.h
index cc23b46b732365446c8bdb75e4de80ba372104a0..ccf76f945ff6e42dbf966879050f4bf4eb0daad4 100644
--- a/test/cctest/wasm/wasm-run-utils.h
+++ b/test/cctest/wasm/wasm-run-utils.h
@@ -168,6 +168,30 @@ class TestingModule : public ModuleEnv {
return &module->functions->back();
}
+ void AddIndirectFunctionTable(int* functions, int table_size) {
+ AllocModule();
+ Isolate* isolate = module->shared_isolate;
+ Handle<FixedArray> fixed =
+ isolate->factory()->NewFixedArray(2 * table_size);
+ function_table = fixed;
+ module->function_table = new std::vector<uint16_t>();
+ for (int i = 0; i < table_size; i++) {
+ module->function_table->push_back(functions[i]);
+ }
+ }
+
+ void PopulateIndirectFunctionTable() {
+ if (function_table.is_null()) return;
+ int table_size = static_cast<int>(module->function_table->size());
+ for (int i = 0; i < table_size; i++) {
+ int function_index = module->function_table->at(i);
+ WasmFunction* function = &module->functions->at(function_index);
+ function_table->set(i, Smi::FromInt(function->sig_index));
+ function_table->set(i + table_size, *function_code->at(function_index));
+ }
+ }
+
+
private:
size_t mem_size;
uint32_t global_offset;
@@ -271,12 +295,13 @@ class WasmFunctionCompiler : public HandleAndZoneScope,
return result;
}
- uint32_t CompileAndAdd(TestingModule* module) {
+ uint32_t CompileAndAdd(TestingModule* module, int sig_index = 0) {
uint32_t index = 0;
if (module->module && module->module->functions) {
index = static_cast<uint32_t>(module->module->functions->size());
}
- module->AddFunction(env.sig, Compile(module));
+ WasmFunction* function = module->AddFunction(env.sig, Compile(module));
+ function->sig_index = sig_index;
return index;
}
};
« no previous file with comments | « test/cctest/wasm/test-signatures.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698