Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: src/compiler/js-typed-lowering.cc

Issue 2890023004: [turbofan] Avoid allocating rest parameters for spread calls. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ast/modules.h" 7 #include "src/ast/modules.h"
8 #include "src/builtins/builtins-utils.h" 8 #include "src/builtins/builtins-utils.h"
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/compilation-dependencies.h" 10 #include "src/compilation-dependencies.h"
(...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 } 1696 }
1697 1697
1698 bool NeedsArgumentAdaptorFrame(Handle<SharedFunctionInfo> shared, int arity) { 1698 bool NeedsArgumentAdaptorFrame(Handle<SharedFunctionInfo> shared, int arity) {
1699 static const int sentinel = SharedFunctionInfo::kDontAdaptArgumentsSentinel; 1699 static const int sentinel = SharedFunctionInfo::kDontAdaptArgumentsSentinel;
1700 const int num_decl_parms = shared->internal_formal_parameter_count(); 1700 const int num_decl_parms = shared->internal_formal_parameter_count();
1701 return (num_decl_parms != arity && num_decl_parms != sentinel); 1701 return (num_decl_parms != arity && num_decl_parms != sentinel);
1702 } 1702 }
1703 1703
1704 } // namespace 1704 } // namespace
1705 1705
1706 Reduction JSTypedLowering::ReduceJSConstructForwardVarargs(Node* node) {
1707 DCHECK_EQ(IrOpcode::kJSConstructForwardVarargs, node->opcode());
1708 ConstructForwardVarargsParameters p =
1709 ConstructForwardVarargsParametersOf(node->op());
1710 DCHECK_LE(2u, p.arity());
1711 int const arity = static_cast<int>(p.arity() - 2);
1712 int const start_index = static_cast<int>(p.start_index());
1713 Node* target = NodeProperties::GetValueInput(node, 0);
1714 Type* target_type = NodeProperties::GetType(target);
1715 Node* new_target = NodeProperties::GetValueInput(node, arity + 1);
1716
1717 // Check if {target} is a JSFunction.
1718 if (target_type->Is(Type::Function())) {
1719 // Patch {node} to an indirect call via ConstructFunctionForwardVarargs.
1720 Callable callable = CodeFactory::ConstructFunctionForwardVarargs(isolate());
1721 node->RemoveInput(arity + 1);
1722 node->InsertInput(graph()->zone(), 0,
1723 jsgraph()->HeapConstant(callable.code()));
1724 node->InsertInput(graph()->zone(), 2, new_target);
1725 node->InsertInput(graph()->zone(), 3, jsgraph()->Constant(arity));
1726 node->InsertInput(graph()->zone(), 4, jsgraph()->Constant(start_index));
1727 node->InsertInput(graph()->zone(), 5, jsgraph()->UndefinedConstant());
1728 NodeProperties::ChangeOp(
1729 node, common()->Call(Linkage::GetStubCallDescriptor(
1730 isolate(), graph()->zone(), callable.descriptor(), arity + 1,
1731 CallDescriptor::kNeedsFrameState)));
1732 return Changed(node);
1733 }
1734
1735 return NoChange();
1736 }
1737
1706 Reduction JSTypedLowering::ReduceJSConstruct(Node* node) { 1738 Reduction JSTypedLowering::ReduceJSConstruct(Node* node) {
1707 DCHECK_EQ(IrOpcode::kJSConstruct, node->opcode()); 1739 DCHECK_EQ(IrOpcode::kJSConstruct, node->opcode());
1708 ConstructParameters const& p = ConstructParametersOf(node->op()); 1740 ConstructParameters const& p = ConstructParametersOf(node->op());
1709 DCHECK_LE(2u, p.arity()); 1741 DCHECK_LE(2u, p.arity());
1710 int const arity = static_cast<int>(p.arity() - 2); 1742 int const arity = static_cast<int>(p.arity() - 2);
1711 Node* target = NodeProperties::GetValueInput(node, 0); 1743 Node* target = NodeProperties::GetValueInput(node, 0);
1712 Type* target_type = NodeProperties::GetType(target); 1744 Type* target_type = NodeProperties::GetType(target);
1713 Node* new_target = NodeProperties::GetValueInput(node, arity + 1); 1745 Node* new_target = NodeProperties::GetValueInput(node, arity + 1);
1714 Node* effect = NodeProperties::GetEffectInput(node); 1746 Node* effect = NodeProperties::GetEffectInput(node);
1715 Node* control = NodeProperties::GetControlInput(node); 1747 Node* control = NodeProperties::GetControlInput(node);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 CallDescriptor::kNeedsFrameState))); 1806 CallDescriptor::kNeedsFrameState)));
1775 return Changed(node); 1807 return Changed(node);
1776 } 1808 }
1777 1809
1778 return NoChange(); 1810 return NoChange();
1779 } 1811 }
1780 1812
1781 Reduction JSTypedLowering::ReduceJSCallForwardVarargs(Node* node) { 1813 Reduction JSTypedLowering::ReduceJSCallForwardVarargs(Node* node) {
1782 DCHECK_EQ(IrOpcode::kJSCallForwardVarargs, node->opcode()); 1814 DCHECK_EQ(IrOpcode::kJSCallForwardVarargs, node->opcode());
1783 CallForwardVarargsParameters p = CallForwardVarargsParametersOf(node->op()); 1815 CallForwardVarargsParameters p = CallForwardVarargsParametersOf(node->op());
1816 DCHECK_LE(2u, p.arity());
1817 int const arity = static_cast<int>(p.arity() - 2);
1818 int const start_index = static_cast<int>(p.start_index());
1784 Node* target = NodeProperties::GetValueInput(node, 0); 1819 Node* target = NodeProperties::GetValueInput(node, 0);
1785 Type* target_type = NodeProperties::GetType(target); 1820 Type* target_type = NodeProperties::GetType(target);
1786 1821
1787 // Check if {target} is a JSFunction. 1822 // Check if {target} is a JSFunction.
1788 if (target_type->Is(Type::Function())) { 1823 if (target_type->Is(Type::Function())) {
1789 // Compute flags for the call. 1824 // Compute flags for the call.
1790 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState; 1825 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState;
1791 if (p.tail_call_mode() == TailCallMode::kAllow) { 1826 if (p.tail_call_mode() == TailCallMode::kAllow) {
1792 flags |= CallDescriptor::kSupportsTailCalls; 1827 flags |= CallDescriptor::kSupportsTailCalls;
1793 } 1828 }
1794 1829
1795 // Patch {node} to an indirect call via CallFunctionForwardVarargs. 1830 // Patch {node} to an indirect call via CallFunctionForwardVarargs.
1796 Callable callable = CodeFactory::CallFunctionForwardVarargs(isolate()); 1831 Callable callable = CodeFactory::CallFunctionForwardVarargs(isolate());
1797 node->InsertInput(graph()->zone(), 0, 1832 node->InsertInput(graph()->zone(), 0,
1798 jsgraph()->HeapConstant(callable.code())); 1833 jsgraph()->HeapConstant(callable.code()));
1799 node->InsertInput(graph()->zone(), 2, jsgraph()->Constant(p.start_index())); 1834 node->InsertInput(graph()->zone(), 2, jsgraph()->Constant(arity));
1835 node->InsertInput(graph()->zone(), 3, jsgraph()->Constant(start_index));
1800 NodeProperties::ChangeOp( 1836 NodeProperties::ChangeOp(
1801 node, 1837 node, common()->Call(Linkage::GetStubCallDescriptor(
1802 common()->Call(Linkage::GetStubCallDescriptor( 1838 isolate(), graph()->zone(), callable.descriptor(), arity + 1,
1803 isolate(), graph()->zone(), callable.descriptor(), 1, flags))); 1839 flags)));
1804 return Changed(node); 1840 return Changed(node);
1805 } 1841 }
1806 1842
1807 return NoChange(); 1843 return NoChange();
1808 } 1844 }
1809 1845
1810 Reduction JSTypedLowering::ReduceJSCall(Node* node) { 1846 Reduction JSTypedLowering::ReduceJSCall(Node* node) {
1811 DCHECK_EQ(IrOpcode::kJSCall, node->opcode()); 1847 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
1812 CallParameters const& p = CallParametersOf(node->op()); 1848 CallParameters const& p = CallParametersOf(node->op());
1813 int const arity = static_cast<int>(p.arity() - 2); 1849 int const arity = static_cast<int>(p.arity() - 2);
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
2169 case IrOpcode::kJSLoadContext: 2205 case IrOpcode::kJSLoadContext:
2170 return ReduceJSLoadContext(node); 2206 return ReduceJSLoadContext(node);
2171 case IrOpcode::kJSStoreContext: 2207 case IrOpcode::kJSStoreContext:
2172 return ReduceJSStoreContext(node); 2208 return ReduceJSStoreContext(node);
2173 case IrOpcode::kJSLoadModule: 2209 case IrOpcode::kJSLoadModule:
2174 return ReduceJSLoadModule(node); 2210 return ReduceJSLoadModule(node);
2175 case IrOpcode::kJSStoreModule: 2211 case IrOpcode::kJSStoreModule:
2176 return ReduceJSStoreModule(node); 2212 return ReduceJSStoreModule(node);
2177 case IrOpcode::kJSConvertReceiver: 2213 case IrOpcode::kJSConvertReceiver:
2178 return ReduceJSConvertReceiver(node); 2214 return ReduceJSConvertReceiver(node);
2215 case IrOpcode::kJSConstructForwardVarargs:
2216 return ReduceJSConstructForwardVarargs(node);
2179 case IrOpcode::kJSConstruct: 2217 case IrOpcode::kJSConstruct:
2180 return ReduceJSConstruct(node); 2218 return ReduceJSConstruct(node);
2181 case IrOpcode::kJSCallForwardVarargs: 2219 case IrOpcode::kJSCallForwardVarargs:
2182 return ReduceJSCallForwardVarargs(node); 2220 return ReduceJSCallForwardVarargs(node);
2183 case IrOpcode::kJSCall: 2221 case IrOpcode::kJSCall:
2184 return ReduceJSCall(node); 2222 return ReduceJSCall(node);
2185 case IrOpcode::kJSForInNext: 2223 case IrOpcode::kJSForInNext:
2186 return ReduceJSForInNext(node); 2224 return ReduceJSForInNext(node);
2187 case IrOpcode::kJSLoadMessage: 2225 case IrOpcode::kJSLoadMessage:
2188 return ReduceJSLoadMessage(node); 2226 return ReduceJSLoadMessage(node);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2237 } 2275 }
2238 2276
2239 2277
2240 CompilationDependencies* JSTypedLowering::dependencies() const { 2278 CompilationDependencies* JSTypedLowering::dependencies() const {
2241 return dependencies_; 2279 return dependencies_;
2242 } 2280 }
2243 2281
2244 } // namespace compiler 2282 } // namespace compiler
2245 } // namespace internal 2283 } // namespace internal
2246 } // namespace v8 2284 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698