Commit c5312996 authored by Andreas Haas's avatar Andreas Haas Committed by V8 LUCI CQ

[cleanup] Refactor WebAssemblyInstance() to avoid variable shadowing

R=jkummerow@chromium.org

Bug: v8:12244
Change-Id: I6264a91caa1f961ea1fa27c372c53240d969e91a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3181527
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77053}
parent 77ebb4d2
......@@ -795,32 +795,27 @@ void WebAssemblyInstance(const v8::FunctionCallbackInfo<v8::Value>& args) {
HandleScope scope(args.GetIsolate());
if (i_isolate->wasm_instance_callback()(args)) return;
ScheduledErrorThrower thrower(i_isolate, "WebAssembly.Instance()");
if (!args.IsConstructCall()) {
thrower.TypeError("WebAssembly.Instance must be invoked with 'new'");
return;
}
GetFirstArgumentAsModule(args, &thrower);
if (thrower.error()) return;
i::MaybeHandle<i::JSObject> maybe_instance_obj;
{
ScheduledErrorThrower thrower(i_isolate, "WebAssembly.Instance()");
i::Handle<i::Object> module_obj = Utils::OpenHandle(*args[0]);
if (!module_obj->IsWasmModuleObject()) {
thrower.TypeError("Argument 0 must be a WebAssembly.Module object");
if (!args.IsConstructCall()) {
thrower.TypeError("WebAssembly.Instance must be invoked with 'new'");
return;
}
i::MaybeHandle<i::WasmModuleObject> maybe_module =
GetFirstArgumentAsModule(args, &thrower);
if (thrower.error()) return;
i::Handle<i::WasmModuleObject> module_obj = maybe_module.ToHandleChecked();
i::MaybeHandle<i::JSReceiver> maybe_imports =
GetValueAsImports(args[1], &thrower);
if (thrower.error()) return;
maybe_instance_obj = i::wasm::GetWasmEngine()->SyncInstantiate(
i_isolate, &thrower, i::Handle<i::WasmModuleObject>::cast(module_obj),
maybe_imports, i::MaybeHandle<i::JSArrayBuffer>());
i_isolate, &thrower, module_obj, maybe_imports,
i::MaybeHandle<i::JSArrayBuffer>());
}
i::Handle<i::JSObject> instance_obj;
......
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