| 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_ARM | 5 #if V8_TARGET_ARCH_ARM |
| 6 | 6 |
| 7 #include "src/full-codegen/full-codegen.h" | 7 #include "src/full-codegen/full-codegen.h" |
| 8 #include "src/ast/compile-time-value.h" | 8 #include "src/ast/compile-time-value.h" |
| 9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| (...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1585 __ CallStub(&stub); | 1585 __ CallStub(&stub); |
| 1586 } | 1586 } |
| 1587 PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER); | 1587 PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER); |
| 1588 | 1588 |
| 1589 bool result_saved = false; // Is the result saved to the stack? | 1589 bool result_saved = false; // Is the result saved to the stack? |
| 1590 ZoneList<Expression*>* subexprs = expr->values(); | 1590 ZoneList<Expression*>* subexprs = expr->values(); |
| 1591 int length = subexprs->length(); | 1591 int length = subexprs->length(); |
| 1592 | 1592 |
| 1593 // Emit code to evaluate all the non-constant subexpressions and to store | 1593 // Emit code to evaluate all the non-constant subexpressions and to store |
| 1594 // them into the newly cloned array. | 1594 // them into the newly cloned array. |
| 1595 int array_index = 0; | 1595 for (int array_index = 0; array_index < length; array_index++) { |
| 1596 for (; array_index < length; array_index++) { | |
| 1597 Expression* subexpr = subexprs->at(array_index); | 1596 Expression* subexpr = subexprs->at(array_index); |
| 1598 DCHECK(!subexpr->IsSpread()); | 1597 DCHECK(!subexpr->IsSpread()); |
| 1599 | 1598 |
| 1600 // If the subexpression is a literal or a simple materialized literal it | 1599 // If the subexpression is a literal or a simple materialized literal it |
| 1601 // is already set in the cloned array. | 1600 // is already set in the cloned array. |
| 1602 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 1601 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
| 1603 | 1602 |
| 1604 if (!result_saved) { | 1603 if (!result_saved) { |
| 1605 PushOperand(r0); | 1604 PushOperand(r0); |
| 1606 result_saved = true; | 1605 result_saved = true; |
| 1607 } | 1606 } |
| 1608 VisitForAccumulatorValue(subexpr); | 1607 VisitForAccumulatorValue(subexpr); |
| 1609 | 1608 |
| 1610 __ mov(StoreDescriptor::NameRegister(), Operand(Smi::FromInt(array_index))); | 1609 __ mov(StoreDescriptor::NameRegister(), Operand(Smi::FromInt(array_index))); |
| 1611 __ ldr(StoreDescriptor::ReceiverRegister(), MemOperand(sp, 0)); | 1610 __ ldr(StoreDescriptor::ReceiverRegister(), MemOperand(sp, 0)); |
| 1612 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); | 1611 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); |
| 1613 CallKeyedStoreIC(); | 1612 CallKeyedStoreIC(); |
| 1614 | 1613 |
| 1615 PrepareForBailoutForId(expr->GetIdForElement(array_index), | 1614 PrepareForBailoutForId(expr->GetIdForElement(array_index), |
| 1616 BailoutState::NO_REGISTERS); | 1615 BailoutState::NO_REGISTERS); |
| 1617 } | 1616 } |
| 1618 | 1617 |
| 1619 // In case the array literal contains spread expressions it has two parts. The | |
| 1620 // first part is the "static" array which has a literal index is handled | |
| 1621 // above. The second part is the part after the first spread expression | |
| 1622 // (inclusive) and these elements gets appended to the array. Note that the | |
| 1623 // number elements an iterable produces is unknown ahead of time. | |
| 1624 if (array_index < length && result_saved) { | |
| 1625 PopOperand(r0); | |
| 1626 result_saved = false; | |
| 1627 } | |
| 1628 for (; array_index < length; array_index++) { | |
| 1629 Expression* subexpr = subexprs->at(array_index); | |
| 1630 | |
| 1631 PushOperand(r0); | |
| 1632 DCHECK(!subexpr->IsSpread()); | |
| 1633 VisitForStackValue(subexpr); | |
| 1634 CallRuntimeWithOperands(Runtime::kAppendElement); | |
| 1635 | |
| 1636 PrepareForBailoutForId(expr->GetIdForElement(array_index), | |
| 1637 BailoutState::NO_REGISTERS); | |
| 1638 } | |
| 1639 | |
| 1640 if (result_saved) { | 1618 if (result_saved) { |
| 1641 context()->PlugTOS(); | 1619 context()->PlugTOS(); |
| 1642 } else { | 1620 } else { |
| 1643 context()->Plug(r0); | 1621 context()->Plug(r0); |
| 1644 } | 1622 } |
| 1645 } | 1623 } |
| 1646 | 1624 |
| 1647 | 1625 |
| 1648 void FullCodeGenerator::VisitAssignment(Assignment* expr) { | 1626 void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
| 1649 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); | 1627 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); |
| (...skipping 2147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3797 DCHECK(interrupt_address == | 3775 DCHECK(interrupt_address == |
| 3798 isolate->builtins()->OnStackReplacement()->entry()); | 3776 isolate->builtins()->OnStackReplacement()->entry()); |
| 3799 return ON_STACK_REPLACEMENT; | 3777 return ON_STACK_REPLACEMENT; |
| 3800 } | 3778 } |
| 3801 | 3779 |
| 3802 | 3780 |
| 3803 } // namespace internal | 3781 } // namespace internal |
| 3804 } // namespace v8 | 3782 } // namespace v8 |
| 3805 | 3783 |
| 3806 #endif // V8_TARGET_ARCH_ARM | 3784 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |