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 if (expr->depth() > 1) { | 1732 Heap* heap = isolate()->heap(); |
| 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) { |
1733 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1750 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
1734 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset)); | 1751 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset)); |
1735 __ push(Immediate(Smi::FromInt(expr->literal_index()))); | 1752 __ push(Immediate(Smi::FromInt(expr->literal_index()))); |
1736 __ push(Immediate(constant_elements)); | 1753 __ push(Immediate(constant_elements)); |
1737 __ push(Immediate(Smi::FromInt(flags))); | 1754 __ push(Immediate(Smi::FromInt(flags))); |
1738 __ CallRuntime(Runtime::kHiddenCreateArrayLiteral, 4); | 1755 __ CallRuntime(Runtime::kHiddenCreateArrayLiteral, 4); |
1739 } else { | 1756 } 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 |
1740 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1768 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
1741 __ mov(eax, FieldOperand(ebx, JSFunction::kLiteralsOffset)); | 1769 __ mov(eax, FieldOperand(ebx, JSFunction::kLiteralsOffset)); |
1742 __ mov(ebx, Immediate(Smi::FromInt(expr->literal_index()))); | 1770 __ mov(ebx, Immediate(Smi::FromInt(expr->literal_index()))); |
1743 __ mov(ecx, Immediate(constant_elements)); | 1771 __ mov(ecx, Immediate(constant_elements)); |
1744 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); | 1772 FastCloneShallowArrayStub stub(isolate(), |
| 1773 mode, |
| 1774 allocation_site_mode, |
| 1775 length); |
1745 __ CallStub(&stub); | 1776 __ CallStub(&stub); |
1746 } | 1777 } |
1747 | 1778 |
1748 bool result_saved = false; // Is the result saved to the stack? | 1779 bool result_saved = false; // Is the result saved to the stack? |
1749 | 1780 |
1750 // Emit code to evaluate all the non-constant subexpressions and to store | 1781 // Emit code to evaluate all the non-constant subexpressions and to store |
1751 // them into the newly cloned array. | 1782 // them into the newly cloned array. |
1752 for (int i = 0; i < length; i++) { | 1783 for (int i = 0; i < length; i++) { |
1753 Expression* subexpr = subexprs->at(i); | 1784 Expression* subexpr = subexprs->at(i); |
1754 // If the subexpression is a literal or a simple materialized literal it | 1785 // 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... |
4793 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4824 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4794 Assembler::target_address_at(call_target_address, | 4825 Assembler::target_address_at(call_target_address, |
4795 unoptimized_code)); | 4826 unoptimized_code)); |
4796 return OSR_AFTER_STACK_CHECK; | 4827 return OSR_AFTER_STACK_CHECK; |
4797 } | 4828 } |
4798 | 4829 |
4799 | 4830 |
4800 } } // namespace v8::internal | 4831 } } // namespace v8::internal |
4801 | 4832 |
4802 #endif // V8_TARGET_ARCH_IA32 | 4833 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |