| 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_ARM64 | 7 #if V8_TARGET_ARCH_ARM64 |
| 8 | 8 |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1674 // If result_saved is true the result is on top of the stack. If | 1674 // If result_saved is true the result is on top of the stack. If |
| 1675 // result_saved is false the result is in x0. | 1675 // result_saved is false the result is in x0. |
| 1676 bool result_saved = false; | 1676 bool result_saved = false; |
| 1677 | 1677 |
| 1678 // Mark all computed expressions that are bound to a key that | 1678 // Mark all computed expressions that are bound to a key that |
| 1679 // is shadowed by a later occurrence of the same key. For the | 1679 // is shadowed by a later occurrence of the same key. For the |
| 1680 // marked expressions, no store code is emitted. | 1680 // marked expressions, no store code is emitted. |
| 1681 expr->CalculateEmitStore(zone()); | 1681 expr->CalculateEmitStore(zone()); |
| 1682 | 1682 |
| 1683 AccessorTable accessor_table(zone()); | 1683 AccessorTable accessor_table(zone()); |
| 1684 for (int i = 0; i < expr->properties()->length(); i++) { | 1684 int property_index = 0; |
| 1685 ObjectLiteral::Property* property = expr->properties()->at(i); | 1685 for (; property_index < expr->properties()->length(); property_index++) { |
| 1686 ObjectLiteral::Property* property = expr->properties()->at(property_index); |
| 1686 if (property->IsCompileTimeValue()) continue; | 1687 if (property->IsCompileTimeValue()) continue; |
| 1688 if (property->kind() == ObjectLiteral::Property::COMPUTED_NAME) break; |
| 1687 | 1689 |
| 1688 Literal* key = property->key(); | 1690 Literal* key = property->key()->AsLiteral(); |
| 1689 Expression* value = property->value(); | 1691 Expression* value = property->value(); |
| 1690 if (!result_saved) { | 1692 if (!result_saved) { |
| 1691 __ Push(x0); // Save result on stack | 1693 __ Push(x0); // Save result on stack |
| 1692 result_saved = true; | 1694 result_saved = true; |
| 1693 } | 1695 } |
| 1694 switch (property->kind()) { | 1696 switch (property->kind()) { |
| 1695 case ObjectLiteral::Property::CONSTANT: | 1697 case ObjectLiteral::Property::CONSTANT: |
| 1698 case ObjectLiteral::Property::COMPUTED_NAME: |
| 1696 UNREACHABLE(); | 1699 UNREACHABLE(); |
| 1697 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1700 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
| 1698 ASSERT(!CompileTimeValue::IsCompileTimeValue(property->value())); | 1701 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); |
| 1699 // Fall through. | 1702 // Fall through. |
| 1700 case ObjectLiteral::Property::COMPUTED: | 1703 case ObjectLiteral::Property::COMPUTED: |
| 1701 if (key->value()->IsInternalizedString()) { | 1704 if (key->value()->IsInternalizedString()) { |
| 1702 if (property->emit_store()) { | 1705 if (property->emit_store()) { |
| 1703 VisitForAccumulatorValue(value); | 1706 VisitForAccumulatorValue(value); |
| 1704 __ Mov(x2, Operand(key->value())); | 1707 __ Mov(x2, Operand(key->value())); |
| 1705 __ Peek(x1, 0); | 1708 __ Peek(x1, 0); |
| 1706 CallStoreIC(key->LiteralFeedbackId()); | 1709 CallStoreIC(key->LiteralFeedbackId()); |
| 1707 PrepareForBailoutForId(key->id(), NO_REGISTERS); | 1710 PrepareForBailoutForId(key->id(), NO_REGISTERS); |
| 1708 } else { | 1711 } else { |
| 1709 VisitForEffect(value); | 1712 VisitForEffect(value); |
| 1710 } | 1713 } |
| 1711 break; | 1714 break; |
| 1712 } | 1715 } |
| 1713 if (property->emit_store()) { | 1716 if (property->emit_store()) { |
| 1714 // Duplicate receiver on stack. | 1717 // Duplicate receiver on stack. |
| 1715 __ Peek(x0, 0); | 1718 __ Peek(x0, 0); |
| 1716 __ Push(x0); | 1719 __ Push(x0); |
| 1717 VisitForStackValue(key); | 1720 VisitForStackValue(property->key()); |
| 1718 VisitForStackValue(value); | 1721 VisitForStackValue(value); |
| 1719 __ Mov(x0, Smi::FromInt(NONE)); // PropertyAttributes | 1722 __ Mov(x0, Smi::FromInt(NONE)); // PropertyAttributes |
| 1720 __ Push(x0); | 1723 __ Push(x0); |
| 1721 __ CallRuntime(Runtime::kSetProperty, 4); | 1724 __ CallRuntime(Runtime::kSetProperty, 4); |
| 1722 } else { | 1725 } else { |
| 1723 VisitForEffect(key); | 1726 VisitForEffect(key); |
| 1724 VisitForEffect(value); | 1727 VisitForEffect(value); |
| 1725 } | 1728 } |
| 1726 break; | 1729 break; |
| 1727 case ObjectLiteral::Property::PROTOTYPE: | 1730 case ObjectLiteral::Property::PROTOTYPE: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1752 __ Peek(x10, 0); // Duplicate receiver. | 1755 __ Peek(x10, 0); // Duplicate receiver. |
| 1753 __ Push(x10); | 1756 __ Push(x10); |
| 1754 VisitForStackValue(it->first); | 1757 VisitForStackValue(it->first); |
| 1755 EmitAccessor(it->second->getter); | 1758 EmitAccessor(it->second->getter); |
| 1756 EmitAccessor(it->second->setter); | 1759 EmitAccessor(it->second->setter); |
| 1757 __ Mov(x10, Smi::FromInt(NONE)); | 1760 __ Mov(x10, Smi::FromInt(NONE)); |
| 1758 __ Push(x10); | 1761 __ Push(x10); |
| 1759 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); | 1762 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); |
| 1760 } | 1763 } |
| 1761 | 1764 |
| 1765 for (; property_index < expr->properties()->length(); property_index++) { |
| 1766 ObjectLiteral::Property* property = expr->properties()->at(property_index); |
| 1767 |
| 1768 Expression* key = property->key(); |
| 1769 Expression* value = property->value(); |
| 1770 if (!result_saved) { |
| 1771 __ Push(x0); // Save result on stack |
| 1772 result_saved = true; |
| 1773 } |
| 1774 |
| 1775 switch (property->kind()) { |
| 1776 case ObjectLiteral::Property::CONSTANT: |
| 1777 case ObjectLiteral::Property::COMPUTED_NAME: |
| 1778 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
| 1779 case ObjectLiteral::Property::COMPUTED: |
| 1780 // Duplicate receiver on stack. |
| 1781 __ Peek(x0, 0); |
| 1782 __ Push(x0); |
| 1783 VisitForStackValue(key); |
| 1784 VisitForStackValue(value); |
| 1785 if (property->emit_store()) { |
| 1786 __ CallRuntime(Runtime::kSetOwnProperty, 3); |
| 1787 } else { |
| 1788 __ Drop(3); |
| 1789 } |
| 1790 break; |
| 1791 case ObjectLiteral::Property::PROTOTYPE: |
| 1792 // Duplicate receiver on stack. |
| 1793 __ Peek(x0, 0); |
| 1794 __ Push(x0); |
| 1795 VisitForStackValue(value); |
| 1796 if (property->emit_store()) { |
| 1797 __ CallRuntime(Runtime::kSetPrototype, 2); |
| 1798 } else { |
| 1799 __ Drop(2); |
| 1800 } |
| 1801 break; |
| 1802 // TODO(wingo): Allow computed names for accessor properties. Currently |
| 1803 // disallowed by the parser. |
| 1804 case ObjectLiteral::Property::GETTER: { |
| 1805 ObjectLiteral::Accessors *accessors = |
| 1806 accessor_table.lookup(key->AsLiteral())->second; |
| 1807 accessors->getter = value; |
| 1808 |
| 1809 // Duplicate receiver on stack. |
| 1810 __ Peek(x0, 0); |
| 1811 __ Push(x0); |
| 1812 VisitForStackValue(key); |
| 1813 EmitAccessor(accessors->getter); |
| 1814 EmitAccessor(accessors->setter); |
| 1815 __ Mov(x10, Smi::FromInt(NONE)); |
| 1816 __ Push(x10); |
| 1817 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); |
| 1818 break; |
| 1819 } |
| 1820 case ObjectLiteral::Property::SETTER: { |
| 1821 ObjectLiteral::Accessors *accessors = |
| 1822 accessor_table.lookup(key->AsLiteral())->second; |
| 1823 accessors->setter = value; |
| 1824 |
| 1825 // Duplicate receiver on stack. |
| 1826 __ Peek(x0, 0); |
| 1827 __ Push(x0); |
| 1828 VisitForStackValue(key); |
| 1829 EmitAccessor(accessors->getter); |
| 1830 EmitAccessor(accessors->setter); |
| 1831 __ Mov(x10, Smi::FromInt(NONE)); |
| 1832 __ Push(x10); |
| 1833 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); |
| 1834 break; |
| 1835 } |
| 1836 } |
| 1837 } |
| 1838 |
| 1762 if (expr->has_function()) { | 1839 if (expr->has_function()) { |
| 1763 ASSERT(result_saved); | 1840 ASSERT(result_saved); |
| 1764 __ Peek(x0, 0); | 1841 __ Peek(x0, 0); |
| 1765 __ Push(x0); | 1842 __ Push(x0); |
| 1766 __ CallRuntime(Runtime::kToFastProperties, 1); | 1843 __ CallRuntime(Runtime::kToFastProperties, 1); |
| 1767 } | 1844 } |
| 1768 | 1845 |
| 1769 if (result_saved) { | 1846 if (result_saved) { |
| 1770 context()->PlugTOS(); | 1847 context()->PlugTOS(); |
| 1771 } else { | 1848 } else { |
| (...skipping 3121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4893 return previous_; | 4970 return previous_; |
| 4894 } | 4971 } |
| 4895 | 4972 |
| 4896 | 4973 |
| 4897 #undef __ | 4974 #undef __ |
| 4898 | 4975 |
| 4899 | 4976 |
| 4900 } } // namespace v8::internal | 4977 } } // namespace v8::internal |
| 4901 | 4978 |
| 4902 #endif // V8_TARGET_ARCH_ARM64 | 4979 #endif // V8_TARGET_ARCH_ARM64 |
| OLD | NEW |