| 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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
| 6 | 6 |
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1629 | 1629 |
| 1630 bool result_saved = false; // Is the result saved to the stack? | 1630 bool result_saved = false; // Is the result saved to the stack? |
| 1631 ZoneList<Expression*>* subexprs = expr->values(); | 1631 ZoneList<Expression*>* subexprs = expr->values(); |
| 1632 int length = subexprs->length(); | 1632 int length = subexprs->length(); |
| 1633 | 1633 |
| 1634 // Emit code to evaluate all the non-constant subexpressions and to store | 1634 // Emit code to evaluate all the non-constant subexpressions and to store |
| 1635 // them into the newly cloned array. | 1635 // them into the newly cloned array. |
| 1636 int array_index = 0; | 1636 int array_index = 0; |
| 1637 for (; array_index < length; array_index++) { | 1637 for (; array_index < length; array_index++) { |
| 1638 Expression* subexpr = subexprs->at(array_index); | 1638 Expression* subexpr = subexprs->at(array_index); |
| 1639 if (subexpr->IsSpread()) break; | 1639 DCHECK(!subexpr->IsSpread()); |
| 1640 | 1640 |
| 1641 // If the subexpression is a literal or a simple materialized literal it | 1641 // If the subexpression is a literal or a simple materialized literal it |
| 1642 // is already set in the cloned array. | 1642 // is already set in the cloned array. |
| 1643 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 1643 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
| 1644 | 1644 |
| 1645 if (!result_saved) { | 1645 if (!result_saved) { |
| 1646 __ push(eax); // array literal. | 1646 __ push(eax); // array literal. |
| 1647 result_saved = true; | 1647 result_saved = true; |
| 1648 } | 1648 } |
| 1649 VisitForAccumulatorValue(subexpr); | 1649 VisitForAccumulatorValue(subexpr); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1664 // (inclusive) and these elements gets appended to the array. Note that the | 1664 // (inclusive) and these elements gets appended to the array. Note that the |
| 1665 // number elements an iterable produces is unknown ahead of time. | 1665 // number elements an iterable produces is unknown ahead of time. |
| 1666 if (array_index < length && result_saved) { | 1666 if (array_index < length && result_saved) { |
| 1667 __ Pop(eax); | 1667 __ Pop(eax); |
| 1668 result_saved = false; | 1668 result_saved = false; |
| 1669 } | 1669 } |
| 1670 for (; array_index < length; array_index++) { | 1670 for (; array_index < length; array_index++) { |
| 1671 Expression* subexpr = subexprs->at(array_index); | 1671 Expression* subexpr = subexprs->at(array_index); |
| 1672 | 1672 |
| 1673 __ Push(eax); | 1673 __ Push(eax); |
| 1674 if (subexpr->IsSpread()) { | 1674 DCHECK(!subexpr->IsSpread()); |
| 1675 VisitForStackValue(subexpr->AsSpread()->expression()); | 1675 VisitForStackValue(subexpr); |
| 1676 __ InvokeBuiltin(Context::CONCAT_ITERABLE_TO_ARRAY_BUILTIN_INDEX, | 1676 __ CallRuntime(Runtime::kAppendElement); |
| 1677 CALL_FUNCTION); | |
| 1678 } else { | |
| 1679 VisitForStackValue(subexpr); | |
| 1680 __ CallRuntime(Runtime::kAppendElement); | |
| 1681 } | |
| 1682 | 1677 |
| 1683 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); | 1678 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); |
| 1684 } | 1679 } |
| 1685 | 1680 |
| 1686 if (result_saved) { | 1681 if (result_saved) { |
| 1687 context()->PlugTOS(); | 1682 context()->PlugTOS(); |
| 1688 } else { | 1683 } else { |
| 1689 context()->Plug(eax); | 1684 context()->Plug(eax); |
| 1690 } | 1685 } |
| 1691 } | 1686 } |
| (...skipping 3055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4747 Assembler::target_address_at(call_target_address, | 4742 Assembler::target_address_at(call_target_address, |
| 4748 unoptimized_code)); | 4743 unoptimized_code)); |
| 4749 return OSR_AFTER_STACK_CHECK; | 4744 return OSR_AFTER_STACK_CHECK; |
| 4750 } | 4745 } |
| 4751 | 4746 |
| 4752 | 4747 |
| 4753 } // namespace internal | 4748 } // namespace internal |
| 4754 } // namespace v8 | 4749 } // namespace v8 |
| 4755 | 4750 |
| 4756 #endif // V8_TARGET_ARCH_IA32 | 4751 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |