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

Unified Diff: src/wasm/wasm-module.cc

Issue 1912103002: [wasm] Store function names in the wasm object (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm-offset-table-2
Patch Set: rebase Created 4 years, 8 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/wasm-module.h ('k') | test/cctest/wasm/wasm-run-utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-module.cc
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc
index a02bb2a3c32796b8e4ee758345df288674502c44..0e154016231ef4dd35877ceae7c3ec203978fb04 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -11,6 +11,7 @@
#include "src/wasm/ast-decoder.h"
#include "src/wasm/module-decoder.h"
+#include "src/wasm/wasm-function-name-table.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-result.h"
@@ -201,11 +202,12 @@ class WasmLinker {
namespace {
// Internal constants for the layout of the module object.
-const int kWasmModuleInternalFieldCount = 4;
+const int kWasmModuleInternalFieldCount = 5;
const int kWasmModuleFunctionTable = 0;
const int kWasmModuleCodeTable = 1;
const int kWasmMemArrayBuffer = 2;
const int kWasmGlobalsArrayBuffer = 3;
+const int kWasmFunctionNamesArray = 4;
size_t AllocateGlobalsOffsets(std::vector<WasmGlobal>& globals) {
uint32_t offset = 0;
@@ -630,6 +632,15 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
}
}
+ //-------------------------------------------------------------------------
+ // Attach an array with function names and an array with offsets into that
+ // first array.
+ //-------------------------------------------------------------------------
+ {
+ Handle<Object> arr = BuildFunctionNamesTable(isolate, module_env.module);
+ instance.js_object->SetInternalField(kWasmFunctionNamesArray, *arr);
+ }
+
if (FLAG_print_wasm_code_size)
printf("Total generated wasm code: %u bytes\n", total_code_size);
@@ -783,6 +794,16 @@ int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module) {
thrower.Error("WASM.compileRun() failed: Return value should be number");
return -1;
}
+
+Handle<Object> GetWasmFunctionName(Handle<JSObject> wasm, uint32_t func_index) {
+ Handle<Object> func_names_arr_obj = handle(
+ wasm->GetInternalField(kWasmFunctionNamesArray), wasm->GetIsolate());
+ if (func_names_arr_obj->IsUndefined())
+ return func_names_arr_obj; // Return undefined.
+ return GetWasmFunctionNameFromTable(
+ Handle<ByteArray>::cast(func_names_arr_obj), func_index);
+}
+
} // namespace wasm
} // namespace internal
} // namespace v8
« no previous file with comments | « src/wasm/wasm-module.h ('k') | test/cctest/wasm/wasm-run-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698