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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
8 | 8 |
9 // Note on Mips implementation: | 9 // Note on Mips implementation: |
10 // | 10 // |
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1683 // If result_saved is true the result is on top of the stack. If | 1683 // If result_saved is true the result is on top of the stack. If |
1684 // result_saved is false the result is in v0. | 1684 // result_saved is false the result is in v0. |
1685 bool result_saved = false; | 1685 bool result_saved = false; |
1686 | 1686 |
1687 // Mark all computed expressions that are bound to a key that | 1687 // Mark all computed expressions that are bound to a key that |
1688 // is shadowed by a later occurrence of the same key. For the | 1688 // is shadowed by a later occurrence of the same key. For the |
1689 // marked expressions, no store code is emitted. | 1689 // marked expressions, no store code is emitted. |
1690 expr->CalculateEmitStore(zone()); | 1690 expr->CalculateEmitStore(zone()); |
1691 | 1691 |
1692 AccessorTable accessor_table(zone()); | 1692 AccessorTable accessor_table(zone()); |
1693 for (int i = 0; i < expr->properties()->length(); i++) { | 1693 int property_index = 0; |
1694 ObjectLiteral::Property* property = expr->properties()->at(i); | 1694 for (; property_index < expr->properties()->length(); property_index++) { |
| 1695 ObjectLiteral::Property* property = expr->properties()->at(property_index); |
1695 if (property->IsCompileTimeValue()) continue; | 1696 if (property->IsCompileTimeValue()) continue; |
| 1697 if (property->kind() == ObjectLiteral::Property::COMPUTED_NAME) break; |
1696 | 1698 |
1697 Literal* key = property->key(); | 1699 Literal* key = property->key()->AsLiteral(); |
1698 Expression* value = property->value(); | 1700 Expression* value = property->value(); |
1699 if (!result_saved) { | 1701 if (!result_saved) { |
1700 __ push(v0); // Save result on stack. | 1702 __ push(v0); // Save result on stack. |
1701 result_saved = true; | 1703 result_saved = true; |
1702 } | 1704 } |
1703 switch (property->kind()) { | 1705 switch (property->kind()) { |
1704 case ObjectLiteral::Property::CONSTANT: | 1706 case ObjectLiteral::Property::CONSTANT: |
| 1707 case ObjectLiteral::Property::COMPUTED_NAME: |
1705 UNREACHABLE(); | 1708 UNREACHABLE(); |
1706 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1709 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
1707 ASSERT(!CompileTimeValue::IsCompileTimeValue(property->value())); | 1710 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); |
1708 // Fall through. | 1711 // Fall through. |
1709 case ObjectLiteral::Property::COMPUTED: | 1712 case ObjectLiteral::Property::COMPUTED: |
1710 if (key->value()->IsInternalizedString()) { | 1713 if (key->value()->IsInternalizedString()) { |
1711 if (property->emit_store()) { | 1714 if (property->emit_store()) { |
1712 VisitForAccumulatorValue(value); | 1715 VisitForAccumulatorValue(value); |
1713 __ mov(a0, result_register()); | 1716 __ mov(a0, result_register()); |
1714 __ li(a2, Operand(key->value())); | 1717 __ li(a2, Operand(key->value())); |
1715 __ lw(a1, MemOperand(sp)); | 1718 __ lw(a1, MemOperand(sp)); |
1716 CallStoreIC(key->LiteralFeedbackId()); | 1719 CallStoreIC(key->LiteralFeedbackId()); |
1717 PrepareForBailoutForId(key->id(), NO_REGISTERS); | 1720 PrepareForBailoutForId(key->id(), NO_REGISTERS); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1761 __ lw(a0, MemOperand(sp)); // Duplicate receiver. | 1764 __ lw(a0, MemOperand(sp)); // Duplicate receiver. |
1762 __ push(a0); | 1765 __ push(a0); |
1763 VisitForStackValue(it->first); | 1766 VisitForStackValue(it->first); |
1764 EmitAccessor(it->second->getter); | 1767 EmitAccessor(it->second->getter); |
1765 EmitAccessor(it->second->setter); | 1768 EmitAccessor(it->second->setter); |
1766 __ li(a0, Operand(Smi::FromInt(NONE))); | 1769 __ li(a0, Operand(Smi::FromInt(NONE))); |
1767 __ push(a0); | 1770 __ push(a0); |
1768 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); | 1771 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); |
1769 } | 1772 } |
1770 | 1773 |
| 1774 // Object literals have two parts. The "static" part on the left contains no |
| 1775 // computed property names, and so we can compute its map ahead of time; see |
| 1776 // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part |
| 1777 // starts with the first computed property name, and continues with all |
| 1778 // properties to its right. All the code from above initializes the static |
| 1779 // component of the object literal, and arranges for the map of the result to |
| 1780 // reflect the static order in which the keys appear. For the dynamic |
| 1781 // properties, we compile them into a series of "PutOwnProperty" runtime |
| 1782 // calls. This will preserve insertion order. |
| 1783 for (; property_index < expr->properties()->length(); property_index++) { |
| 1784 ObjectLiteral::Property* property = expr->properties()->at(property_index); |
| 1785 |
| 1786 Expression* key = property->key(); |
| 1787 Expression* value = property->value(); |
| 1788 if (!result_saved) { |
| 1789 __ push(v0); // Save result on the stack |
| 1790 result_saved = true; |
| 1791 } |
| 1792 |
| 1793 switch (property->kind()) { |
| 1794 case ObjectLiteral::Property::CONSTANT: |
| 1795 case ObjectLiteral::Property::COMPUTED_NAME: |
| 1796 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
| 1797 case ObjectLiteral::Property::COMPUTED: |
| 1798 // Duplicate receiver on stack. |
| 1799 __ lw(a0, MemOperand(sp)); |
| 1800 __ push(a0); |
| 1801 VisitForStackValue(key); |
| 1802 VisitForStackValue(value); |
| 1803 if (property->emit_store()) { |
| 1804 __ CallRuntime(Runtime::kPutOwnProperty, 3); |
| 1805 } else { |
| 1806 __ Drop(3); |
| 1807 } |
| 1808 break; |
| 1809 case ObjectLiteral::Property::PROTOTYPE: |
| 1810 // Duplicate receiver on stack. |
| 1811 __ lw(a0, MemOperand(sp)); |
| 1812 __ push(a0); |
| 1813 VisitForStackValue(value); |
| 1814 if (property->emit_store()) { |
| 1815 __ CallRuntime(Runtime::kSetPrototype, 2); |
| 1816 } else { |
| 1817 __ Drop(2); |
| 1818 } |
| 1819 break; |
| 1820 case ObjectLiteral::Property::GETTER: { |
| 1821 ObjectLiteral::Accessors *accessors = |
| 1822 accessor_table.lookup(key->AsLiteral())->second; |
| 1823 accessors->getter = value; |
| 1824 |
| 1825 // Duplicate receiver on stack. |
| 1826 __ lw(a0, MemOperand(sp)); |
| 1827 __ push(a0); |
| 1828 VisitForStackValue(key); |
| 1829 EmitAccessor(accessors->getter); |
| 1830 EmitAccessor(accessors->setter); |
| 1831 __ li(a0, Operand(Smi::FromInt(NONE))); // PropertyAttributes. |
| 1832 __ push(a0); |
| 1833 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); |
| 1834 break; |
| 1835 } |
| 1836 case ObjectLiteral::Property::SETTER: { |
| 1837 ObjectLiteral::Accessors *accessors = |
| 1838 accessor_table.lookup(key->AsLiteral())->second; |
| 1839 accessors->setter = value; |
| 1840 |
| 1841 // Duplicate receiver on stack. |
| 1842 __ lw(a0, MemOperand(sp)); |
| 1843 __ push(a0); |
| 1844 VisitForStackValue(key); |
| 1845 EmitAccessor(accessors->getter); |
| 1846 EmitAccessor(accessors->setter); |
| 1847 __ li(a0, Operand(Smi::FromInt(NONE))); // PropertyAttributes. |
| 1848 __ push(a0); |
| 1849 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); |
| 1850 break; |
| 1851 } |
| 1852 } |
| 1853 } |
| 1854 |
1771 if (expr->has_function()) { | 1855 if (expr->has_function()) { |
1772 ASSERT(result_saved); | 1856 ASSERT(result_saved); |
1773 __ lw(a0, MemOperand(sp)); | 1857 __ lw(a0, MemOperand(sp)); |
1774 __ push(a0); | 1858 __ push(a0); |
1775 __ CallRuntime(Runtime::kToFastProperties, 1); | 1859 __ CallRuntime(Runtime::kToFastProperties, 1); |
1776 } | 1860 } |
1777 | 1861 |
1778 if (result_saved) { | 1862 if (result_saved) { |
1779 context()->PlugTOS(); | 1863 context()->PlugTOS(); |
1780 } else { | 1864 } else { |
(...skipping 3081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4862 Assembler::target_address_at(pc_immediate_load_address)) == | 4946 Assembler::target_address_at(pc_immediate_load_address)) == |
4863 reinterpret_cast<uint32_t>( | 4947 reinterpret_cast<uint32_t>( |
4864 isolate->builtins()->OsrAfterStackCheck()->entry())); | 4948 isolate->builtins()->OsrAfterStackCheck()->entry())); |
4865 return OSR_AFTER_STACK_CHECK; | 4949 return OSR_AFTER_STACK_CHECK; |
4866 } | 4950 } |
4867 | 4951 |
4868 | 4952 |
4869 } } // namespace v8::internal | 4953 } } // namespace v8::internal |
4870 | 4954 |
4871 #endif // V8_TARGET_ARCH_MIPS | 4955 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |