Index: src/compiler/js-typed-lowering.cc |
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc |
index bd4363649416fd60d7ea945a3d2df978f202922c..43a599e1aeed17a0ff0f8c5d95155bc1db8347d0 100644 |
--- a/src/compiler/js-typed-lowering.cc |
+++ b/src/compiler/js-typed-lowering.cc |
@@ -1633,6 +1633,29 @@ Reduction JSTypedLowering::ReduceJSCallFunction(Node* node) { |
return Changed(node); |
} |
+ // Check if {target} is a JSFunction. |
+ if (target_type->Is(Type::Function())) { |
+ // Remove the eager bailout frame state. |
+ NodeProperties::RemoveFrameStateInput(node, 1); |
+ |
+ // Compute flags for the call. |
+ CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState; |
+ if (p.tail_call_mode() == TailCallMode::kAllow) { |
+ flags |= CallDescriptor::kSupportsTailCalls; |
+ } |
+ |
+ // Patch {node} to an indirect call via the CallFunction builtin. |
+ Callable callable = CodeFactory::CallFunction(isolate()); |
+ node->InsertInput(graph()->zone(), 0, |
+ jsgraph()->HeapConstant(callable.code())); |
+ node->InsertInput(graph()->zone(), 2, jsgraph()->Int32Constant(arity)); |
+ NodeProperties::ChangeOp( |
+ node, common()->Call(Linkage::GetStubCallDescriptor( |
+ isolate(), graph()->zone(), callable.descriptor(), 1 + arity, |
+ flags))); |
+ return Changed(node); |
+ } |
+ |
return NoChange(); |
} |