Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: src/full-codegen/ia32/full-codegen-ia32.cc

Issue 1471893003: [compiler] No need to push literal index in VisitArrayLiteral. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comment Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_IA32 5 #if V8_TARGET_ARCH_IA32
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 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 for (; array_index < length; array_index++) { 1683 for (; array_index < length; array_index++) {
1684 Expression* subexpr = subexprs->at(array_index); 1684 Expression* subexpr = subexprs->at(array_index);
1685 if (subexpr->IsSpread()) break; 1685 if (subexpr->IsSpread()) break;
1686 1686
1687 // If the subexpression is a literal or a simple materialized literal it 1687 // If the subexpression is a literal or a simple materialized literal it
1688 // is already set in the cloned array. 1688 // is already set in the cloned array.
1689 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; 1689 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
1690 1690
1691 if (!result_saved) { 1691 if (!result_saved) {
1692 __ push(eax); // array literal. 1692 __ push(eax); // array literal.
1693 __ push(Immediate(Smi::FromInt(expr->literal_index())));
1694 result_saved = true; 1693 result_saved = true;
1695 } 1694 }
1696 VisitForAccumulatorValue(subexpr); 1695 VisitForAccumulatorValue(subexpr);
1697 1696
1698 __ mov(StoreDescriptor::NameRegister(), 1697 __ mov(StoreDescriptor::NameRegister(),
1699 Immediate(Smi::FromInt(array_index))); 1698 Immediate(Smi::FromInt(array_index)));
1700 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, kPointerSize)); 1699 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0));
1701 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); 1700 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot());
1702 Handle<Code> ic = 1701 Handle<Code> ic =
1703 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); 1702 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
1704 CallIC(ic); 1703 CallIC(ic);
1705 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); 1704 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS);
1706 } 1705 }
1707 1706
1708 // In case the array literal contains spread expressions it has two parts. The 1707 // In case the array literal contains spread expressions it has two parts. The
1709 // first part is the "static" array which has a literal index is handled 1708 // first part is the "static" array which has a literal index is handled
1710 // above. The second part is the part after the first spread expression 1709 // above. The second part is the part after the first spread expression
1711 // (inclusive) and these elements gets appended to the array. Note that the 1710 // (inclusive) and these elements gets appended to the array. Note that the
1712 // number elements an iterable produces is unknown ahead of time. 1711 // number elements an iterable produces is unknown ahead of time.
1713 if (array_index < length && result_saved) { 1712 if (array_index < length && result_saved) {
1714 __ Drop(1); // literal index
1715 __ Pop(eax); 1713 __ Pop(eax);
1716 result_saved = false; 1714 result_saved = false;
1717 } 1715 }
1718 for (; array_index < length; array_index++) { 1716 for (; array_index < length; array_index++) {
1719 Expression* subexpr = subexprs->at(array_index); 1717 Expression* subexpr = subexprs->at(array_index);
1720 1718
1721 __ Push(eax); 1719 __ Push(eax);
1722 if (subexpr->IsSpread()) { 1720 if (subexpr->IsSpread()) {
1723 VisitForStackValue(subexpr->AsSpread()->expression()); 1721 VisitForStackValue(subexpr->AsSpread()->expression());
1724 __ InvokeBuiltin(Context::CONCAT_ITERABLE_TO_ARRAY_BUILTIN_INDEX, 1722 __ InvokeBuiltin(Context::CONCAT_ITERABLE_TO_ARRAY_BUILTIN_INDEX,
1725 CALL_FUNCTION); 1723 CALL_FUNCTION);
1726 } else { 1724 } else {
1727 VisitForStackValue(subexpr); 1725 VisitForStackValue(subexpr);
1728 __ CallRuntime(Runtime::kAppendElement, 2); 1726 __ CallRuntime(Runtime::kAppendElement, 2);
1729 } 1727 }
1730 1728
1731 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); 1729 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS);
1732 } 1730 }
1733 1731
1734 if (result_saved) { 1732 if (result_saved) {
1735 __ Drop(1); // literal index
1736 context()->PlugTOS(); 1733 context()->PlugTOS();
1737 } else { 1734 } else {
1738 context()->Plug(eax); 1735 context()->Plug(eax);
1739 } 1736 }
1740 } 1737 }
1741 1738
1742 1739
1743 void FullCodeGenerator::VisitAssignment(Assignment* expr) { 1740 void FullCodeGenerator::VisitAssignment(Assignment* expr) {
1744 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); 1741 DCHECK(expr->target()->IsValidReferenceExpressionOrThis());
1745 1742
(...skipping 3173 matching lines...) Expand 10 before | Expand all | Expand 10 after
4919 Assembler::target_address_at(call_target_address, 4916 Assembler::target_address_at(call_target_address,
4920 unoptimized_code)); 4917 unoptimized_code));
4921 return OSR_AFTER_STACK_CHECK; 4918 return OSR_AFTER_STACK_CHECK;
4922 } 4919 }
4923 4920
4924 4921
4925 } // namespace internal 4922 } // namespace internal
4926 } // namespace v8 4923 } // namespace v8
4927 4924
4928 #endif // V8_TARGET_ARCH_IA32 4925 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/full-codegen/arm64/full-codegen-arm64.cc ('k') | src/full-codegen/mips/full-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698