OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1790 Handle<FixedArrayBase> constant_elements_values( | 1790 Handle<FixedArrayBase> constant_elements_values( |
1791 FixedArrayBase::cast(constant_elements->get(1))); | 1791 FixedArrayBase::cast(constant_elements->get(1))); |
1792 | 1792 |
1793 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; | 1793 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; |
1794 if (has_constant_fast_elements && !FLAG_allocation_site_pretenuring) { | 1794 if (has_constant_fast_elements && !FLAG_allocation_site_pretenuring) { |
1795 // If the only customer of allocation sites is transitioning, then | 1795 // If the only customer of allocation sites is transitioning, then |
1796 // we can turn it off if we don't have anywhere else to transition to. | 1796 // we can turn it off if we don't have anywhere else to transition to. |
1797 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; | 1797 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; |
1798 } | 1798 } |
1799 | 1799 |
1800 Heap* heap = isolate()->heap(); | 1800 if (expr->depth() > 1) { |
1801 if (has_constant_fast_elements && | |
1802 constant_elements_values->map() == heap->fixed_cow_array_map()) { | |
1803 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot | |
1804 // change, so it's possible to specialize the stub in advance. | |
1805 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); | |
1806 __ movp(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | |
1807 __ movp(rax, FieldOperand(rbx, JSFunction::kLiteralsOffset)); | |
1808 __ Move(rbx, Smi::FromInt(expr->literal_index())); | |
1809 __ Move(rcx, constant_elements); | |
1810 FastCloneShallowArrayStub stub( | |
1811 isolate(), | |
1812 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, | |
1813 allocation_site_mode, | |
1814 length); | |
1815 __ CallStub(&stub); | |
1816 } else if (expr->depth() > 1 || Serializer::enabled() || | |
1817 length > FastCloneShallowArrayStub::kMaximumClonedLength) { | |
1818 __ movp(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 1801 __ movp(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
1819 __ Push(FieldOperand(rbx, JSFunction::kLiteralsOffset)); | 1802 __ Push(FieldOperand(rbx, JSFunction::kLiteralsOffset)); |
1820 __ Push(Smi::FromInt(expr->literal_index())); | 1803 __ Push(Smi::FromInt(expr->literal_index())); |
1821 __ Push(constant_elements); | 1804 __ Push(constant_elements); |
1822 __ Push(Smi::FromInt(flags)); | 1805 __ Push(Smi::FromInt(flags)); |
1823 __ CallRuntime(Runtime::kHiddenCreateArrayLiteral, 4); | 1806 __ CallRuntime(Runtime::kHiddenCreateArrayLiteral, 4); |
1824 } else { | 1807 } else { |
1825 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || | |
1826 FLAG_smi_only_arrays); | |
1827 FastCloneShallowArrayStub::Mode mode = | |
1828 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; | |
1829 | |
1830 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot | |
1831 // change, so it's possible to specialize the stub in advance. | |
1832 if (has_constant_fast_elements) { | |
1833 mode = FastCloneShallowArrayStub::CLONE_ELEMENTS; | |
1834 } | |
1835 | |
1836 __ movp(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 1808 __ movp(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
1837 __ movp(rax, FieldOperand(rbx, JSFunction::kLiteralsOffset)); | 1809 __ movp(rax, FieldOperand(rbx, JSFunction::kLiteralsOffset)); |
1838 __ Move(rbx, Smi::FromInt(expr->literal_index())); | 1810 __ Move(rbx, Smi::FromInt(expr->literal_index())); |
1839 __ Move(rcx, constant_elements); | 1811 __ Move(rcx, constant_elements); |
1840 FastCloneShallowArrayStub stub(isolate(), | 1812 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); |
1841 mode, | |
1842 allocation_site_mode, length); | |
1843 __ CallStub(&stub); | 1813 __ CallStub(&stub); |
1844 } | 1814 } |
1845 | 1815 |
1846 bool result_saved = false; // Is the result saved to the stack? | 1816 bool result_saved = false; // Is the result saved to the stack? |
1847 | 1817 |
1848 // Emit code to evaluate all the non-constant subexpressions and to store | 1818 // Emit code to evaluate all the non-constant subexpressions and to store |
1849 // them into the newly cloned array. | 1819 // them into the newly cloned array. |
1850 for (int i = 0; i < length; i++) { | 1820 for (int i = 0; i < length; i++) { |
1851 Expression* subexpr = subexprs->at(i); | 1821 Expression* subexpr = subexprs->at(i); |
1852 // If the subexpression is a literal or a simple materialized literal it | 1822 // If the subexpression is a literal or a simple materialized literal it |
(...skipping 3076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4929 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4899 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4930 Assembler::target_address_at(call_target_address, | 4900 Assembler::target_address_at(call_target_address, |
4931 unoptimized_code)); | 4901 unoptimized_code)); |
4932 return OSR_AFTER_STACK_CHECK; | 4902 return OSR_AFTER_STACK_CHECK; |
4933 } | 4903 } |
4934 | 4904 |
4935 | 4905 |
4936 } } // namespace v8::internal | 4906 } } // namespace v8::internal |
4937 | 4907 |
4938 #endif // V8_TARGET_ARCH_X64 | 4908 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |