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 1677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1688 int length = subexprs->length(); | 1688 int length = subexprs->length(); |
1689 Handle<FixedArray> constant_elements = expr->constant_elements(); | 1689 Handle<FixedArray> constant_elements = expr->constant_elements(); |
1690 ASSERT_EQ(2, constant_elements->length()); | 1690 ASSERT_EQ(2, constant_elements->length()); |
1691 ElementsKind constant_elements_kind = | 1691 ElementsKind constant_elements_kind = |
1692 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); | 1692 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); |
1693 bool has_constant_fast_elements = | 1693 bool has_constant_fast_elements = |
1694 IsFastObjectElementsKind(constant_elements_kind); | 1694 IsFastObjectElementsKind(constant_elements_kind); |
1695 Handle<FixedArrayBase> constant_elements_values( | 1695 Handle<FixedArrayBase> constant_elements_values( |
1696 FixedArrayBase::cast(constant_elements->get(1))); | 1696 FixedArrayBase::cast(constant_elements->get(1))); |
1697 | 1697 |
1698 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | |
1699 __ push(FieldOperand(rbx, JSFunction::kLiteralsOffset)); | |
1700 __ Push(Smi::FromInt(expr->literal_index())); | |
1701 __ Push(constant_elements); | |
1702 Heap* heap = isolate()->heap(); | 1698 Heap* heap = isolate()->heap(); |
1703 if (has_constant_fast_elements && | 1699 if (has_constant_fast_elements && |
1704 constant_elements_values->map() == heap->fixed_cow_array_map()) { | 1700 constant_elements_values->map() == heap->fixed_cow_array_map()) { |
1705 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot | 1701 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot |
1706 // change, so it's possible to specialize the stub in advance. | 1702 // change, so it's possible to specialize the stub in advance. |
1707 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); | 1703 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); |
| 1704 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1705 __ movq(rax, FieldOperand(rbx, JSFunction::kLiteralsOffset)); |
| 1706 __ Move(rbx, Smi::FromInt(expr->literal_index())); |
| 1707 __ Move(rcx, constant_elements); |
1708 FastCloneShallowArrayStub stub( | 1708 FastCloneShallowArrayStub stub( |
1709 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, | 1709 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, |
1710 DONT_TRACK_ALLOCATION_SITE, | 1710 DONT_TRACK_ALLOCATION_SITE, |
1711 length); | 1711 length); |
1712 __ CallStub(&stub); | 1712 __ CallStub(&stub); |
1713 } else if (expr->depth() > 1) { | 1713 } else if (expr->depth() > 1) { |
| 1714 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1715 __ push(FieldOperand(rbx, JSFunction::kLiteralsOffset)); |
| 1716 __ Push(Smi::FromInt(expr->literal_index())); |
| 1717 __ Push(constant_elements); |
1714 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); | 1718 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); |
1715 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { | 1719 } else if (Serializer::enabled() || |
| 1720 length > FastCloneShallowArrayStub::kMaximumClonedLength) { |
| 1721 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1722 __ push(FieldOperand(rbx, JSFunction::kLiteralsOffset)); |
| 1723 __ Push(Smi::FromInt(expr->literal_index())); |
| 1724 __ Push(constant_elements); |
1716 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3); | 1725 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3); |
1717 } else { | 1726 } else { |
1718 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || | 1727 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || |
1719 FLAG_smi_only_arrays); | 1728 FLAG_smi_only_arrays); |
1720 FastCloneShallowArrayStub::Mode mode = | 1729 FastCloneShallowArrayStub::Mode mode = |
1721 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; | 1730 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; |
1722 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites | 1731 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites |
1723 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE; | 1732 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE; |
1724 | 1733 |
1725 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot | 1734 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot |
1726 // change, so it's possible to specialize the stub in advance. | 1735 // change, so it's possible to specialize the stub in advance. |
1727 if (has_constant_fast_elements) { | 1736 if (has_constant_fast_elements) { |
1728 mode = FastCloneShallowArrayStub::CLONE_ELEMENTS; | 1737 mode = FastCloneShallowArrayStub::CLONE_ELEMENTS; |
1729 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; | 1738 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; |
1730 } | 1739 } |
1731 | 1740 |
| 1741 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1742 __ movq(rax, FieldOperand(rbx, JSFunction::kLiteralsOffset)); |
| 1743 __ Move(rbx, Smi::FromInt(expr->literal_index())); |
| 1744 __ Move(rcx, constant_elements); |
1732 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length); | 1745 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length); |
1733 __ CallStub(&stub); | 1746 __ CallStub(&stub); |
1734 } | 1747 } |
1735 | 1748 |
1736 bool result_saved = false; // Is the result saved to the stack? | 1749 bool result_saved = false; // Is the result saved to the stack? |
1737 | 1750 |
1738 // Emit code to evaluate all the non-constant subexpressions and to store | 1751 // Emit code to evaluate all the non-constant subexpressions and to store |
1739 // them into the newly cloned array. | 1752 // them into the newly cloned array. |
1740 for (int i = 0; i < length; i++) { | 1753 for (int i = 0; i < length; i++) { |
1741 Expression* subexpr = subexprs->at(i); | 1754 Expression* subexpr = subexprs->at(i); |
(...skipping 2809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4551 *context_length = 0; | 4564 *context_length = 0; |
4552 return previous_; | 4565 return previous_; |
4553 } | 4566 } |
4554 | 4567 |
4555 | 4568 |
4556 #undef __ | 4569 #undef __ |
4557 | 4570 |
4558 } } // namespace v8::internal | 4571 } } // namespace v8::internal |
4559 | 4572 |
4560 #endif // V8_TARGET_ARCH_X64 | 4573 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |