| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 "v8.h" | 5 #include "v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
| 8 | 8 |
| 9 #include "code-stubs.h" | 9 #include "code-stubs.h" |
| 10 #include "codegen.h" | 10 #include "codegen.h" |
| (...skipping 1748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1759 Handle<FixedArrayBase> constant_elements_values( | 1759 Handle<FixedArrayBase> constant_elements_values( |
| 1760 FixedArrayBase::cast(constant_elements->get(1))); | 1760 FixedArrayBase::cast(constant_elements->get(1))); |
| 1761 | 1761 |
| 1762 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; | 1762 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; |
| 1763 if (has_constant_fast_elements && !FLAG_allocation_site_pretenuring) { | 1763 if (has_constant_fast_elements && !FLAG_allocation_site_pretenuring) { |
| 1764 // If the only customer of allocation sites is transitioning, then | 1764 // If the only customer of allocation sites is transitioning, then |
| 1765 // we can turn it off if we don't have anywhere else to transition to. | 1765 // we can turn it off if we don't have anywhere else to transition to. |
| 1766 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; | 1766 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; |
| 1767 } | 1767 } |
| 1768 | 1768 |
| 1769 Heap* heap = isolate()->heap(); | 1769 if (expr->depth() > 1) { |
| 1770 if (has_constant_fast_elements && | |
| 1771 constant_elements_values->map() == heap->fixed_cow_array_map()) { | |
| 1772 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot | |
| 1773 // change, so it's possible to specialize the stub in advance. | |
| 1774 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); | |
| 1775 __ movp(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | |
| 1776 __ movp(rax, FieldOperand(rbx, JSFunction::kLiteralsOffset)); | |
| 1777 __ Move(rbx, Smi::FromInt(expr->literal_index())); | |
| 1778 __ Move(rcx, constant_elements); | |
| 1779 FastCloneShallowArrayStub stub( | |
| 1780 isolate(), | |
| 1781 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, | |
| 1782 allocation_site_mode, | |
| 1783 length); | |
| 1784 __ CallStub(&stub); | |
| 1785 } else if (expr->depth() > 1 || Serializer::enabled(isolate()) || | |
| 1786 length > FastCloneShallowArrayStub::kMaximumClonedLength) { | |
| 1787 __ movp(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 1770 __ movp(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1788 __ Push(FieldOperand(rbx, JSFunction::kLiteralsOffset)); | 1771 __ Push(FieldOperand(rbx, JSFunction::kLiteralsOffset)); |
| 1789 __ Push(Smi::FromInt(expr->literal_index())); | 1772 __ Push(Smi::FromInt(expr->literal_index())); |
| 1790 __ Push(constant_elements); | 1773 __ Push(constant_elements); |
| 1791 __ Push(Smi::FromInt(flags)); | 1774 __ Push(Smi::FromInt(flags)); |
| 1792 __ CallRuntime(Runtime::kHiddenCreateArrayLiteral, 4); | 1775 __ CallRuntime(Runtime::kHiddenCreateArrayLiteral, 4); |
| 1793 } else { | 1776 } else { |
| 1794 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || | |
| 1795 FLAG_smi_only_arrays); | |
| 1796 FastCloneShallowArrayStub::Mode mode = | |
| 1797 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; | |
| 1798 | |
| 1799 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot | |
| 1800 // change, so it's possible to specialize the stub in advance. | |
| 1801 if (has_constant_fast_elements) { | |
| 1802 mode = FastCloneShallowArrayStub::CLONE_ELEMENTS; | |
| 1803 } | |
| 1804 | |
| 1805 __ movp(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 1777 __ movp(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1806 __ movp(rax, FieldOperand(rbx, JSFunction::kLiteralsOffset)); | 1778 __ movp(rax, FieldOperand(rbx, JSFunction::kLiteralsOffset)); |
| 1807 __ Move(rbx, Smi::FromInt(expr->literal_index())); | 1779 __ Move(rbx, Smi::FromInt(expr->literal_index())); |
| 1808 __ Move(rcx, constant_elements); | 1780 __ Move(rcx, constant_elements); |
| 1809 FastCloneShallowArrayStub stub(isolate(), | 1781 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); |
| 1810 mode, | |
| 1811 allocation_site_mode, length); | |
| 1812 __ CallStub(&stub); | 1782 __ CallStub(&stub); |
| 1813 } | 1783 } |
| 1814 | 1784 |
| 1815 bool result_saved = false; // Is the result saved to the stack? | 1785 bool result_saved = false; // Is the result saved to the stack? |
| 1816 | 1786 |
| 1817 // Emit code to evaluate all the non-constant subexpressions and to store | 1787 // Emit code to evaluate all the non-constant subexpressions and to store |
| 1818 // them into the newly cloned array. | 1788 // them into the newly cloned array. |
| 1819 for (int i = 0; i < length; i++) { | 1789 for (int i = 0; i < length; i++) { |
| 1820 Expression* subexpr = subexprs->at(i); | 1790 Expression* subexpr = subexprs->at(i); |
| 1821 // If the subexpression is a literal or a simple materialized literal it | 1791 // If the subexpression is a literal or a simple materialized literal it |
| (...skipping 3011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4833 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4803 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 4834 Assembler::target_address_at(call_target_address, | 4804 Assembler::target_address_at(call_target_address, |
| 4835 unoptimized_code)); | 4805 unoptimized_code)); |
| 4836 return OSR_AFTER_STACK_CHECK; | 4806 return OSR_AFTER_STACK_CHECK; |
| 4837 } | 4807 } |
| 4838 | 4808 |
| 4839 | 4809 |
| 4840 } } // namespace v8::internal | 4810 } } // namespace v8::internal |
| 4841 | 4811 |
| 4842 #endif // V8_TARGET_ARCH_X64 | 4812 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |