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(
// are the same. If that changes later, we refactor the consts into
// parameters.
static const int kFfiOffset = 1;
static const int kMemOffset = 2;
MaybeLocal<Value> nothing;
i::Handle<i::JSReceiver> ffi = i::Handle<i::JSObject>::null();
......@@ -212,26 +211,8 @@ 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()) {
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);
i::MaybeHandle<i::JSObject> instance =
i::wasm::WasmModule::Instantiate(i_isolate, thrower, i_module_obj, ffi);
if (instance.is_null()) {
if (!thrower->error())
thrower->RuntimeError("Could not instantiate module");
......
......@@ -218,7 +218,7 @@ struct V8_EXPORT_PRIVATE WasmModule {
static MaybeHandle<WasmInstanceObject> Instantiate(
Isolate* isolate, ErrorThrower* thrower,
Handle<WasmModuleObject> wasm_module, Handle<JSReceiver> ffi,
Handle<JSArrayBuffer> memory);
Handle<JSArrayBuffer> memory = Handle<JSArrayBuffer>::null());
MaybeHandle<WasmCompiledModule> CompileFunctions(
Isolate* isolate, Handle<Managed<WasmModule>> module_wrapper,
......
......@@ -66,9 +66,9 @@ const Handle<WasmInstanceObject> InstantiateModuleForTesting(
thrower->CompileError("Module pre-validation failed.");
return Handle<WasmInstanceObject>::null();
}
MaybeHandle<WasmInstanceObject> maybe_instance = WasmModule::Instantiate(
isolate, thrower, module_object.ToHandleChecked(),
Handle<JSReceiver>::null(), Handle<JSArrayBuffer>::null());
MaybeHandle<WasmInstanceObject> maybe_instance =
WasmModule::Instantiate(isolate, thrower, module_object.ToHandleChecked(),
Handle<JSReceiver>::null());
Handle<WasmInstanceObject> instance;
if (!maybe_instance.ToHandle(&instance)) {
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