Commit d8217c32 authored by Victor Gomes's avatar Victor Gomes Committed by Commit Bot

[wasm] Remove arguments adaptor frame

Change-Id: I33294dc5b93d5842a3a51779bfec30f20bf4f23f
Bug: v8:10201
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2436345Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70220}
parent f5456f37
......@@ -3423,12 +3423,6 @@ void Builtins::Generate_GenericJSToWasmWrapper(MacroAssembler* masm) {
// IF we have 0 params: jump through parameter handling.
__ j(equal, &prepare_for_wasm_call);
// ELSE:
// Make sure we have the same number of arguments in order to be able to load
// the arguments using static offsets below.
__ cmpl(kJavaScriptCallArgCountRegister, param_count);
__ Check(equal, AbortReason::kInvalidNumberOfJsArgs);
// -------------------------------------------
// Create 2 sections for integer and float params.
// -------------------------------------------
......
......@@ -30,7 +30,6 @@ namespace internal {
V(kInvalidJumpTableIndex, "Invalid jump table index") \
V(kInvalidParametersAndRegistersInGenerator, \
"invalid parameters and registers in generator") \
V(kInvalidNumberOfJsArgs, "Invalid number of JS arguments") \
V(kMissingBytecodeArray, "Missing bytecode array from function") \
V(kObjectNotTagged, "The object is not tagged") \
V(kObjectTagged, "The object is tagged") \
......
......@@ -6664,6 +6664,45 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
args.begin());
break;
}
#ifdef V8_NO_ARGUMENTS_ADAPTOR
// =======================================================================
// === JS Functions with mismatching arity ===============================
// =======================================================================
case WasmImportCallKind::kJSFunctionArityMismatch: {
int pushed_count = std::max(expected_arity, wasm_count);
base::SmallVector<Node*, 16> args(pushed_count + 7);
int pos = 0;
args[pos++] = callable_node; // target callable.
// Determine receiver at runtime.
args[pos++] =
BuildReceiverNode(callable_node, native_context, undefined_node);
// Convert wasm numbers to JS values.
pos = AddArgumentNodes(VectorOf(args), pos, wasm_count, sig_);
for (int i = wasm_count; i < expected_arity; ++i) {
args[pos++] = undefined_node;
}
args[pos++] = undefined_node; // new target
args[pos++] = mcgraph()->Int32Constant(wasm_count); // argument count
Node* function_context =
gasm_->Load(MachineType::TaggedPointer(), callable_node,
wasm::ObjectAccess::ContextOffsetInTaggedJSFunction());
args[pos++] = function_context;
args[pos++] = effect();
args[pos++] = control();
DCHECK_EQ(pos, args.size());
auto call_descriptor = Linkage::GetJSCallDescriptor(
graph()->zone(), false, pushed_count + 1, CallDescriptor::kNoFlags);
call = graph()->NewNode(mcgraph()->common()->Call(call_descriptor), pos,
args.begin());
break;
}
case WasmImportCallKind::kJSFunctionArityMismatchSkipAdaptor:
UNREACHABLE();
#else
// =======================================================================
// === JS Functions with arguments adapter ===============================
// =======================================================================
......@@ -6754,6 +6793,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
args.begin());
break;
}
#endif
// =======================================================================
// === General case of unknown callable ==================================
// =======================================================================
......
......@@ -1074,8 +1074,9 @@ bool InstanceBuilder::ProcessImportedFunction(
// The imported function is a callable.
int expected_arity = static_cast<int>(expected_sig->parameter_count());
if (kind ==
compiler::WasmImportCallKind::kJSFunctionArityMismatchSkipAdaptor) {
if (kind == compiler::WasmImportCallKind::kJSFunctionArityMismatch ||
kind == compiler::WasmImportCallKind::
kJSFunctionArityMismatchSkipAdaptor) {
Handle<JSFunction> function = Handle<JSFunction>::cast(js_receiver);
SharedFunctionInfo shared = function->shared();
expected_arity = shared.internal_formal_parameter_count();
......@@ -1450,6 +1451,8 @@ void InstanceBuilder::CompileImportWrappers(
int expected_arity = static_cast<int>(sig->parameter_count());
if (resolved.first ==
compiler::WasmImportCallKind::kJSFunctionArityMismatch ||
resolved.first ==
compiler::WasmImportCallKind::kJSFunctionArityMismatchSkipAdaptor) {
Handle<JSFunction> function = Handle<JSFunction>::cast(resolved.second);
SharedFunctionInfo shared = function->shared();
......
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