| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/js-typed-lowering.h" | 5 #include "src/compiler/js-typed-lowering.h" |
| 6 | 6 |
| 7 #include "src/builtins/builtins-utils.h" | 7 #include "src/builtins/builtins-utils.h" |
| 8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
| 9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
| 10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
| (...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1591 if (target_type->IsConstant() && | 1591 if (target_type->IsConstant() && |
| 1592 target_type->AsConstant()->Value()->IsJSFunction()) { | 1592 target_type->AsConstant()->Value()->IsJSFunction()) { |
| 1593 Handle<JSFunction> function = | 1593 Handle<JSFunction> function = |
| 1594 Handle<JSFunction>::cast(target_type->AsConstant()->Value()); | 1594 Handle<JSFunction>::cast(target_type->AsConstant()->Value()); |
| 1595 Handle<SharedFunctionInfo> shared(function->shared(), isolate()); | 1595 Handle<SharedFunctionInfo> shared(function->shared(), isolate()); |
| 1596 const int builtin_index = shared->construct_stub()->builtin_index(); | 1596 const int builtin_index = shared->construct_stub()->builtin_index(); |
| 1597 const bool is_builtin = (builtin_index != -1); | 1597 const bool is_builtin = (builtin_index != -1); |
| 1598 | 1598 |
| 1599 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState; | 1599 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState; |
| 1600 | 1600 |
| 1601 if (is_builtin && Builtins::HasCppImplementation(builtin_index)) { | 1601 if (is_builtin && Builtins::HasCppImplementation(builtin_index) && |
| 1602 (shared->internal_formal_parameter_count() == arity || |
| 1603 shared->internal_formal_parameter_count() == |
| 1604 SharedFunctionInfo::kDontAdaptArgumentsSentinel)) { |
| 1602 // Patch {node} to a direct CEntryStub call. | 1605 // Patch {node} to a direct CEntryStub call. |
| 1603 | 1606 |
| 1604 // Load the context from the {target}. | 1607 // Load the context from the {target}. |
| 1605 Node* context = effect = graph()->NewNode( | 1608 Node* context = effect = graph()->NewNode( |
| 1606 simplified()->LoadField(AccessBuilder::ForJSFunctionContext()), | 1609 simplified()->LoadField(AccessBuilder::ForJSFunctionContext()), |
| 1607 target, effect, control); | 1610 target, effect, control); |
| 1608 NodeProperties::ReplaceContextInput(node, context); | 1611 NodeProperties::ReplaceContextInput(node, context); |
| 1609 | 1612 |
| 1610 // Update the effect dependency for the {node}. | 1613 // Update the effect dependency for the {node}. |
| 1611 NodeProperties::ReplaceEffectInput(node, effect); | 1614 NodeProperties::ReplaceEffectInput(node, effect); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1703 NodeProperties::ReplaceEffectInput(node, effect); | 1706 NodeProperties::ReplaceEffectInput(node, effect); |
| 1704 | 1707 |
| 1705 // Compute flags for the call. | 1708 // Compute flags for the call. |
| 1706 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState; | 1709 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState; |
| 1707 if (p.tail_call_mode() == TailCallMode::kAllow) { | 1710 if (p.tail_call_mode() == TailCallMode::kAllow) { |
| 1708 flags |= CallDescriptor::kSupportsTailCalls; | 1711 flags |= CallDescriptor::kSupportsTailCalls; |
| 1709 } | 1712 } |
| 1710 | 1713 |
| 1711 Node* new_target = jsgraph()->UndefinedConstant(); | 1714 Node* new_target = jsgraph()->UndefinedConstant(); |
| 1712 Node* argument_count = jsgraph()->Int32Constant(arity); | 1715 Node* argument_count = jsgraph()->Int32Constant(arity); |
| 1713 if (is_builtin && Builtins::HasCppImplementation(builtin_index)) { | 1716 if (is_builtin && Builtins::HasCppImplementation(builtin_index) && |
| 1717 (shared->internal_formal_parameter_count() == arity || |
| 1718 shared->internal_formal_parameter_count() == |
| 1719 SharedFunctionInfo::kDontAdaptArgumentsSentinel)) { |
| 1714 // Patch {node} to a direct CEntryStub call. | 1720 // Patch {node} to a direct CEntryStub call. |
| 1715 ReduceBuiltin(isolate(), jsgraph(), node, builtin_index, arity, flags); | 1721 ReduceBuiltin(isolate(), jsgraph(), node, builtin_index, arity, flags); |
| 1716 } else if (shared->internal_formal_parameter_count() == arity || | 1722 } else if (shared->internal_formal_parameter_count() == arity || |
| 1717 shared->internal_formal_parameter_count() == | 1723 shared->internal_formal_parameter_count() == |
| 1718 SharedFunctionInfo::kDontAdaptArgumentsSentinel) { | 1724 SharedFunctionInfo::kDontAdaptArgumentsSentinel) { |
| 1719 // Patch {node} to a direct call. | 1725 // Patch {node} to a direct call. |
| 1720 node->InsertInput(graph()->zone(), arity + 2, new_target); | 1726 node->InsertInput(graph()->zone(), arity + 2, new_target); |
| 1721 node->InsertInput(graph()->zone(), arity + 3, argument_count); | 1727 node->InsertInput(graph()->zone(), arity + 3, argument_count); |
| 1722 NodeProperties::ChangeOp(node, | 1728 NodeProperties::ChangeOp(node, |
| 1723 common()->Call(Linkage::GetJSCallDescriptor( | 1729 common()->Call(Linkage::GetJSCallDescriptor( |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2219 } | 2225 } |
| 2220 | 2226 |
| 2221 | 2227 |
| 2222 CompilationDependencies* JSTypedLowering::dependencies() const { | 2228 CompilationDependencies* JSTypedLowering::dependencies() const { |
| 2223 return dependencies_; | 2229 return dependencies_; |
| 2224 } | 2230 } |
| 2225 | 2231 |
| 2226 } // namespace compiler | 2232 } // namespace compiler |
| 2227 } // namespace internal | 2233 } // namespace internal |
| 2228 } // namespace v8 | 2234 } // namespace v8 |
| OLD | NEW |