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

Side by Side Diff: src/arm/full-codegen-arm.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: Added tests 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 | « no previous file | src/arm64/full-codegen-arm64.cc » ('j') | src/preparser.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_ARM 7 #if V8_TARGET_ARCH_ARM
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 1662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 // If result_saved is true the result is on top of the stack. If 1673 // If result_saved is true the result is on top of the stack. If
1674 // result_saved is false the result is in r0. 1674 // result_saved is false the result is in r0.
1675 bool result_saved = false; 1675 bool result_saved = false;
1676 1676
1677 // Mark all computed expressions that are bound to a key that 1677 // Mark all computed expressions that are bound to a key that
1678 // is shadowed by a later occurrence of the same key. For the 1678 // is shadowed by a later occurrence of the same key. For the
1679 // marked expressions, no store code is emitted. 1679 // marked expressions, no store code is emitted.
1680 expr->CalculateEmitStore(zone()); 1680 expr->CalculateEmitStore(zone());
1681 1681
1682 AccessorTable accessor_table(zone()); 1682 AccessorTable accessor_table(zone());
1683 for (int i = 0; i < expr->properties()->length(); i++) { 1683 int property_index = 0;
1684 ObjectLiteral::Property* property = expr->properties()->at(i); 1684 for (; property_index < expr->properties()->length(); property_index++) {
1685 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1685 if (property->IsCompileTimeValue()) continue; 1686 if (property->IsCompileTimeValue()) continue;
1687 if (property->kind() == ObjectLiteral::Property::COMPUTED_NAME) break;
1686 1688
1687 Literal* key = property->key(); 1689 Literal* key = property->key()->AsLiteral();
1688 Expression* value = property->value(); 1690 Expression* value = property->value();
1689 if (!result_saved) { 1691 if (!result_saved) {
1690 __ push(r0); // Save result on stack 1692 __ push(r0); // Save result on stack
1691 result_saved = true; 1693 result_saved = true;
1692 } 1694 }
1693 switch (property->kind()) { 1695 switch (property->kind()) {
1694 case ObjectLiteral::Property::CONSTANT: 1696 case ObjectLiteral::Property::CONSTANT:
1697 case ObjectLiteral::Property::COMPUTED_NAME:
1695 UNREACHABLE(); 1698 UNREACHABLE();
1696 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 1699 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1697 ASSERT(!CompileTimeValue::IsCompileTimeValue(property->value())); 1700 ASSERT(!CompileTimeValue::IsCompileTimeValue(value));
1698 // Fall through. 1701 // Fall through.
1699 case ObjectLiteral::Property::COMPUTED: 1702 case ObjectLiteral::Property::COMPUTED:
1700 if (key->value()->IsInternalizedString()) { 1703 if (key->value()->IsInternalizedString()) {
1701 if (property->emit_store()) { 1704 if (property->emit_store()) {
1702 VisitForAccumulatorValue(value); 1705 VisitForAccumulatorValue(value);
1703 __ mov(r2, Operand(key->value())); 1706 __ mov(r2, Operand(key->value()));
1704 __ ldr(r1, MemOperand(sp)); 1707 __ ldr(r1, MemOperand(sp));
1705 CallStoreIC(key->LiteralFeedbackId()); 1708 CallStoreIC(key->LiteralFeedbackId());
1706 PrepareForBailoutForId(key->id(), NO_REGISTERS); 1709 PrepareForBailoutForId(key->id(), NO_REGISTERS);
1707 } else { 1710 } else {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 __ ldr(r0, MemOperand(sp)); // Duplicate receiver. 1754 __ ldr(r0, MemOperand(sp)); // Duplicate receiver.
1752 __ push(r0); 1755 __ push(r0);
1753 VisitForStackValue(it->first); 1756 VisitForStackValue(it->first);
1754 EmitAccessor(it->second->getter); 1757 EmitAccessor(it->second->getter);
1755 EmitAccessor(it->second->setter); 1758 EmitAccessor(it->second->setter);
1756 __ mov(r0, Operand(Smi::FromInt(NONE))); 1759 __ mov(r0, Operand(Smi::FromInt(NONE)));
1757 __ push(r0); 1760 __ push(r0);
1758 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); 1761 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5);
1759 } 1762 }
1760 1763
1764 for (; property_index < expr->properties()->length(); property_index++) {
1765 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1766
1767 Expression* key = property->key();
1768 Expression* value = property->value();
1769 if (!result_saved) {
1770 __ push(r0); // Save result on the stack
1771 result_saved = true;
1772 }
1773
1774 switch (property->kind()) {
1775 case ObjectLiteral::Property::CONSTANT:
1776 case ObjectLiteral::Property::COMPUTED_NAME:
1777 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1778 case ObjectLiteral::Property::COMPUTED:
1779 // Duplicate receiver on stack.
1780 __ ldr(r0, MemOperand(sp));
1781 __ push(r0);
1782 VisitForStackValue(key);
1783 VisitForStackValue(value);
1784 if (property->emit_store()) {
1785 __ CallRuntime(Runtime::kSetOwnProperty, 3);
1786 } else {
1787 __ Drop(3);
1788 }
1789 break;
1790 case ObjectLiteral::Property::PROTOTYPE:
1791 // Duplicate receiver on stack.
1792 __ ldr(r0, MemOperand(sp));
1793 __ push(r0);
1794 VisitForStackValue(value);
1795 if (property->emit_store()) {
1796 __ CallRuntime(Runtime::kSetPrototype, 2);
1797 } else {
1798 __ Drop(2);
1799 }
1800 break;
1801 // TODO(wingo): Allow computed names for accessor properties. Currently
1802 // disallowed by the parser.
1803 case ObjectLiteral::Property::GETTER: {
1804 ObjectLiteral::Accessors *accessors =
1805 accessor_table.lookup(key->AsLiteral())->second;
1806 accessors->getter = value;
1807
1808 // Duplicate receiver on stack.
1809 __ ldr(r0, MemOperand(sp));
1810 __ push(r0);
1811 VisitForStackValue(key);
1812 EmitAccessor(accessors->getter);
1813 EmitAccessor(accessors->setter);
1814 __ mov(r0, Operand(Smi::FromInt(NONE)));
1815 __ push(r0);
1816 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5);
1817 break;
1818 }
1819 case ObjectLiteral::Property::SETTER: {
1820 ObjectLiteral::Accessors *accessors =
1821 accessor_table.lookup(key->AsLiteral())->second;
1822 accessors->setter = value;
1823
1824 // Duplicate receiver on stack.
1825 __ ldr(r0, MemOperand(sp));
1826 __ push(r0);
1827 VisitForStackValue(key);
1828 EmitAccessor(accessors->getter);
1829 EmitAccessor(accessors->setter);
1830 __ mov(r0, Operand(Smi::FromInt(NONE)));
1831 __ push(r0);
1832 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5);
1833 break;
1834 }
1835 }
1836 }
1837
1761 if (expr->has_function()) { 1838 if (expr->has_function()) {
1762 ASSERT(result_saved); 1839 ASSERT(result_saved);
1763 __ ldr(r0, MemOperand(sp)); 1840 __ ldr(r0, MemOperand(sp));
1764 __ push(r0); 1841 __ push(r0);
1765 __ CallRuntime(Runtime::kToFastProperties, 1); 1842 __ CallRuntime(Runtime::kToFastProperties, 1);
1766 } 1843 }
1767 1844
1768 if (result_saved) { 1845 if (result_saved) {
1769 context()->PlugTOS(); 1846 context()->PlugTOS();
1770 } else { 1847 } else {
(...skipping 3060 matching lines...) Expand 10 before | Expand all | Expand 10 after
4831 4908
4832 ASSERT(interrupt_address == 4909 ASSERT(interrupt_address ==
4833 isolate->builtins()->OsrAfterStackCheck()->entry()); 4910 isolate->builtins()->OsrAfterStackCheck()->entry());
4834 return OSR_AFTER_STACK_CHECK; 4911 return OSR_AFTER_STACK_CHECK;
4835 } 4912 }
4836 4913
4837 4914
4838 } } // namespace v8::internal 4915 } } // namespace v8::internal
4839 4916
4840 #endif // V8_TARGET_ARCH_ARM 4917 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm64/full-codegen-arm64.cc » ('j') | src/preparser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698