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/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/compilation-dependencies.h" | 6 #include "src/compilation-dependencies.h" |
7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 1747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1758 return Changed(node); | 1758 return Changed(node); |
1759 } | 1759 } |
1760 | 1760 |
1761 return NoChange(); | 1761 return NoChange(); |
1762 } | 1762 } |
1763 | 1763 |
1764 | 1764 |
1765 Reduction JSTypedLowering::ReduceJSCreateLiteralArray(Node* node) { | 1765 Reduction JSTypedLowering::ReduceJSCreateLiteralArray(Node* node) { |
1766 DCHECK_EQ(IrOpcode::kJSCreateLiteralArray, node->opcode()); | 1766 DCHECK_EQ(IrOpcode::kJSCreateLiteralArray, node->opcode()); |
1767 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); | 1767 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); |
1768 Handle<FixedArray> const constants = Handle<FixedArray>::cast(p.constant()); | 1768 int const length = p.constants()->length(); |
1769 int const length = constants->length(); | |
1770 int const flags = p.flags(); | 1769 int const flags = p.flags(); |
1771 | 1770 |
1772 // Use the FastCloneShallowArrayStub only for shallow boilerplates up to the | 1771 // Use the FastCloneShallowArrayStub only for shallow boilerplates up to the |
1773 // initial length limit for arrays with "fast" elements kind. | 1772 // initial length limit for arrays with "fast" elements kind. |
1774 // TODO(rossberg): Teach strong mode to FastCloneShallowArrayStub. | 1773 // TODO(rossberg): Teach strong mode to FastCloneShallowArrayStub. |
1775 if ((flags & ArrayLiteral::kShallowElements) != 0 && | 1774 if ((flags & ArrayLiteral::kShallowElements) != 0 && |
1776 (flags & ArrayLiteral::kIsStrong) == 0 && | 1775 (flags & ArrayLiteral::kIsStrong) == 0 && |
1777 length < JSArray::kInitialMaxFastElementArray) { | 1776 length < JSArray::kInitialMaxFastElementArray) { |
1778 Isolate* isolate = jsgraph()->isolate(); | 1777 Isolate* isolate = jsgraph()->isolate(); |
1779 Callable callable = CodeFactory::FastCloneShallowArray(isolate); | 1778 Callable callable = CodeFactory::FastCloneShallowArray(isolate); |
1780 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 1779 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
1781 isolate, graph()->zone(), callable.descriptor(), 0, | 1780 isolate, graph()->zone(), callable.descriptor(), 0, |
1782 (OperatorProperties::GetFrameStateInputCount(node->op()) != 0) | 1781 (OperatorProperties::GetFrameStateInputCount(node->op()) != 0) |
1783 ? CallDescriptor::kNeedsFrameState | 1782 ? CallDescriptor::kNeedsFrameState |
1784 : CallDescriptor::kNoFlags); | 1783 : CallDescriptor::kNoFlags); |
1785 const Operator* new_op = common()->Call(desc); | 1784 const Operator* new_op = common()->Call(desc); |
1786 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 1785 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
1787 Node* literal_index = jsgraph()->SmiConstant(p.index()); | 1786 Node* literal_index = jsgraph()->SmiConstant(p.index()); |
1788 Node* constant_elements = jsgraph()->HeapConstant(constants); | 1787 Node* constant_elements = jsgraph()->HeapConstant(p.constants()); |
1789 node->InsertInput(graph()->zone(), 0, stub_code); | 1788 node->InsertInput(graph()->zone(), 0, stub_code); |
1790 node->InsertInput(graph()->zone(), 2, literal_index); | 1789 node->InsertInput(graph()->zone(), 2, literal_index); |
1791 node->InsertInput(graph()->zone(), 3, constant_elements); | 1790 node->InsertInput(graph()->zone(), 3, constant_elements); |
1792 NodeProperties::ChangeOp(node, new_op); | 1791 NodeProperties::ChangeOp(node, new_op); |
1793 return Changed(node); | 1792 return Changed(node); |
1794 } | 1793 } |
1795 | 1794 |
1796 return NoChange(); | 1795 return NoChange(); |
1797 } | 1796 } |
1798 | 1797 |
1799 | 1798 |
1800 Reduction JSTypedLowering::ReduceJSCreateLiteralObject(Node* node) { | 1799 Reduction JSTypedLowering::ReduceJSCreateLiteralObject(Node* node) { |
1801 DCHECK_EQ(IrOpcode::kJSCreateLiteralObject, node->opcode()); | 1800 DCHECK_EQ(IrOpcode::kJSCreateLiteralObject, node->opcode()); |
1802 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); | 1801 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); |
1803 Handle<FixedArray> const constants = Handle<FixedArray>::cast(p.constant()); | |
1804 // Constants are pairs, see ObjectLiteral::properties_count(). | 1802 // Constants are pairs, see ObjectLiteral::properties_count(). |
1805 int const length = constants->length() / 2; | 1803 int const length = p.constants()->length() / 2; |
1806 int const flags = p.flags(); | 1804 int const flags = p.flags(); |
1807 | 1805 |
1808 // Use the FastCloneShallowObjectStub only for shallow boilerplates without | 1806 // Use the FastCloneShallowObjectStub only for shallow boilerplates without |
1809 // elements up to the number of properties that the stubs can handle. | 1807 // elements up to the number of properties that the stubs can handle. |
1810 if ((flags & ObjectLiteral::kShallowProperties) != 0 && | 1808 if ((flags & ObjectLiteral::kShallowProperties) != 0 && |
1811 length <= FastCloneShallowObjectStub::kMaximumClonedProperties) { | 1809 length <= FastCloneShallowObjectStub::kMaximumClonedProperties) { |
1812 Isolate* isolate = jsgraph()->isolate(); | 1810 Isolate* isolate = jsgraph()->isolate(); |
1813 Callable callable = CodeFactory::FastCloneShallowObject(isolate, length); | 1811 Callable callable = CodeFactory::FastCloneShallowObject(isolate, length); |
1814 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 1812 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
1815 isolate, graph()->zone(), callable.descriptor(), 0, | 1813 isolate, graph()->zone(), callable.descriptor(), 0, |
1816 (OperatorProperties::GetFrameStateInputCount(node->op()) != 0) | 1814 (OperatorProperties::GetFrameStateInputCount(node->op()) != 0) |
1817 ? CallDescriptor::kNeedsFrameState | 1815 ? CallDescriptor::kNeedsFrameState |
1818 : CallDescriptor::kNoFlags); | 1816 : CallDescriptor::kNoFlags); |
1819 const Operator* new_op = common()->Call(desc); | 1817 const Operator* new_op = common()->Call(desc); |
1820 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 1818 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
1821 Node* literal_index = jsgraph()->SmiConstant(p.index()); | 1819 Node* literal_index = jsgraph()->SmiConstant(p.index()); |
1822 Node* literal_flags = jsgraph()->SmiConstant(flags); | 1820 Node* literal_flags = jsgraph()->SmiConstant(flags); |
1823 Node* constant_elements = jsgraph()->HeapConstant(constants); | 1821 Node* constant_elements = jsgraph()->HeapConstant(p.constants()); |
1824 node->InsertInput(graph()->zone(), 0, stub_code); | 1822 node->InsertInput(graph()->zone(), 0, stub_code); |
1825 node->InsertInput(graph()->zone(), 2, literal_index); | 1823 node->InsertInput(graph()->zone(), 2, literal_index); |
1826 node->InsertInput(graph()->zone(), 3, constant_elements); | 1824 node->InsertInput(graph()->zone(), 3, constant_elements); |
1827 node->InsertInput(graph()->zone(), 4, literal_flags); | 1825 node->InsertInput(graph()->zone(), 4, literal_flags); |
1828 NodeProperties::ChangeOp(node, new_op); | 1826 NodeProperties::ChangeOp(node, new_op); |
1829 return Changed(node); | 1827 return Changed(node); |
1830 } | 1828 } |
1831 | 1829 |
1832 return NoChange(); | 1830 return NoChange(); |
1833 } | 1831 } |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2621 } | 2619 } |
2622 | 2620 |
2623 | 2621 |
2624 CompilationDependencies* JSTypedLowering::dependencies() const { | 2622 CompilationDependencies* JSTypedLowering::dependencies() const { |
2625 return dependencies_; | 2623 return dependencies_; |
2626 } | 2624 } |
2627 | 2625 |
2628 } // namespace compiler | 2626 } // namespace compiler |
2629 } // namespace internal | 2627 } // namespace internal |
2630 } // namespace v8 | 2628 } // namespace v8 |
OLD | NEW |