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_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "code-stubs.h" | 9 #include "code-stubs.h" |
10 #include "codegen.h" | 10 #include "codegen.h" |
(...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1722 Handle<FixedArrayBase> constant_elements_values( | 1722 Handle<FixedArrayBase> constant_elements_values( |
1723 FixedArrayBase::cast(constant_elements->get(1))); | 1723 FixedArrayBase::cast(constant_elements->get(1))); |
1724 | 1724 |
1725 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; | 1725 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; |
1726 if (has_constant_fast_elements && !FLAG_allocation_site_pretenuring) { | 1726 if (has_constant_fast_elements && !FLAG_allocation_site_pretenuring) { |
1727 // If the only customer of allocation sites is transitioning, then | 1727 // If the only customer of allocation sites is transitioning, then |
1728 // we can turn it off if we don't have anywhere else to transition to. | 1728 // we can turn it off if we don't have anywhere else to transition to. |
1729 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; | 1729 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; |
1730 } | 1730 } |
1731 | 1731 |
1732 Heap* heap = isolate()->heap(); | 1732 if (expr->depth() > 1) { |
1733 if (has_constant_fast_elements && | |
1734 constant_elements_values->map() == heap->fixed_cow_array_map()) { | |
1735 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot | |
1736 // change, so it's possible to specialize the stub in advance. | |
1737 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); | |
1738 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | |
1739 __ mov(eax, FieldOperand(ebx, JSFunction::kLiteralsOffset)); | |
1740 __ mov(ebx, Immediate(Smi::FromInt(expr->literal_index()))); | |
1741 __ mov(ecx, Immediate(constant_elements)); | |
1742 FastCloneShallowArrayStub stub( | |
1743 isolate(), | |
1744 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, | |
1745 allocation_site_mode, | |
1746 length); | |
1747 __ CallStub(&stub); | |
1748 } else if (expr->depth() > 1 || Serializer::enabled(isolate()) || | |
1749 length > FastCloneShallowArrayStub::kMaximumClonedLength) { | |
1750 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1733 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
1751 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset)); | 1734 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset)); |
1752 __ push(Immediate(Smi::FromInt(expr->literal_index()))); | 1735 __ push(Immediate(Smi::FromInt(expr->literal_index()))); |
1753 __ push(Immediate(constant_elements)); | 1736 __ push(Immediate(constant_elements)); |
1754 __ push(Immediate(Smi::FromInt(flags))); | 1737 __ push(Immediate(Smi::FromInt(flags))); |
1755 __ CallRuntime(Runtime::kHiddenCreateArrayLiteral, 4); | 1738 __ CallRuntime(Runtime::kHiddenCreateArrayLiteral, 4); |
1756 } else { | 1739 } else { |
1757 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || | |
1758 FLAG_smi_only_arrays); | |
1759 FastCloneShallowArrayStub::Mode mode = | |
1760 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; | |
1761 | |
1762 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot | |
1763 // change, so it's possible to specialize the stub in advance. | |
1764 if (has_constant_fast_elements) { | |
1765 mode = FastCloneShallowArrayStub::CLONE_ELEMENTS; | |
1766 } | |
1767 | |
1768 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1740 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
1769 __ mov(eax, FieldOperand(ebx, JSFunction::kLiteralsOffset)); | 1741 __ mov(eax, FieldOperand(ebx, JSFunction::kLiteralsOffset)); |
1770 __ mov(ebx, Immediate(Smi::FromInt(expr->literal_index()))); | 1742 __ mov(ebx, Immediate(Smi::FromInt(expr->literal_index()))); |
1771 __ mov(ecx, Immediate(constant_elements)); | 1743 __ mov(ecx, Immediate(constant_elements)); |
1772 FastCloneShallowArrayStub stub(isolate(), | 1744 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); |
1773 mode, | |
1774 allocation_site_mode, | |
1775 length); | |
1776 __ CallStub(&stub); | 1745 __ CallStub(&stub); |
1777 } | 1746 } |
1778 | 1747 |
1779 bool result_saved = false; // Is the result saved to the stack? | 1748 bool result_saved = false; // Is the result saved to the stack? |
1780 | 1749 |
1781 // Emit code to evaluate all the non-constant subexpressions and to store | 1750 // Emit code to evaluate all the non-constant subexpressions and to store |
1782 // them into the newly cloned array. | 1751 // them into the newly cloned array. |
1783 for (int i = 0; i < length; i++) { | 1752 for (int i = 0; i < length; i++) { |
1784 Expression* subexpr = subexprs->at(i); | 1753 Expression* subexpr = subexprs->at(i); |
1785 // If the subexpression is a literal or a simple materialized literal it | 1754 // If the subexpression is a literal or a simple materialized literal it |
(...skipping 3038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4824 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4793 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4825 Assembler::target_address_at(call_target_address, | 4794 Assembler::target_address_at(call_target_address, |
4826 unoptimized_code)); | 4795 unoptimized_code)); |
4827 return OSR_AFTER_STACK_CHECK; | 4796 return OSR_AFTER_STACK_CHECK; |
4828 } | 4797 } |
4829 | 4798 |
4830 | 4799 |
4831 } } // namespace v8::internal | 4800 } } // namespace v8::internal |
4832 | 4801 |
4833 #endif // V8_TARGET_ARCH_IA32 | 4802 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |