Commit 400b01ff authored by titzer's avatar titzer Committed by Commit bot

[wasm] Honor the names section for modules coming from asm.js.

R=bradnelson@chromium.org,clemensh@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2553123002
Cr-Commit-Position: refs/heads/master@{#41528}
parent a9017cb0
......@@ -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;
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --validate-asm
function Module(stdlib, foreign, buffer) {
"use asm";
function foo() {}
return {bar: foo};
}
var func = Module({}, {}, new ArrayBuffer(65536)).bar;
assertEquals("Module", Module.name);
assertEquals("foo", func.name);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment