[wasm] Fix expected arity in ImportWasmJSFunctionIntoTable

Change-Id: If9ab58bf671567f7a035a03b3e4e772ba302b522
Bug: v8:10201
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2467843
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70487}
This commit is contained in:
Victor Gomes 2020-10-13 16:42:36 +02:00 committed by Commit Bot
parent 4c39f1decc
commit d73c32b9f7

View File

@ -1508,10 +1508,18 @@ void WasmInstanceObject::ImportWasmJSFunctionIntoTable(
callable = resolved.second; // Update to ultimate target.
DCHECK_NE(compiler::WasmImportCallKind::kLinkError, kind);
wasm::CompilationEnv env = native_module->CreateCompilationEnv();
SharedFunctionInfo shared = js_function->shared();
// {expected_arity} should only be used if kind != kJSFunctionArityMismatch
// or kind != kJSFunctionArityMismatchSkipAdaptor.
int expected_arity = -1;
if (kind == compiler::WasmImportCallKind ::kJSFunctionArityMismatch ||
kind == compiler::WasmImportCallKind ::
kJSFunctionArityMismatchSkipAdaptor) {
expected_arity = Handle<JSFunction>::cast(callable)
->shared()
.internal_formal_parameter_count();
}
wasm::WasmCompilationResult result = compiler::CompileWasmImportCallWrapper(
isolate->wasm_engine(), &env, kind, sig, false,
shared.internal_formal_parameter_count());
isolate->wasm_engine(), &env, kind, sig, false, expected_arity);
std::unique_ptr<wasm::WasmCode> wasm_code = native_module->AddCode(
result.func_index, result.code_desc, result.frame_slot_count,
result.tagged_parameter_slots,