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

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

Issue 2810203002: Revert of [wasm] instantiate expressed in terms of compile (Closed)
Patch Set: Created 3 years, 8 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 | « src/wasm/wasm-module.h ('k') | test/mjsunit/wasm/instantiate-run-basic.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 df99e93e6169db06b8de88febb17d372178c6e5e..40015a70e161c889906896a242e94d7b4fa399b9 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -2604,6 +2604,44 @@
instance_object.ToHandleChecked());
}
+void wasm::AsyncCompileAndInstantiate(Isolate* isolate,
+ Handle<JSPromise> promise,
+ const ModuleWireBytes& bytes,
+ MaybeHandle<JSReceiver> imports) {
+ ErrorThrower thrower(isolate, nullptr);
+
+ // Compile the module.
+ MaybeHandle<WasmModuleObject> module_object =
+ SyncCompile(isolate, &thrower, bytes);
+ if (thrower.error()) {
+ RejectPromise(isolate, handle(isolate->context()), &thrower, promise);
+ return;
+ }
+ Handle<WasmModuleObject> module = module_object.ToHandleChecked();
+
+ // Instantiate the module.
+ MaybeHandle<WasmInstanceObject> instance_object = SyncInstantiate(
+ isolate, &thrower, module, imports, Handle<JSArrayBuffer>::null());
+ if (thrower.error()) {
+ RejectPromise(isolate, handle(isolate->context()), &thrower, promise);
+ return;
+ }
+
+ Handle<JSFunction> object_function =
+ Handle<JSFunction>(isolate->native_context()->object_function(), isolate);
+ Handle<JSObject> ret =
+ isolate->factory()->NewJSObject(object_function, TENURED);
+ Handle<String> module_property_name =
+ isolate->factory()->InternalizeUtf8String("module");
+ Handle<String> instance_property_name =
+ isolate->factory()->InternalizeUtf8String("instance");
+ JSObject::AddProperty(ret, module_property_name, module, NONE);
+ JSObject::AddProperty(ret, instance_property_name,
+ instance_object.ToHandleChecked(), NONE);
+
+ ResolvePromise(isolate, handle(isolate->context()), promise, ret);
+}
+
// Encapsulates all the state and steps of an asynchronous compilation.
// An asynchronous compile job consists of a number of tasks that are executed
// as foreground and background tasks. Any phase that touches the V8 heap or
« no previous file with comments | « src/wasm/wasm-module.h ('k') | test/mjsunit/wasm/instantiate-run-basic.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698