Commit ca03447c authored by gdeepti's avatar gdeepti Committed by Commit bot

[wasm] Internal Instantiate function should not take memory as an arg from wasm

BUG=5823

R=bradnelson@chromium.org

Review-Url: https://codereview.chromium.org/2636803002
Cr-Commit-Position: refs/heads/master@{#42355}
parent 11cf1466
...@@ -195,7 +195,6 @@ MaybeLocal<Value> InstantiateModuleImpl( ...@@ -195,7 +195,6 @@ MaybeLocal<Value> InstantiateModuleImpl(
// are the same. If that changes later, we refactor the consts into // are the same. If that changes later, we refactor the consts into
// parameters. // parameters.
static const int kFfiOffset = 1; static const int kFfiOffset = 1;
static const int kMemOffset = 2;
MaybeLocal<Value> nothing; MaybeLocal<Value> nothing;
i::Handle<i::JSReceiver> ffi = i::Handle<i::JSObject>::null(); i::Handle<i::JSReceiver> ffi = i::Handle<i::JSObject>::null();
...@@ -212,26 +211,8 @@ MaybeLocal<Value> InstantiateModuleImpl( ...@@ -212,26 +211,8 @@ MaybeLocal<Value> InstantiateModuleImpl(
ffi = i::Handle<i::JSReceiver>::cast(v8::Utils::OpenHandle(*obj)); ffi = i::Handle<i::JSReceiver>::cast(v8::Utils::OpenHandle(*obj));
} }
// The memory argument is a legacy, not spec - compliant artifact. i::MaybeHandle<i::JSObject> instance =
i::Handle<i::JSArrayBuffer> memory = i::Handle<i::JSArrayBuffer>::null(); i::wasm::WasmModule::Instantiate(i_isolate, thrower, i_module_obj, ffi);
if (args.Length() > kMemOffset && !args[kMemOffset]->IsUndefined()) {
if (!args[kMemOffset]->IsObject()) {
thrower->TypeError("Argument %d must be a WebAssembly.Memory",
kMemOffset);
return nothing;
}
Local<Object> obj = Local<Object>::Cast(args[kMemOffset]);
i::Handle<i::Object> mem_obj = v8::Utils::OpenHandle(*obj);
if (!i::WasmJs::IsWasmMemoryObject(i_isolate, mem_obj)) {
thrower->TypeError("Argument %d must be a WebAssembly.Memory",
kMemOffset);
return nothing;
}
memory = i::Handle<i::JSArrayBuffer>(
i::Handle<i::WasmMemoryObject>::cast(mem_obj)->buffer(), i_isolate);
}
i::MaybeHandle<i::JSObject> instance = i::wasm::WasmModule::Instantiate(
i_isolate, thrower, i_module_obj, ffi, memory);
if (instance.is_null()) { if (instance.is_null()) {
if (!thrower->error()) if (!thrower->error())
thrower->RuntimeError("Could not instantiate module"); thrower->RuntimeError("Could not instantiate module");
......
...@@ -218,7 +218,7 @@ struct V8_EXPORT_PRIVATE WasmModule { ...@@ -218,7 +218,7 @@ struct V8_EXPORT_PRIVATE WasmModule {
static MaybeHandle<WasmInstanceObject> Instantiate( static MaybeHandle<WasmInstanceObject> Instantiate(
Isolate* isolate, ErrorThrower* thrower, Isolate* isolate, ErrorThrower* thrower,
Handle<WasmModuleObject> wasm_module, Handle<JSReceiver> ffi, Handle<WasmModuleObject> wasm_module, Handle<JSReceiver> ffi,
Handle<JSArrayBuffer> memory); Handle<JSArrayBuffer> memory = Handle<JSArrayBuffer>::null());
MaybeHandle<WasmCompiledModule> CompileFunctions( MaybeHandle<WasmCompiledModule> CompileFunctions(
Isolate* isolate, Handle<Managed<WasmModule>> module_wrapper, Isolate* isolate, Handle<Managed<WasmModule>> module_wrapper,
......
...@@ -66,9 +66,9 @@ const Handle<WasmInstanceObject> InstantiateModuleForTesting( ...@@ -66,9 +66,9 @@ const Handle<WasmInstanceObject> InstantiateModuleForTesting(
thrower->CompileError("Module pre-validation failed."); thrower->CompileError("Module pre-validation failed.");
return Handle<WasmInstanceObject>::null(); return Handle<WasmInstanceObject>::null();
} }
MaybeHandle<WasmInstanceObject> maybe_instance = WasmModule::Instantiate( MaybeHandle<WasmInstanceObject> maybe_instance =
isolate, thrower, module_object.ToHandleChecked(), WasmModule::Instantiate(isolate, thrower, module_object.ToHandleChecked(),
Handle<JSReceiver>::null(), Handle<JSArrayBuffer>::null()); Handle<JSReceiver>::null());
Handle<WasmInstanceObject> instance; Handle<WasmInstanceObject> instance;
if (!maybe_instance.ToHandle(&instance)) { if (!maybe_instance.ToHandle(&instance)) {
return Handle<WasmInstanceObject>::null(); return Handle<WasmInstanceObject>::null();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment