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 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1665 // -- 2 + n + 3: the C entry point | 1665 // -- 2 + n + 3: the C entry point |
1666 // -- 2 + n + 4: argc (Int32) | 1666 // -- 2 + n + 4: argc (Int32) |
1667 // ----------------------------------- | 1667 // ----------------------------------- |
1668 | 1668 |
1669 // The logic contained here is mirrored in Builtins::Generate_Adaptor. | 1669 // The logic contained here is mirrored in Builtins::Generate_Adaptor. |
1670 // Keep these in sync. | 1670 // Keep these in sync. |
1671 | 1671 |
1672 const bool is_construct = (node->opcode() == IrOpcode::kJSCallConstruct); | 1672 const bool is_construct = (node->opcode() == IrOpcode::kJSCallConstruct); |
1673 | 1673 |
1674 DCHECK(Builtins::HasCppImplementation(builtin_index)); | 1674 DCHECK(Builtins::HasCppImplementation(builtin_index)); |
1675 DCHECK_EQ(0, flags & CallDescriptor::kSupportsTailCalls); | |
1675 | 1676 |
1676 Node* target = NodeProperties::GetValueInput(node, 0); | 1677 Node* target = NodeProperties::GetValueInput(node, 0); |
1677 Node* new_target = is_construct | 1678 Node* new_target = is_construct |
1678 ? NodeProperties::GetValueInput(node, arity + 1) | 1679 ? NodeProperties::GetValueInput(node, arity + 1) |
1679 : jsgraph->UndefinedConstant(); | 1680 : jsgraph->UndefinedConstant(); |
1680 | 1681 |
1681 // API and CPP builtins are implemented in C++, and we can inline both. | 1682 // API and CPP builtins are implemented in C++, and we can inline both. |
1682 // CPP builtins create a builtin exit frame, API builtins don't. | 1683 // CPP builtins create a builtin exit frame, API builtins don't. |
1683 const bool has_builtin_exit_frame = Builtins::IsCpp(builtin_index); | 1684 const bool has_builtin_exit_frame = Builtins::IsCpp(builtin_index); |
1684 | 1685 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1741 | 1742 |
1742 // Check if {target} is a known JSFunction. | 1743 // Check if {target} is a known JSFunction. |
1743 if (target_type->IsHeapConstant() && | 1744 if (target_type->IsHeapConstant() && |
1744 target_type->AsHeapConstant()->Value()->IsJSFunction()) { | 1745 target_type->AsHeapConstant()->Value()->IsJSFunction()) { |
1745 Handle<JSFunction> function = | 1746 Handle<JSFunction> function = |
1746 Handle<JSFunction>::cast(target_type->AsHeapConstant()->Value()); | 1747 Handle<JSFunction>::cast(target_type->AsHeapConstant()->Value()); |
1747 Handle<SharedFunctionInfo> shared(function->shared(), isolate()); | 1748 Handle<SharedFunctionInfo> shared(function->shared(), isolate()); |
1748 const int builtin_index = shared->construct_stub()->builtin_index(); | 1749 const int builtin_index = shared->construct_stub()->builtin_index(); |
1749 const bool is_builtin = (builtin_index != -1); | 1750 const bool is_builtin = (builtin_index != -1); |
1750 | 1751 |
1751 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState; | 1752 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState; |
Michael Starzinger
2016/10/26 11:35:54
Flags are set unconditionally to not do tail calls
| |
1752 | 1753 |
1753 if (is_builtin && Builtins::HasCppImplementation(builtin_index) && | 1754 if (is_builtin && Builtins::HasCppImplementation(builtin_index) && |
1754 !NeedsArgumentAdaptorFrame(shared, arity)) { | 1755 !NeedsArgumentAdaptorFrame(shared, arity)) { |
1755 // Patch {node} to a direct CEntryStub call. | 1756 // Patch {node} to a direct CEntryStub call. |
1756 | 1757 |
1757 // Load the context from the {target}. | 1758 // Load the context from the {target}. |
1758 Node* context = effect = graph()->NewNode( | 1759 Node* context = effect = graph()->NewNode( |
1759 simplified()->LoadField(AccessBuilder::ForJSFunctionContext()), | 1760 simplified()->LoadField(AccessBuilder::ForJSFunctionContext()), |
1760 target, effect, control); | 1761 target, effect, control); |
1761 NodeProperties::ReplaceContextInput(node, context); | 1762 NodeProperties::ReplaceContextInput(node, context); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1870 jsgraph()->HeapConstant(callable.code())); | 1871 jsgraph()->HeapConstant(callable.code())); |
1871 node->InsertInput(graph()->zone(), 2, new_target); | 1872 node->InsertInput(graph()->zone(), 2, new_target); |
1872 node->InsertInput(graph()->zone(), 3, argument_count); | 1873 node->InsertInput(graph()->zone(), 3, argument_count); |
1873 node->InsertInput( | 1874 node->InsertInput( |
1874 graph()->zone(), 4, | 1875 graph()->zone(), 4, |
1875 jsgraph()->Int32Constant(shared->internal_formal_parameter_count())); | 1876 jsgraph()->Int32Constant(shared->internal_formal_parameter_count())); |
1876 NodeProperties::ChangeOp( | 1877 NodeProperties::ChangeOp( |
1877 node, common()->Call(Linkage::GetStubCallDescriptor( | 1878 node, common()->Call(Linkage::GetStubCallDescriptor( |
1878 isolate(), graph()->zone(), callable.descriptor(), | 1879 isolate(), graph()->zone(), callable.descriptor(), |
1879 1 + arity, flags))); | 1880 1 + arity, flags))); |
1880 } else if (is_builtin && Builtins::HasCppImplementation(builtin_index)) { | 1881 } else if (is_builtin && Builtins::HasCppImplementation(builtin_index) && |
jgruber
2016/10/26 11:22:59
ReduceBuiltin is also called from ReduceJSCallCons
Michael Starzinger
2016/10/26 11:35:54
Acknowledged. Constructor calls cannot be in tail-
| |
1882 ((flags & CallDescriptor::kSupportsTailCalls) == 0)) { | |
1881 // Patch {node} to a direct CEntryStub call. | 1883 // Patch {node} to a direct CEntryStub call. |
1882 ReduceBuiltin(isolate(), jsgraph(), node, builtin_index, arity, flags); | 1884 ReduceBuiltin(isolate(), jsgraph(), node, builtin_index, arity, flags); |
1883 } else { | 1885 } else { |
1884 // Patch {node} to a direct call. | 1886 // Patch {node} to a direct call. |
1885 node->InsertInput(graph()->zone(), arity + 2, new_target); | 1887 node->InsertInput(graph()->zone(), arity + 2, new_target); |
1886 node->InsertInput(graph()->zone(), arity + 3, argument_count); | 1888 node->InsertInput(graph()->zone(), arity + 3, argument_count); |
1887 NodeProperties::ChangeOp(node, | 1889 NodeProperties::ChangeOp(node, |
1888 common()->Call(Linkage::GetJSCallDescriptor( | 1890 common()->Call(Linkage::GetJSCallDescriptor( |
1889 graph()->zone(), false, 1 + arity, flags))); | 1891 graph()->zone(), false, 1 + arity, flags))); |
1890 } | 1892 } |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2168 } | 2170 } |
2169 | 2171 |
2170 | 2172 |
2171 CompilationDependencies* JSTypedLowering::dependencies() const { | 2173 CompilationDependencies* JSTypedLowering::dependencies() const { |
2172 return dependencies_; | 2174 return dependencies_; |
2173 } | 2175 } |
2174 | 2176 |
2175 } // namespace compiler | 2177 } // namespace compiler |
2176 } // namespace internal | 2178 } // namespace internal |
2177 } // namespace v8 | 2179 } // namespace v8 |
OLD | NEW |