[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: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/main@{#77053}
This commit is contained in:
parent
77ebb4d21a
commit
c5312996f5
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user