[turbofan] Minor code cleanup for builtin inlining
BUG= Review-Url: https://codereview.chromium.org/2278863002 Cr-Commit-Position: refs/heads/master@{#38896}
This commit is contained in:
parent
0da5b8222b
commit
25f3de99e1
@ -1542,16 +1542,18 @@ void ReduceBuiltin(Isolate* isolate, JSGraph* jsgraph, Node* node,
|
|||||||
const int argc = arity + BuiltinArguments::kNumExtraArgsWithReceiver;
|
const int argc = arity + BuiltinArguments::kNumExtraArgsWithReceiver;
|
||||||
Node* argc_node = jsgraph->Int32Constant(argc);
|
Node* argc_node = jsgraph->Int32Constant(argc);
|
||||||
|
|
||||||
node->InsertInput(zone, arity + 2, argc_node);
|
static const int kStubAndReceiver = 2;
|
||||||
node->InsertInput(zone, arity + 3, target);
|
int cursor = arity + kStubAndReceiver;
|
||||||
node->InsertInput(zone, arity + 4, new_target);
|
node->InsertInput(zone, cursor++, argc_node);
|
||||||
|
node->InsertInput(zone, cursor++, target);
|
||||||
|
node->InsertInput(zone, cursor++, new_target);
|
||||||
|
|
||||||
Address entry = Builtins::CppEntryOf(builtin_index);
|
Address entry = Builtins::CppEntryOf(builtin_index);
|
||||||
ExternalReference entry_ref(ExternalReference(entry, isolate));
|
ExternalReference entry_ref(ExternalReference(entry, isolate));
|
||||||
Node* entry_node = jsgraph->ExternalConstant(entry_ref);
|
Node* entry_node = jsgraph->ExternalConstant(entry_ref);
|
||||||
|
|
||||||
node->InsertInput(zone, arity + 5, entry_node);
|
node->InsertInput(zone, cursor++, entry_node);
|
||||||
node->InsertInput(zone, arity + 6, argc_node);
|
node->InsertInput(zone, cursor++, argc_node);
|
||||||
|
|
||||||
static const int kReturnCount = 1;
|
static const int kReturnCount = 1;
|
||||||
const char* debug_name = Builtins::name(builtin_index);
|
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));
|
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
|
} // namespace
|
||||||
|
|
||||||
Reduction JSTypedLowering::ReduceJSCallConstruct(Node* node) {
|
Reduction JSTypedLowering::ReduceJSCallConstruct(Node* node) {
|
||||||
@ -1587,9 +1595,7 @@ Reduction JSTypedLowering::ReduceJSCallConstruct(Node* node) {
|
|||||||
CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState;
|
CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState;
|
||||||
|
|
||||||
if (is_builtin && Builtins::HasCppImplementation(builtin_index) &&
|
if (is_builtin && Builtins::HasCppImplementation(builtin_index) &&
|
||||||
(shared->internal_formal_parameter_count() == arity ||
|
!NeedsArgumentAdaptorFrame(shared, arity)) {
|
||||||
shared->internal_formal_parameter_count() ==
|
|
||||||
SharedFunctionInfo::kDontAdaptArgumentsSentinel)) {
|
|
||||||
// Patch {node} to a direct CEntryStub call.
|
// Patch {node} to a direct CEntryStub call.
|
||||||
|
|
||||||
// Load the context from the {target}.
|
// Load the context from the {target}.
|
||||||
@ -1701,22 +1707,7 @@ Reduction JSTypedLowering::ReduceJSCallFunction(Node* node) {
|
|||||||
|
|
||||||
Node* new_target = jsgraph()->UndefinedConstant();
|
Node* new_target = jsgraph()->UndefinedConstant();
|
||||||
Node* argument_count = jsgraph()->Int32Constant(arity);
|
Node* argument_count = jsgraph()->Int32Constant(arity);
|
||||||
if (is_builtin && Builtins::HasCppImplementation(builtin_index) &&
|
if (NeedsArgumentAdaptorFrame(shared, arity)) {
|
||||||
(shared->internal_formal_parameter_count() == arity ||
|
|
||||||
shared->internal_formal_parameter_count() ==
|
|
||||||
SharedFunctionInfo::kDontAdaptArgumentsSentinel)) {
|
|
||||||
// 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) {
|
|
||||||
// Patch {node} to a direct call.
|
|
||||||
node->InsertInput(graph()->zone(), arity + 2, new_target);
|
|
||||||
node->InsertInput(graph()->zone(), arity + 3, argument_count);
|
|
||||||
NodeProperties::ChangeOp(node,
|
|
||||||
common()->Call(Linkage::GetJSCallDescriptor(
|
|
||||||
graph()->zone(), false, 1 + arity, flags)));
|
|
||||||
} else {
|
|
||||||
// Patch {node} to an indirect call via the ArgumentsAdaptorTrampoline.
|
// Patch {node} to an indirect call via the ArgumentsAdaptorTrampoline.
|
||||||
Callable callable = CodeFactory::ArgumentAdaptor(isolate());
|
Callable callable = CodeFactory::ArgumentAdaptor(isolate());
|
||||||
node->InsertInput(graph()->zone(), 0,
|
node->InsertInput(graph()->zone(), 0,
|
||||||
@ -1730,6 +1721,16 @@ Reduction JSTypedLowering::ReduceJSCallFunction(Node* node) {
|
|||||||
node, common()->Call(Linkage::GetStubCallDescriptor(
|
node, common()->Call(Linkage::GetStubCallDescriptor(
|
||||||
isolate(), graph()->zone(), callable.descriptor(),
|
isolate(), graph()->zone(), callable.descriptor(),
|
||||||
1 + arity, flags)));
|
1 + arity, flags)));
|
||||||
|
} else if (is_builtin && Builtins::HasCppImplementation(builtin_index)) {
|
||||||
|
// Patch {node} to a direct CEntryStub call.
|
||||||
|
ReduceBuiltin(isolate(), jsgraph(), node, builtin_index, arity, flags);
|
||||||
|
} else {
|
||||||
|
// Patch {node} to a direct call.
|
||||||
|
node->InsertInput(graph()->zone(), arity + 2, new_target);
|
||||||
|
node->InsertInput(graph()->zone(), arity + 3, argument_count);
|
||||||
|
NodeProperties::ChangeOp(node,
|
||||||
|
common()->Call(Linkage::GetJSCallDescriptor(
|
||||||
|
graph()->zone(), false, 1 + arity, flags)));
|
||||||
}
|
}
|
||||||
return Changed(node);
|
return Changed(node);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user