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

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: 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 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 bool has_seen_computed_name = false;
1684 for (int i = 0; i < expr->properties()->length(); i++) { 1685 for (int i = 0; i < expr->properties()->length(); i++) {
1685 ObjectLiteral::Property* property = expr->properties()->at(i); 1686 ObjectLiteral::Property* property = expr->properties()->at(i);
1686 if (property->IsCompileTimeValue()) continue;
1687 1687
1688 Literal* key = property->key(); 1688 if (!has_seen_computed_name && property->IsCompileTimeValue()) {
1689 continue;
1690 }
1691 if (property->kind() == ObjectLiteral::Property::COMPUTED_NAME) {
1692 has_seen_computed_name = true;
1693 }
1694
1695 Literal* literal_key = property->key()->AsLiteral();
1689 Expression* value = property->value(); 1696 Expression* value = property->value();
1690 if (!result_saved) { 1697 if (!result_saved) {
1691 __ Push(x0); // Save result on stack 1698 __ Push(x0); // Save result on stack
1692 result_saved = true; 1699 result_saved = true;
1693 } 1700 }
1694 switch (property->kind()) { 1701 switch (property->kind()) {
1695 case ObjectLiteral::Property::CONSTANT: 1702 case ObjectLiteral::Property::CONSTANT:
1696 UNREACHABLE(); 1703 ASSERT(has_seen_computed_name);
1704 // Fall through.
1697 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 1705 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1698 ASSERT(!CompileTimeValue::IsCompileTimeValue(property->value())); 1706 ASSERT(has_seen_computed_name ||
1707 !CompileTimeValue::IsCompileTimeValue(value));
1699 // Fall through. 1708 // Fall through.
1700 case ObjectLiteral::Property::COMPUTED: 1709 case ObjectLiteral::Property::COMPUTED:
1701 if (key->value()->IsInternalizedString()) { 1710 if (literal_key->value()->IsInternalizedString()) {
1702 if (property->emit_store()) { 1711 if (property->emit_store()) {
1703 VisitForAccumulatorValue(value); 1712 VisitForAccumulatorValue(value);
1704 __ Mov(x2, Operand(key->value())); 1713 __ Mov(x2, Operand(literal_key->value()));
1705 __ Peek(x1, 0); 1714 __ Peek(x1, 0);
1706 CallStoreIC(key->LiteralFeedbackId()); 1715 CallStoreIC(literal_key->LiteralFeedbackId());
1707 PrepareForBailoutForId(key->id(), NO_REGISTERS); 1716 PrepareForBailoutForId(literal_key->id(), NO_REGISTERS);
1708 } else { 1717 } else {
1709 VisitForEffect(value); 1718 VisitForEffect(value);
1710 } 1719 }
1711 break; 1720 break;
1712 } 1721 }
1722 // Fall through.
1723 case ObjectLiteral::Property::COMPUTED_NAME:
1713 if (property->emit_store()) { 1724 if (property->emit_store()) {
1714 // Duplicate receiver on stack. 1725 // Duplicate receiver on stack.
1715 __ Peek(x0, 0); 1726 __ Peek(x0, 0);
1716 __ Push(x0); 1727 __ Push(x0);
1717 VisitForStackValue(key); 1728 VisitForStackValue(property->key());
1718 VisitForStackValue(value); 1729 VisitForStackValue(value);
1719 __ Mov(x0, Smi::FromInt(NONE)); // PropertyAttributes 1730 __ Mov(x0, Smi::FromInt(NONE)); // PropertyAttributes
1720 __ Push(x0); 1731 __ Push(x0);
1721 __ CallRuntime(Runtime::kSetProperty, 4); 1732 __ CallRuntime(Runtime::kSetProperty, 4);
1722 } else { 1733 } else {
1723 VisitForEffect(key); 1734 VisitForEffect(property->key());
1724 VisitForEffect(value); 1735 VisitForEffect(value);
1725 } 1736 }
1726 break; 1737 break;
1727 case ObjectLiteral::Property::PROTOTYPE: 1738 case ObjectLiteral::Property::PROTOTYPE:
1728 if (property->emit_store()) { 1739 if (property->emit_store()) {
1729 // Duplicate receiver on stack. 1740 // Duplicate receiver on stack.
1730 __ Peek(x0, 0); 1741 __ Peek(x0, 0);
1731 __ Push(x0); 1742 __ Push(x0);
1732 VisitForStackValue(value); 1743 VisitForStackValue(value);
1733 __ CallRuntime(Runtime::kSetPrototype, 2); 1744 __ CallRuntime(Runtime::kSetPrototype, 2);
1734 } else { 1745 } else {
1735 VisitForEffect(value); 1746 VisitForEffect(value);
1736 } 1747 }
1737 break; 1748 break;
1738 case ObjectLiteral::Property::GETTER: 1749 case ObjectLiteral::Property::GETTER:
1739 accessor_table.lookup(key)->second->getter = value; 1750 accessor_table.lookup(literal_key)->second->getter = value;
1740 break; 1751 break;
1741 case ObjectLiteral::Property::SETTER: 1752 case ObjectLiteral::Property::SETTER:
1742 accessor_table.lookup(key)->second->setter = value; 1753 accessor_table.lookup(literal_key)->second->setter = value;
1743 break; 1754 break;
1744 } 1755 }
1745 } 1756 }
1746 1757
1747 // Emit code to define accessors, using only a single call to the runtime for 1758 // Emit code to define accessors, using only a single call to the runtime for
1748 // each pair of corresponding getters and setters. 1759 // each pair of corresponding getters and setters.
1749 for (AccessorTable::Iterator it = accessor_table.begin(); 1760 for (AccessorTable::Iterator it = accessor_table.begin();
1750 it != accessor_table.end(); 1761 it != accessor_table.end();
1751 ++it) { 1762 ++it) {
1752 __ Peek(x10, 0); // Duplicate receiver. 1763 __ Peek(x10, 0); // Duplicate receiver.
(...skipping 3140 matching lines...) Expand 10 before | Expand all | Expand 10 after
4893 return previous_; 4904 return previous_;
4894 } 4905 }
4895 4906
4896 4907
4897 #undef __ 4908 #undef __
4898 4909
4899 4910
4900 } } // namespace v8::internal 4911 } } // namespace v8::internal
4901 4912
4902 #endif // V8_TARGET_ARCH_ARM64 4913 #endif // V8_TARGET_ARCH_ARM64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698