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 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/debug/debug.h" | 10 #include "src/debug/debug.h" |
(...skipping 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1708 for (; array_index < length; array_index++) { | 1708 for (; array_index < length; array_index++) { |
1709 Expression* subexpr = subexprs->at(array_index); | 1709 Expression* subexpr = subexprs->at(array_index); |
1710 if (subexpr->IsSpread()) break; | 1710 if (subexpr->IsSpread()) break; |
1711 | 1711 |
1712 // If the subexpression is a literal or a simple materialized literal it | 1712 // If the subexpression is a literal or a simple materialized literal it |
1713 // is already set in the cloned array. | 1713 // is already set in the cloned array. |
1714 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 1714 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
1715 | 1715 |
1716 if (!result_saved) { | 1716 if (!result_saved) { |
1717 __ Push(rax); // array literal | 1717 __ Push(rax); // array literal |
1718 __ Push(Smi::FromInt(expr->literal_index())); | |
1719 result_saved = true; | 1718 result_saved = true; |
1720 } | 1719 } |
1721 VisitForAccumulatorValue(subexpr); | 1720 VisitForAccumulatorValue(subexpr); |
1722 | 1721 |
1723 __ Move(StoreDescriptor::NameRegister(), Smi::FromInt(array_index)); | 1722 __ Move(StoreDescriptor::NameRegister(), Smi::FromInt(array_index)); |
1724 __ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, kPointerSize)); | 1723 __ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0)); |
1725 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); | 1724 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); |
1726 Handle<Code> ic = | 1725 Handle<Code> ic = |
1727 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); | 1726 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); |
1728 CallIC(ic); | 1727 CallIC(ic); |
1729 | 1728 |
1730 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); | 1729 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); |
1731 } | 1730 } |
1732 | 1731 |
1733 // In case the array literal contains spread expressions it has two parts. The | 1732 // In case the array literal contains spread expressions it has two parts. The |
1734 // first part is the "static" array which has a literal index is handled | 1733 // first part is the "static" array which has a literal index is handled |
1735 // above. The second part is the part after the first spread expression | 1734 // above. The second part is the part after the first spread expression |
1736 // (inclusive) and these elements gets appended to the array. Note that the | 1735 // (inclusive) and these elements gets appended to the array. Note that the |
1737 // number elements an iterable produces is unknown ahead of time. | 1736 // number elements an iterable produces is unknown ahead of time. |
1738 if (array_index < length && result_saved) { | 1737 if (array_index < length && result_saved) { |
1739 __ Drop(1); // literal index | |
1740 __ Pop(rax); | 1738 __ Pop(rax); |
1741 result_saved = false; | 1739 result_saved = false; |
1742 } | 1740 } |
1743 for (; array_index < length; array_index++) { | 1741 for (; array_index < length; array_index++) { |
1744 Expression* subexpr = subexprs->at(array_index); | 1742 Expression* subexpr = subexprs->at(array_index); |
1745 | 1743 |
1746 __ Push(rax); | 1744 __ Push(rax); |
1747 if (subexpr->IsSpread()) { | 1745 if (subexpr->IsSpread()) { |
1748 VisitForStackValue(subexpr->AsSpread()->expression()); | 1746 VisitForStackValue(subexpr->AsSpread()->expression()); |
1749 __ InvokeBuiltin(Context::CONCAT_ITERABLE_TO_ARRAY_BUILTIN_INDEX, | 1747 __ InvokeBuiltin(Context::CONCAT_ITERABLE_TO_ARRAY_BUILTIN_INDEX, |
1750 CALL_FUNCTION); | 1748 CALL_FUNCTION); |
1751 } else { | 1749 } else { |
1752 VisitForStackValue(subexpr); | 1750 VisitForStackValue(subexpr); |
1753 __ CallRuntime(Runtime::kAppendElement, 2); | 1751 __ CallRuntime(Runtime::kAppendElement, 2); |
1754 } | 1752 } |
1755 | 1753 |
1756 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); | 1754 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); |
1757 } | 1755 } |
1758 | 1756 |
1759 if (result_saved) { | 1757 if (result_saved) { |
1760 __ Drop(1); // literal index | |
1761 context()->PlugTOS(); | 1758 context()->PlugTOS(); |
1762 } else { | 1759 } else { |
1763 context()->Plug(rax); | 1760 context()->Plug(rax); |
1764 } | 1761 } |
1765 } | 1762 } |
1766 | 1763 |
1767 | 1764 |
1768 void FullCodeGenerator::VisitAssignment(Assignment* expr) { | 1765 void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
1769 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); | 1766 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); |
1770 | 1767 |
(...skipping 3163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4934 Assembler::target_address_at(call_target_address, | 4931 Assembler::target_address_at(call_target_address, |
4935 unoptimized_code)); | 4932 unoptimized_code)); |
4936 return OSR_AFTER_STACK_CHECK; | 4933 return OSR_AFTER_STACK_CHECK; |
4937 } | 4934 } |
4938 | 4935 |
4939 | 4936 |
4940 } // namespace internal | 4937 } // namespace internal |
4941 } // namespace v8 | 4938 } // namespace v8 |
4942 | 4939 |
4943 #endif // V8_TARGET_ARCH_X64 | 4940 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |