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

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

Issue 2553123002: [wasm] Honor the names section for modules coming from asm.js. (Closed)
Patch Set: Created 4 years 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 | « no previous file | test/mjsunit/wasm/asm-wasm-names.js » ('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 e8e147e3fea0397986ae0e0e34d9c872e8a7c4d5..39372e03cb5079b1da9e7479e2139b8ee9fe11a9 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -1760,8 +1760,16 @@ class WasmInstanceBuilder {
// Wrap the exported code as a JSFunction.
Handle<Code> export_code =
code_table->GetValueChecked<Code>(isolate_, func_index);
+ Handle<String> func_name = name;
+ if (module_->origin == kAsmJsOrigin) {
+ // For modules arising from asm.js, honor the names section.
+ func_name = ExtractStringFromModuleBytes(
+ isolate_, compiled_module_, function.name_offset,
+ function.name_length)
+ .ToHandleChecked();
+ }
js_function = WasmExportedFunction::New(
- isolate_, instance, name, export_code,
+ isolate_, instance, func_name, export_code,
static_cast<int>(function.sig->parameter_count()),
function.func_index);
js_wrappers_[exp.index] = js_function;
@@ -1913,10 +1921,17 @@ class WasmInstanceBuilder {
Handle<Code> wrapper_code = compiler::CompileJSToWasmWrapper(
isolate_, module_, wasm_code, func_index);
+ Handle<String> func_name = isolate_->factory()->empty_string();
+ if (module_->origin == kAsmJsOrigin) {
+ // For modules arising from asm.js, honor the names section.
+ func_name = ExtractStringFromModuleBytes(
+ isolate_, compiled_module_,
+ function->name_offset, function->name_length)
+ .ToHandleChecked();
+ }
Handle<WasmExportedFunction> js_function =
WasmExportedFunction::New(
- isolate_, instance, isolate_->factory()->empty_string(),
- wrapper_code,
+ isolate_, instance, func_name, wrapper_code,
static_cast<int>(function->sig->parameter_count()),
func_index);
js_wrappers_[func_index] = js_function;
« no previous file with comments | « no previous file | test/mjsunit/wasm/asm-wasm-names.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698