| 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 "SetOwnProperty" 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::kSetOwnProperty, 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 // TODO(wingo): Allow computed names for accessor properties. Currently |
| 1821 // disallowed by the parser. |
| 1822 case ObjectLiteral::Property::GETTER: { |
| 1823 ObjectLiteral::Accessors *accessors = |
| 1824 accessor_table.lookup(key->AsLiteral())->second; |
| 1825 accessors->getter = value; |
| 1826 |
| 1827 // Duplicate receiver on stack. |
| 1828 __ lw(a0, MemOperand(sp)); |
| 1829 __ push(a0); |
| 1830 VisitForStackValue(key); |
| 1831 EmitAccessor(accessors->getter); |
| 1832 EmitAccessor(accessors->setter); |
| 1833 __ li(a0, Operand(Smi::FromInt(NONE))); // PropertyAttributes. |
| 1834 __ push(a0); |
| 1835 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); |
| 1836 break; |
| 1837 } |
| 1838 case ObjectLiteral::Property::SETTER: { |
| 1839 ObjectLiteral::Accessors *accessors = |
| 1840 accessor_table.lookup(key->AsLiteral())->second; |
| 1841 accessors->setter = value; |
| 1842 |
| 1843 // Duplicate receiver on stack. |
| 1844 __ lw(a0, MemOperand(sp)); |
| 1845 __ push(a0); |
| 1846 VisitForStackValue(key); |
| 1847 EmitAccessor(accessors->getter); |
| 1848 EmitAccessor(accessors->setter); |
| 1849 __ li(a0, Operand(Smi::FromInt(NONE))); // PropertyAttributes. |
| 1850 __ push(a0); |
| 1851 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); |
| 1852 break; |
| 1853 } |
| 1854 } |
| 1855 } |
| 1856 |
| 1771 if (expr->has_function()) { | 1857 if (expr->has_function()) { |
| 1772 ASSERT(result_saved); | 1858 ASSERT(result_saved); |
| 1773 __ lw(a0, MemOperand(sp)); | 1859 __ lw(a0, MemOperand(sp)); |
| 1774 __ push(a0); | 1860 __ push(a0); |
| 1775 __ CallRuntime(Runtime::kToFastProperties, 1); | 1861 __ CallRuntime(Runtime::kToFastProperties, 1); |
| 1776 } | 1862 } |
| 1777 | 1863 |
| 1778 if (result_saved) { | 1864 if (result_saved) { |
| 1779 context()->PlugTOS(); | 1865 context()->PlugTOS(); |
| 1780 } else { | 1866 } else { |
| (...skipping 3081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4862 Assembler::target_address_at(pc_immediate_load_address)) == | 4948 Assembler::target_address_at(pc_immediate_load_address)) == |
| 4863 reinterpret_cast<uint32_t>( | 4949 reinterpret_cast<uint32_t>( |
| 4864 isolate->builtins()->OsrAfterStackCheck()->entry())); | 4950 isolate->builtins()->OsrAfterStackCheck()->entry())); |
| 4865 return OSR_AFTER_STACK_CHECK; | 4951 return OSR_AFTER_STACK_CHECK; |
| 4866 } | 4952 } |
| 4867 | 4953 |
| 4868 | 4954 |
| 4869 } } // namespace v8::internal | 4955 } } // namespace v8::internal |
| 4870 | 4956 |
| 4871 #endif // V8_TARGET_ARCH_MIPS | 4957 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |