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

Unified Diff: src/asmjs/asm-js.cc

Issue 2348383003: [wasm] Support asm.js modules with a single function. (Closed)
Patch Set: fix Created 4 years, 3 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 | « no previous file | src/asmjs/asm-wasm-builder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | src/asmjs/asm-wasm-builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698