Index: src/wasm/wasm-module.cc |
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc |
index 28fdb105dc834cd7a0caf8f26657fa4c5970692d..e7c0a02f9ea1061a3c9e683a91510adc4174dabe 100644 |
--- a/src/wasm/wasm-module.cc |
+++ b/src/wasm/wasm-module.cc |
@@ -556,7 +556,6 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate, |
WasmName str = GetName(func.name_offset, func.name_length); |
WasmName str_null = {nullptr, 0}; |
- Handle<String> name = factory->InternalizeUtf8String(str); |
Handle<Code> code = Handle<Code>::null(); |
Handle<JSFunction> function = Handle<JSFunction>::null(); |
if (func.external) { |
@@ -581,6 +580,7 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate, |
return MaybeHandle<JSObject>(); |
} |
if (func.exported) { |
+ Handle<String> name = factory->InternalizeUtf8String(str); |
function = compiler::CompileJSToWasmWrapper( |
isolate, &module_env, name, code, instance.js_object, i); |
record_code_size(function->code()); |
@@ -592,12 +592,13 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate, |
code_table->set(i, *code); |
record_code_size(*code); |
} |
- if (func.exported) { |
+ if (!function.is_null()) { |
// Exported functions are installed as read-only properties on the |
// module. |
desc.set_value(function); |
Maybe<bool> status = JSReceiver::DefineOwnProperty( |
- isolate, instance.js_object, name, &desc, Object::THROW_ON_ERROR); |
+ isolate, instance.js_object, JSFunction::GetName(function), &desc, |
titzer
2016/05/12 08:29:14
I think it's better to pull out the name handle in
Clemens Hammacher
2016/05/12 11:21:41
Done.
|
+ Object::THROW_ON_ERROR); |
if (!status.IsJust()) |
thrower.Error("export of %.*s failed.", str.length(), str.start()); |
} |