Index: src/asmjs/asm-js.cc |
diff --git a/src/asmjs/asm-js.cc b/src/asmjs/asm-js.cc |
index be542c7613903e03cf65f6a392b93de30701b750..31a2337f450ccd84b5f82df8a7df6afff2f33ace 100644 |
--- a/src/asmjs/asm-js.cc |
+++ b/src/asmjs/asm-js.cc |
@@ -212,12 +212,12 @@ MaybeHandle<Object> AsmJs::InstantiateAsmWasm(i::Isolate* isolate, |
return MaybeHandle<Object>(); |
} |
- i::Handle<i::Name> name(isolate->factory()->InternalizeOneByteString( |
- STATIC_CHAR_VECTOR("__foreign_init__"))); |
+ i::Handle<i::Name> init_name(isolate->factory()->InternalizeUtf8String( |
+ wasm::AsmWasmBuilder::foreign_init_name)); |
i::Handle<i::Object> module_object = maybe_module_object.ToHandleChecked(); |
i::MaybeHandle<i::Object> maybe_init = |
- i::Object::GetProperty(module_object, name); |
+ i::Object::GetProperty(module_object, init_name); |
DCHECK(!maybe_init.is_null()); |
i::Handle<i::Object> init = maybe_init.ToHandleChecked(); |
@@ -242,10 +242,18 @@ MaybeHandle<Object> AsmJs::InstantiateAsmWasm(i::Isolate* isolate, |
i::MaybeHandle<i::Object> retval = i::Execution::Call( |
isolate, init, undefined, foreign_globals->length(), foreign_args_array); |
delete[] foreign_args_array; |
- |
DCHECK(!retval.is_null()); |
- return maybe_module_object; |
+ i::Handle<i::Name> single_function_name( |
+ isolate->factory()->InternalizeUtf8String( |
+ wasm::AsmWasmBuilder::single_function_name)); |
+ i::MaybeHandle<i::Object> single_function = |
+ i::Object::GetProperty(module_object, single_function_name); |
+ if (!single_function.is_null() && |
+ !single_function.ToHandleChecked()->IsUndefined(isolate)) { |
+ return single_function; |
+ } |
+ return module_object; |
} |
} // namespace internal |