Chromium Code Reviews| Index: src/wasm/wasm-js.cc |
| diff --git a/src/wasm/wasm-js.cc b/src/wasm/wasm-js.cc |
| index 732751610587bfb64d23563d36f5371e2d746a69..2f75bae15af4976baf1edc69bb2e23d67f8055fb 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 |
| @@ -211,6 +211,12 @@ MaybeLocal<Value> InstantiateModuleImpl( |
| Local<Object> obj = Local<Object>::Cast(args[kFfiOffset]); |
| ffi = i::Handle<i::JSReceiver>::cast(v8::Utils::OpenHandle(*obj)); |
| } |
| + if (!i_module_obj->compiled_module()->module()->import_table.empty() && |
|
titzer
2017/01/13 16:47:02
I think it's better if we don't reach into the imp
Mircea Trofin
2017/01/13 17:02:56
OK, but I'd prefer doing it as early as possible -
|
| + ffi.is_null()) { |
| + thrower->TypeError("Argument %d must be present and must be an object", |
| + kFfiOffset); |
| + return nothing; |
| + } |
| i::Handle<i::JSArrayBuffer> memory = i::Handle<i::JSArrayBuffer>::null(); |
| if (args.Length() > kMemOffset && !args[kMemOffset]->IsUndefined()) { |
| @@ -321,8 +327,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 +349,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(); |