OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
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 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1568 __ CallStub(&stub); | 1568 __ CallStub(&stub); |
1569 } | 1569 } |
1570 PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER); | 1570 PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER); |
1571 | 1571 |
1572 bool result_saved = false; // Is the result saved to the stack? | 1572 bool result_saved = false; // Is the result saved to the stack? |
1573 ZoneList<Expression*>* subexprs = expr->values(); | 1573 ZoneList<Expression*>* subexprs = expr->values(); |
1574 int length = subexprs->length(); | 1574 int length = subexprs->length(); |
1575 | 1575 |
1576 // Emit code to evaluate all the non-constant subexpressions and to store | 1576 // Emit code to evaluate all the non-constant subexpressions and to store |
1577 // them into the newly cloned array. | 1577 // them into the newly cloned array. |
1578 int array_index = 0; | 1578 for (int array_index = 0; array_index < length; array_index++) { |
1579 for (; array_index < length; array_index++) { | |
1580 Expression* subexpr = subexprs->at(array_index); | 1579 Expression* subexpr = subexprs->at(array_index); |
1581 DCHECK(!subexpr->IsSpread()); | 1580 DCHECK(!subexpr->IsSpread()); |
1582 | 1581 |
1583 // If the subexpression is a literal or a simple materialized literal it | 1582 // If the subexpression is a literal or a simple materialized literal it |
1584 // is already set in the cloned array. | 1583 // is already set in the cloned array. |
1585 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 1584 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
1586 | 1585 |
1587 if (!result_saved) { | 1586 if (!result_saved) { |
1588 PushOperand(x0); | 1587 PushOperand(x0); |
1589 result_saved = true; | 1588 result_saved = true; |
1590 } | 1589 } |
1591 VisitForAccumulatorValue(subexpr); | 1590 VisitForAccumulatorValue(subexpr); |
1592 | 1591 |
1593 __ Mov(StoreDescriptor::NameRegister(), Smi::FromInt(array_index)); | 1592 __ Mov(StoreDescriptor::NameRegister(), Smi::FromInt(array_index)); |
1594 __ Peek(StoreDescriptor::ReceiverRegister(), 0); | 1593 __ Peek(StoreDescriptor::ReceiverRegister(), 0); |
1595 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); | 1594 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); |
1596 CallKeyedStoreIC(); | 1595 CallKeyedStoreIC(); |
1597 | 1596 |
1598 PrepareForBailoutForId(expr->GetIdForElement(array_index), | 1597 PrepareForBailoutForId(expr->GetIdForElement(array_index), |
1599 BailoutState::NO_REGISTERS); | 1598 BailoutState::NO_REGISTERS); |
1600 } | 1599 } |
1601 | 1600 |
1602 // In case the array literal contains spread expressions it has two parts. The | |
1603 // first part is the "static" array which has a literal index is handled | |
1604 // above. The second part is the part after the first spread expression | |
1605 // (inclusive) and these elements gets appended to the array. Note that the | |
1606 // number elements an iterable produces is unknown ahead of time. | |
1607 if (array_index < length && result_saved) { | |
1608 PopOperand(x0); | |
1609 result_saved = false; | |
1610 } | |
1611 for (; array_index < length; array_index++) { | |
1612 Expression* subexpr = subexprs->at(array_index); | |
1613 | |
1614 PushOperand(x0); | |
1615 DCHECK(!subexpr->IsSpread()); | |
1616 VisitForStackValue(subexpr); | |
1617 CallRuntimeWithOperands(Runtime::kAppendElement); | |
1618 | |
1619 PrepareForBailoutForId(expr->GetIdForElement(array_index), | |
1620 BailoutState::NO_REGISTERS); | |
1621 } | |
1622 | |
1623 if (result_saved) { | 1601 if (result_saved) { |
1624 context()->PlugTOS(); | 1602 context()->PlugTOS(); |
1625 } else { | 1603 } else { |
1626 context()->Plug(x0); | 1604 context()->Plug(x0); |
1627 } | 1605 } |
1628 } | 1606 } |
1629 | 1607 |
1630 | 1608 |
1631 void FullCodeGenerator::VisitAssignment(Assignment* expr) { | 1609 void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
1632 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); | 1610 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); |
(...skipping 2174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3807 } | 3785 } |
3808 | 3786 |
3809 return INTERRUPT; | 3787 return INTERRUPT; |
3810 } | 3788 } |
3811 | 3789 |
3812 | 3790 |
3813 } // namespace internal | 3791 } // namespace internal |
3814 } // namespace v8 | 3792 } // namespace v8 |
3815 | 3793 |
3816 #endif // V8_TARGET_ARCH_ARM64 | 3794 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |