| Index: src/compiler/js-typed-lowering.cc
|
| diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
|
| index ed8f3b0dae4afa3f5db2af01cef9c10f2d79852d..7f50ac8b7f7b55734c7a9b7e38a761a0a79aaac8 100644
|
| --- a/src/compiler/js-typed-lowering.cc
|
| +++ b/src/compiler/js-typed-lowering.cc
|
| @@ -1542,16 +1542,18 @@ void ReduceBuiltin(Isolate* isolate, JSGraph* jsgraph, Node* node,
|
| const int argc = arity + BuiltinArguments::kNumExtraArgsWithReceiver;
|
| Node* argc_node = jsgraph->Int32Constant(argc);
|
|
|
| - node->InsertInput(zone, arity + 2, argc_node);
|
| - node->InsertInput(zone, arity + 3, target);
|
| - node->InsertInput(zone, arity + 4, new_target);
|
| + static const int kStubAndReceiver = 2;
|
| + int cursor = arity + kStubAndReceiver;
|
| + node->InsertInput(zone, cursor++, argc_node);
|
| + node->InsertInput(zone, cursor++, target);
|
| + node->InsertInput(zone, cursor++, new_target);
|
|
|
| Address entry = Builtins::CppEntryOf(builtin_index);
|
| ExternalReference entry_ref(ExternalReference(entry, isolate));
|
| Node* entry_node = jsgraph->ExternalConstant(entry_ref);
|
|
|
| - node->InsertInput(zone, arity + 5, entry_node);
|
| - node->InsertInput(zone, arity + 6, argc_node);
|
| + node->InsertInput(zone, cursor++, entry_node);
|
| + node->InsertInput(zone, cursor++, argc_node);
|
|
|
| static const int kReturnCount = 1;
|
| const char* debug_name = Builtins::name(builtin_index);
|
| @@ -1562,6 +1564,12 @@ void ReduceBuiltin(Isolate* isolate, JSGraph* jsgraph, Node* node,
|
| NodeProperties::ChangeOp(node, jsgraph->common()->Call(desc));
|
| }
|
|
|
| +bool NeedsArgumentAdaptorFrame(Handle<SharedFunctionInfo> shared, int arity) {
|
| + static const int sentinel = SharedFunctionInfo::kDontAdaptArgumentsSentinel;
|
| + const int num_decl_parms = shared->internal_formal_parameter_count();
|
| + return (num_decl_parms != arity && num_decl_parms != sentinel);
|
| +}
|
| +
|
| } // namespace
|
|
|
| Reduction JSTypedLowering::ReduceJSCallConstruct(Node* node) {
|
| @@ -1587,9 +1595,7 @@ Reduction JSTypedLowering::ReduceJSCallConstruct(Node* node) {
|
| CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState;
|
|
|
| if (is_builtin && Builtins::HasCppImplementation(builtin_index) &&
|
| - (shared->internal_formal_parameter_count() == arity ||
|
| - shared->internal_formal_parameter_count() ==
|
| - SharedFunctionInfo::kDontAdaptArgumentsSentinel)) {
|
| + !NeedsArgumentAdaptorFrame(shared, arity)) {
|
| // Patch {node} to a direct CEntryStub call.
|
|
|
| // Load the context from the {target}.
|
| @@ -1702,14 +1708,10 @@ Reduction JSTypedLowering::ReduceJSCallFunction(Node* node) {
|
| Node* new_target = jsgraph()->UndefinedConstant();
|
| Node* argument_count = jsgraph()->Int32Constant(arity);
|
| if (is_builtin && Builtins::HasCppImplementation(builtin_index) &&
|
| - (shared->internal_formal_parameter_count() == arity ||
|
| - shared->internal_formal_parameter_count() ==
|
| - SharedFunctionInfo::kDontAdaptArgumentsSentinel)) {
|
| + !NeedsArgumentAdaptorFrame(shared, arity)) {
|
| // Patch {node} to a direct CEntryStub call.
|
| ReduceBuiltin(isolate(), jsgraph(), node, builtin_index, arity, flags);
|
| - } else if (shared->internal_formal_parameter_count() == arity ||
|
| - shared->internal_formal_parameter_count() ==
|
| - SharedFunctionInfo::kDontAdaptArgumentsSentinel) {
|
| + } else if (!NeedsArgumentAdaptorFrame(shared, arity)) {
|
| // Patch {node} to a direct call.
|
| node->InsertInput(graph()->zone(), arity + 2, new_target);
|
| node->InsertInput(graph()->zone(), arity + 3, argument_count);
|
|
|