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

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

Issue 2629523007: [wasm] JS-API: enable WebAssembly.instantiate tests; fix LinkError (Closed)
Patch Set: initialize module_ upfront Created 3 years, 11 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
Index: src/wasm/wasm-js.cc
diff --git a/src/wasm/wasm-js.cc b/src/wasm/wasm-js.cc
index 732751610587bfb64d23563d36f5371e2d746a69..dc259f34923ff76e763c081af8346561cff92957 100644
--- a/src/wasm/wasm-js.cc
+++ b/src/wasm/wasm-js.cc
@@ -192,7 +192,7 @@ void WebAssemblyModule(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
MaybeLocal<Value> InstantiateModuleImpl(
- i::Isolate* i_isolate, i::Handle<i::JSObject> i_module_obj,
+ i::Isolate* i_isolate, i::Handle<i::WasmModuleObject> i_module_obj,
const v8::FunctionCallbackInfo<v8::Value>& args, ErrorThrower* thrower) {
// It so happens that in both the WebAssembly.instantiate, as well as
// WebAssembly.Instance ctor, the positions of the ffi object and memory
@@ -203,6 +203,10 @@ MaybeLocal<Value> InstantiateModuleImpl(
MaybeLocal<Value> nothing;
i::Handle<i::JSReceiver> ffi = i::Handle<i::JSObject>::null();
+ // This is a first - level validation of the argument. If present, we only
+ // check its type. {Instantiate} will further check that if the module
+ // has imports, the argument must be present, as well as piecemeal
+ // import satisfaction.
if (args.Length() > kFfiOffset && !args[kFfiOffset]->IsUndefined()) {
if (!args[kFfiOffset]->IsObject()) {
thrower->TypeError("Argument %d must be an object", kFfiOffset);
@@ -212,6 +216,7 @@ MaybeLocal<Value> InstantiateModuleImpl(
ffi = i::Handle<i::JSReceiver>::cast(v8::Utils::OpenHandle(*obj));
}
+ // The memory argument is a legacy, not spec - compliant artifact.
i::Handle<i::JSArrayBuffer> memory = i::Handle<i::JSArrayBuffer>::null();
if (args.Length() > kMemOffset && !args[kMemOffset]->IsUndefined()) {
if (!args[kMemOffset]->IsObject()) {
@@ -321,8 +326,8 @@ void WebAssemblyInstance(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
Local<Object> module_obj = Local<Object>::Cast(args[0]);
- i::Handle<i::JSObject> i_module_obj =
- i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*module_obj));
+ i::Handle<i::WasmModuleObject> i_module_obj =
+ i::Handle<i::WasmModuleObject>::cast(v8::Utils::OpenHandle(*module_obj));
MaybeLocal<Value> instance =
InstantiateModuleImpl(i_isolate, i_module_obj, args, &thrower);
@@ -343,7 +348,7 @@ void WebAssemblyInstantiate(const v8::FunctionCallbackInfo<v8::Value>& args) {
thrower.TypeError("Argument 0 must be a buffer source");
return;
}
- i::MaybeHandle<i::JSObject> module_obj =
+ i::MaybeHandle<i::WasmModuleObject> module_obj =
CreateModuleObject(isolate, args[0], &thrower);
Local<Context> context = isolate->GetCurrentContext();
« no previous file with comments | « src/asmjs/asm-js.cc ('k') | src/wasm/wasm-module.h » ('j') | test/mjsunit/wasm/js-api.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698