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

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: 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
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 bool has_seen_computed_name = false;
1683 for (int i = 0; i < expr->properties()->length(); i++) { 1684 for (int i = 0; i < expr->properties()->length(); i++) {
1684 ObjectLiteral::Property* property = expr->properties()->at(i); 1685 ObjectLiteral::Property* property = expr->properties()->at(i);
1685 if (property->IsCompileTimeValue()) continue;
1686 1686
1687 Literal* key = property->key(); 1687 if (!has_seen_computed_name && property->IsCompileTimeValue()) {
1688 continue;
1689 }
1690 if (property->kind() == ObjectLiteral::Property::COMPUTED_NAME) {
1691 has_seen_computed_name = true;
1692 }
1693
1694 Literal* literal_key = property->key()->AsLiteral();
1688 Expression* value = property->value(); 1695 Expression* value = property->value();
1689 if (!result_saved) { 1696 if (!result_saved) {
1690 __ push(r0); // Save result on stack 1697 __ push(r0); // Save result on stack
1691 result_saved = true; 1698 result_saved = true;
1692 } 1699 }
1693 switch (property->kind()) { 1700 switch (property->kind()) {
1694 case ObjectLiteral::Property::CONSTANT: 1701 case ObjectLiteral::Property::CONSTANT:
1695 UNREACHABLE(); 1702 ASSERT(has_seen_computed_name);
1703 // Fall through.
1696 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 1704 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1697 ASSERT(!CompileTimeValue::IsCompileTimeValue(property->value())); 1705 ASSERT(has_seen_computed_name ||
1706 !CompileTimeValue::IsCompileTimeValue(value));
1698 // Fall through. 1707 // Fall through.
1699 case ObjectLiteral::Property::COMPUTED: 1708 case ObjectLiteral::Property::COMPUTED:
1700 if (key->value()->IsInternalizedString()) { 1709 if (literal_key->value()->IsInternalizedString()) {
1701 if (property->emit_store()) { 1710 if (property->emit_store()) {
1702 VisitForAccumulatorValue(value); 1711 VisitForAccumulatorValue(value);
1703 __ mov(r2, Operand(key->value())); 1712 __ mov(r2, Operand(literal_key->value()));
1704 __ ldr(r1, MemOperand(sp)); 1713 __ ldr(r1, MemOperand(sp));
1705 CallStoreIC(key->LiteralFeedbackId()); 1714 CallStoreIC(literal_key->LiteralFeedbackId());
1706 PrepareForBailoutForId(key->id(), NO_REGISTERS); 1715 PrepareForBailoutForId(literal_key->id(), NO_REGISTERS);
1707 } else { 1716 } else {
1708 VisitForEffect(value); 1717 VisitForEffect(value);
1709 } 1718 }
1710 break; 1719 break;
1711 } 1720 }
1721 // Fall through.
1722 case ObjectLiteral::Property::COMPUTED_NAME:
1712 // Duplicate receiver on stack. 1723 // Duplicate receiver on stack.
1713 __ ldr(r0, MemOperand(sp)); 1724 __ ldr(r0, MemOperand(sp));
1714 __ push(r0); 1725 __ push(r0);
1715 VisitForStackValue(key); 1726 VisitForStackValue(property->key());
1716 VisitForStackValue(value); 1727 VisitForStackValue(value);
1717 if (property->emit_store()) { 1728 if (property->emit_store()) {
1718 __ mov(r0, Operand(Smi::FromInt(NONE))); // PropertyAttributes 1729 __ mov(r0, Operand(Smi::FromInt(NONE))); // PropertyAttributes
1719 __ push(r0); 1730 __ push(r0);
1720 __ CallRuntime(Runtime::kSetProperty, 4); 1731 __ CallRuntime(Runtime::kSetProperty, 4);
1721 } else { 1732 } else {
1722 __ Drop(3); 1733 __ Drop(3);
1723 } 1734 }
1724 break; 1735 break;
1725 case ObjectLiteral::Property::PROTOTYPE: 1736 case ObjectLiteral::Property::PROTOTYPE:
1726 // Duplicate receiver on stack. 1737 // Duplicate receiver on stack.
1727 __ ldr(r0, MemOperand(sp)); 1738 __ ldr(r0, MemOperand(sp));
1728 __ push(r0); 1739 __ push(r0);
1729 VisitForStackValue(value); 1740 VisitForStackValue(value);
1730 if (property->emit_store()) { 1741 if (property->emit_store()) {
1731 __ CallRuntime(Runtime::kSetPrototype, 2); 1742 __ CallRuntime(Runtime::kSetPrototype, 2);
1732 } else { 1743 } else {
1733 __ Drop(2); 1744 __ Drop(2);
1734 } 1745 }
1735 break; 1746 break;
1736 1747
1737 case ObjectLiteral::Property::GETTER: 1748 case ObjectLiteral::Property::GETTER:
1738 accessor_table.lookup(key)->second->getter = value; 1749 accessor_table.lookup(literal_key)->second->getter = value;
1739 break; 1750 break;
1740 case ObjectLiteral::Property::SETTER: 1751 case ObjectLiteral::Property::SETTER:
1741 accessor_table.lookup(key)->second->setter = value; 1752 accessor_table.lookup(literal_key)->second->setter = value;
1742 break; 1753 break;
1743 } 1754 }
1744 } 1755 }
1745 1756
1746 // Emit code to define accessors, using only a single call to the runtime for 1757 // Emit code to define accessors, using only a single call to the runtime for
1747 // each pair of corresponding getters and setters. 1758 // each pair of corresponding getters and setters.
1748 for (AccessorTable::Iterator it = accessor_table.begin(); 1759 for (AccessorTable::Iterator it = accessor_table.begin();
1749 it != accessor_table.end(); 1760 it != accessor_table.end();
1750 ++it) { 1761 ++it) {
1751 __ ldr(r0, MemOperand(sp)); // Duplicate receiver. 1762 __ ldr(r0, MemOperand(sp)); // Duplicate receiver.
(...skipping 3079 matching lines...) Expand 10 before | Expand all | Expand 10 after
4831 4842
4832 ASSERT(interrupt_address == 4843 ASSERT(interrupt_address ==
4833 isolate->builtins()->OsrAfterStackCheck()->entry()); 4844 isolate->builtins()->OsrAfterStackCheck()->entry());
4834 return OSR_AFTER_STACK_CHECK; 4845 return OSR_AFTER_STACK_CHECK;
4835 } 4846 }
4836 4847
4837 4848
4838 } } // namespace v8::internal 4849 } } // namespace v8::internal
4839 4850
4840 #endif // V8_TARGET_ARCH_ARM 4851 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm64/full-codegen-arm64.cc » ('j') | test/mjsunit/object-literal-computed-names.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698