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

Side by Side Diff: src/mips/full-codegen-mips.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_MIPS 7 #if V8_TARGET_ARCH_MIPS
8 8
9 // Note on Mips implementation: 9 // Note on Mips implementation:
10 // 10 //
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 // If result_saved is true the result is on top of the stack. If 1683 // If result_saved is true the result is on top of the stack. If
1684 // result_saved is false the result is in v0. 1684 // result_saved is false the result is in v0.
1685 bool result_saved = false; 1685 bool result_saved = false;
1686 1686
1687 // Mark all computed expressions that are bound to a key that 1687 // Mark all computed expressions that are bound to a key that
1688 // is shadowed by a later occurrence of the same key. For the 1688 // is shadowed by a later occurrence of the same key. For the
1689 // marked expressions, no store code is emitted. 1689 // marked expressions, no store code is emitted.
1690 expr->CalculateEmitStore(zone()); 1690 expr->CalculateEmitStore(zone());
1691 1691
1692 AccessorTable accessor_table(zone()); 1692 AccessorTable accessor_table(zone());
1693 bool has_seen_computed_name = false;
1693 for (int i = 0; i < expr->properties()->length(); i++) { 1694 for (int i = 0; i < expr->properties()->length(); i++) {
1694 ObjectLiteral::Property* property = expr->properties()->at(i); 1695 ObjectLiteral::Property* property = expr->properties()->at(i);
1695 if (property->IsCompileTimeValue()) continue;
1696 1696
1697 Literal* key = property->key(); 1697 if (!has_seen_computed_name && property->IsCompileTimeValue()) {
1698 continue;
1699 }
1700 if (property->kind() == ObjectLiteral::Property::COMPUTED_NAME) {
1701 has_seen_computed_name = true;
1702 }
1703
1704 Literal* literal_key = property->key()->AsLiteral();
1698 Expression* value = property->value(); 1705 Expression* value = property->value();
1699 if (!result_saved) { 1706 if (!result_saved) {
1700 __ push(v0); // Save result on stack. 1707 __ push(v0); // Save result on stack.
1701 result_saved = true; 1708 result_saved = true;
1702 } 1709 }
1703 switch (property->kind()) { 1710 switch (property->kind()) {
1704 case ObjectLiteral::Property::CONSTANT: 1711 case ObjectLiteral::Property::CONSTANT:
1705 UNREACHABLE(); 1712 ASSERT(has_seen_computed_name);
1713 // Fall through.
1706 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 1714 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1707 ASSERT(!CompileTimeValue::IsCompileTimeValue(property->value())); 1715 ASSERT(has_seen_computed_name ||
1716 !CompileTimeValue::IsCompileTimeValue(value));
1708 // Fall through. 1717 // Fall through.
1709 case ObjectLiteral::Property::COMPUTED: 1718 case ObjectLiteral::Property::COMPUTED:
1710 if (key->value()->IsInternalizedString()) { 1719 if (literal_key->value()->IsInternalizedString()) {
1711 if (property->emit_store()) { 1720 if (property->emit_store()) {
1712 VisitForAccumulatorValue(value); 1721 VisitForAccumulatorValue(value);
1713 __ mov(a0, result_register()); 1722 __ mov(a0, result_register());
1714 __ li(a2, Operand(key->value())); 1723 __ li(a2, Operand(literal_key->value()));
1715 __ lw(a1, MemOperand(sp)); 1724 __ lw(a1, MemOperand(sp));
1716 CallStoreIC(key->LiteralFeedbackId()); 1725 CallStoreIC(literal_key->LiteralFeedbackId());
1717 PrepareForBailoutForId(key->id(), NO_REGISTERS); 1726 PrepareForBailoutForId(literal_key->id(), NO_REGISTERS);
1718 } else { 1727 } else {
1719 VisitForEffect(value); 1728 VisitForEffect(value);
1720 } 1729 }
1721 break; 1730 break;
1722 } 1731 }
1732 // Fall through.
1733 case ObjectLiteral::Property::COMPUTED_NAME:
1723 // Duplicate receiver on stack. 1734 // Duplicate receiver on stack.
1724 __ lw(a0, MemOperand(sp)); 1735 __ lw(a0, MemOperand(sp));
1725 __ push(a0); 1736 __ push(a0);
1726 VisitForStackValue(key); 1737 VisitForStackValue(property->key());
1727 VisitForStackValue(value); 1738 VisitForStackValue(value);
1728 if (property->emit_store()) { 1739 if (property->emit_store()) {
1729 __ li(a0, Operand(Smi::FromInt(NONE))); // PropertyAttributes. 1740 __ li(a0, Operand(Smi::FromInt(NONE))); // PropertyAttributes.
1730 __ push(a0); 1741 __ push(a0);
1731 __ CallRuntime(Runtime::kSetProperty, 4); 1742 __ CallRuntime(Runtime::kSetProperty, 4);
1732 } else { 1743 } else {
1733 __ Drop(3); 1744 __ Drop(3);
1734 } 1745 }
1735 break; 1746 break;
1736 case ObjectLiteral::Property::PROTOTYPE: 1747 case ObjectLiteral::Property::PROTOTYPE:
1737 // Duplicate receiver on stack. 1748 // Duplicate receiver on stack.
1738 __ lw(a0, MemOperand(sp)); 1749 __ lw(a0, MemOperand(sp));
1739 __ push(a0); 1750 __ push(a0);
1740 VisitForStackValue(value); 1751 VisitForStackValue(value);
1741 if (property->emit_store()) { 1752 if (property->emit_store()) {
1742 __ CallRuntime(Runtime::kSetPrototype, 2); 1753 __ CallRuntime(Runtime::kSetPrototype, 2);
1743 } else { 1754 } else {
1744 __ Drop(2); 1755 __ Drop(2);
1745 } 1756 }
1746 break; 1757 break;
1747 case ObjectLiteral::Property::GETTER: 1758 case ObjectLiteral::Property::GETTER:
1748 accessor_table.lookup(key)->second->getter = value; 1759 accessor_table.lookup(literal_key)->second->getter = value;
1749 break; 1760 break;
1750 case ObjectLiteral::Property::SETTER: 1761 case ObjectLiteral::Property::SETTER:
1751 accessor_table.lookup(key)->second->setter = value; 1762 accessor_table.lookup(literal_key)->second->setter = value;
1752 break; 1763 break;
1753 } 1764 }
1754 } 1765 }
1755 1766
1756 // Emit code to define accessors, using only a single call to the runtime for 1767 // Emit code to define accessors, using only a single call to the runtime for
1757 // each pair of corresponding getters and setters. 1768 // each pair of corresponding getters and setters.
1758 for (AccessorTable::Iterator it = accessor_table.begin(); 1769 for (AccessorTable::Iterator it = accessor_table.begin();
1759 it != accessor_table.end(); 1770 it != accessor_table.end();
1760 ++it) { 1771 ++it) {
1761 __ lw(a0, MemOperand(sp)); // Duplicate receiver. 1772 __ lw(a0, MemOperand(sp)); // Duplicate receiver.
(...skipping 3100 matching lines...) Expand 10 before | Expand all | Expand 10 after
4862 Assembler::target_address_at(pc_immediate_load_address)) == 4873 Assembler::target_address_at(pc_immediate_load_address)) ==
4863 reinterpret_cast<uint32_t>( 4874 reinterpret_cast<uint32_t>(
4864 isolate->builtins()->OsrAfterStackCheck()->entry())); 4875 isolate->builtins()->OsrAfterStackCheck()->entry()));
4865 return OSR_AFTER_STACK_CHECK; 4876 return OSR_AFTER_STACK_CHECK;
4866 } 4877 }
4867 4878
4868 4879
4869 } } // namespace v8::internal 4880 } } // namespace v8::internal
4870 4881
4871 #endif // V8_TARGET_ARCH_MIPS 4882 #endif // V8_TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698