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

Side by Side Diff: src/x64/full-codegen-x64.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_X64 7 #if V8_TARGET_ARCH_X64
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 1648 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 // If result_saved is true the result is on top of the stack. If 1659 // If result_saved is true the result is on top of the stack. If
1660 // result_saved is false the result is in rax. 1660 // result_saved is false the result is in rax.
1661 bool result_saved = false; 1661 bool result_saved = false;
1662 1662
1663 // Mark all computed expressions that are bound to a key that 1663 // Mark all computed expressions that are bound to a key that
1664 // is shadowed by a later occurrence of the same key. For the 1664 // is shadowed by a later occurrence of the same key. For the
1665 // marked expressions, no store code is emitted. 1665 // marked expressions, no store code is emitted.
1666 expr->CalculateEmitStore(zone()); 1666 expr->CalculateEmitStore(zone());
1667 1667
1668 AccessorTable accessor_table(zone()); 1668 AccessorTable accessor_table(zone());
1669 bool has_seen_computed_name = false;
1669 for (int i = 0; i < expr->properties()->length(); i++) { 1670 for (int i = 0; i < expr->properties()->length(); i++) {
1670 ObjectLiteral::Property* property = expr->properties()->at(i); 1671 ObjectLiteral::Property* property = expr->properties()->at(i);
1671 if (property->IsCompileTimeValue()) continue;
1672 1672
1673 Literal* key = property->key(); 1673 if (!has_seen_computed_name && property->IsCompileTimeValue()) {
1674 continue;
1675 }
1676 if (property->kind() == ObjectLiteral::Property::COMPUTED_NAME) {
1677 has_seen_computed_name = true;
1678 }
1679
1680 Literal* literal_key = property->key()->AsLiteral();
1674 Expression* value = property->value(); 1681 Expression* value = property->value();
1675 if (!result_saved) { 1682 if (!result_saved) {
1676 __ Push(rax); // Save result on the stack 1683 __ Push(rax); // Save result on the stack
1677 result_saved = true; 1684 result_saved = true;
1678 } 1685 }
1679 switch (property->kind()) { 1686 switch (property->kind()) {
1680 case ObjectLiteral::Property::CONSTANT: 1687 case ObjectLiteral::Property::CONSTANT:
1681 UNREACHABLE(); 1688 ASSERT(has_seen_computed_name);
1689 // Fall through.
1682 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 1690 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1683 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); 1691 ASSERT(has_seen_computed_name ||
1692 !CompileTimeValue::IsCompileTimeValue(value));
1684 // Fall through. 1693 // Fall through.
1685 case ObjectLiteral::Property::COMPUTED: 1694 case ObjectLiteral::Property::COMPUTED:
1686 if (key->value()->IsInternalizedString()) { 1695 if (literal_key->value()->IsInternalizedString()) {
1687 if (property->emit_store()) { 1696 if (property->emit_store()) {
1688 VisitForAccumulatorValue(value); 1697 VisitForAccumulatorValue(value);
1689 __ Move(rcx, key->value()); 1698 __ Move(rcx, literal_key->value());
1690 __ movp(rdx, Operand(rsp, 0)); 1699 __ movp(rdx, Operand(rsp, 0));
1691 CallStoreIC(key->LiteralFeedbackId()); 1700 CallStoreIC(literal_key->LiteralFeedbackId());
1692 PrepareForBailoutForId(key->id(), NO_REGISTERS); 1701 PrepareForBailoutForId(literal_key->id(), NO_REGISTERS);
1693 } else { 1702 } else {
1694 VisitForEffect(value); 1703 VisitForEffect(value);
1695 } 1704 }
1696 break; 1705 break;
1697 } 1706 }
1707 // Fall through.
1708 case ObjectLiteral::Property::COMPUTED_NAME:
1698 __ Push(Operand(rsp, 0)); // Duplicate receiver. 1709 __ Push(Operand(rsp, 0)); // Duplicate receiver.
1699 VisitForStackValue(key); 1710 VisitForStackValue(property->key());
1700 VisitForStackValue(value); 1711 VisitForStackValue(value);
1701 if (property->emit_store()) { 1712 if (property->emit_store()) {
1702 __ Push(Smi::FromInt(NONE)); // PropertyAttributes 1713 __ Push(Smi::FromInt(NONE)); // PropertyAttributes
1703 __ CallRuntime(Runtime::kSetProperty, 4); 1714 __ CallRuntime(Runtime::kSetProperty, 4);
1704 } else { 1715 } else {
1705 __ Drop(3); 1716 __ Drop(3);
1706 } 1717 }
1707 break; 1718 break;
1708 case ObjectLiteral::Property::PROTOTYPE: 1719 case ObjectLiteral::Property::PROTOTYPE:
1709 __ Push(Operand(rsp, 0)); // Duplicate receiver. 1720 __ Push(Operand(rsp, 0)); // Duplicate receiver.
1710 VisitForStackValue(value); 1721 VisitForStackValue(value);
1711 if (property->emit_store()) { 1722 if (property->emit_store()) {
1712 __ CallRuntime(Runtime::kSetPrototype, 2); 1723 __ CallRuntime(Runtime::kSetPrototype, 2);
1713 } else { 1724 } else {
1714 __ Drop(2); 1725 __ Drop(2);
1715 } 1726 }
1716 break; 1727 break;
1717 case ObjectLiteral::Property::GETTER: 1728 case ObjectLiteral::Property::GETTER:
1718 accessor_table.lookup(key)->second->getter = value; 1729 accessor_table.lookup(literal_key)->second->getter = value;
1719 break; 1730 break;
1720 case ObjectLiteral::Property::SETTER: 1731 case ObjectLiteral::Property::SETTER:
1721 accessor_table.lookup(key)->second->setter = value; 1732 accessor_table.lookup(literal_key)->second->setter = value;
1722 break; 1733 break;
1723 } 1734 }
1724 } 1735 }
1725 1736
1726 // Emit code to define accessors, using only a single call to the runtime for 1737 // Emit code to define accessors, using only a single call to the runtime for
1727 // each pair of corresponding getters and setters. 1738 // each pair of corresponding getters and setters.
1728 for (AccessorTable::Iterator it = accessor_table.begin(); 1739 for (AccessorTable::Iterator it = accessor_table.begin();
1729 it != accessor_table.end(); 1740 it != accessor_table.end();
1730 ++it) { 1741 ++it) {
1731 __ Push(Operand(rsp, 0)); // Duplicate receiver. 1742 __ Push(Operand(rsp, 0)); // Duplicate receiver.
(...skipping 3078 matching lines...) Expand 10 before | Expand all | Expand 10 after
4810 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4821 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4811 Assembler::target_address_at(call_target_address, 4822 Assembler::target_address_at(call_target_address,
4812 unoptimized_code)); 4823 unoptimized_code));
4813 return OSR_AFTER_STACK_CHECK; 4824 return OSR_AFTER_STACK_CHECK;
4814 } 4825 }
4815 4826
4816 4827
4817 } } // namespace v8::internal 4828 } } // namespace v8::internal
4818 4829
4819 #endif // V8_TARGET_ARCH_X64 4830 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698