Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1628)

Side by Side Diff: src/arm64/full-codegen-arm64.cc

Issue 332443002: Add support for computed property names in object literals (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Dynamic part of object literal initialized with PutOwnProperty Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/ast.h » ('j') | src/ast.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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::kPutOwnProperty, 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 case ObjectLiteral::Property::GETTER: {
1803 ObjectLiteral::Accessors *accessors =
1804 accessor_table.lookup(key->AsLiteral())->second;
1805 accessors->getter = value;
1806
1807 // Duplicate receiver on stack.
1808 __ Peek(x0, 0);
1809 __ Push(x0);
1810 VisitForStackValue(key);
1811 EmitAccessor(accessors->getter);
1812 EmitAccessor(accessors->setter);
1813 __ Mov(x10, Smi::FromInt(NONE));
1814 __ Push(x10);
1815 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5);
1816 break;
1817 }
1818 case ObjectLiteral::Property::SETTER: {
1819 ObjectLiteral::Accessors *accessors =
1820 accessor_table.lookup(key->AsLiteral())->second;
1821 accessors->setter = value;
1822
1823 // Duplicate receiver on stack.
1824 __ Peek(x0, 0);
1825 __ Push(x0);
1826 VisitForStackValue(key);
1827 EmitAccessor(accessors->getter);
1828 EmitAccessor(accessors->setter);
1829 __ Mov(x10, Smi::FromInt(NONE));
1830 __ Push(x10);
1831 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5);
1832 break;
1833 }
1834 }
1835 }
1836
1762 if (expr->has_function()) { 1837 if (expr->has_function()) {
1763 ASSERT(result_saved); 1838 ASSERT(result_saved);
1764 __ Peek(x0, 0); 1839 __ Peek(x0, 0);
1765 __ Push(x0); 1840 __ Push(x0);
1766 __ CallRuntime(Runtime::kToFastProperties, 1); 1841 __ CallRuntime(Runtime::kToFastProperties, 1);
1767 } 1842 }
1768 1843
1769 if (result_saved) { 1844 if (result_saved) {
1770 context()->PlugTOS(); 1845 context()->PlugTOS();
1771 } else { 1846 } else {
(...skipping 3121 matching lines...) Expand 10 before | Expand all | Expand 10 after
4893 return previous_; 4968 return previous_;
4894 } 4969 }
4895 4970
4896 4971
4897 #undef __ 4972 #undef __
4898 4973
4899 4974
4900 } } // namespace v8::internal 4975 } } // namespace v8::internal
4901 4976
4902 #endif // V8_TARGET_ARCH_ARM64 4977 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/ast.h » ('j') | src/ast.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698