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

Side by Side Diff: src/x87/full-codegen-x87.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_X87 7 #if V8_TARGET_ARCH_X87
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 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 // If result_saved is true the result is on top of the stack. If 1619 // If result_saved is true the result is on top of the stack. If
1620 // result_saved is false the result is in eax. 1620 // result_saved is false the result is in eax.
1621 bool result_saved = false; 1621 bool result_saved = false;
1622 1622
1623 // Mark all computed expressions that are bound to a key that 1623 // Mark all computed expressions that are bound to a key that
1624 // is shadowed by a later occurrence of the same key. For the 1624 // is shadowed by a later occurrence of the same key. For the
1625 // marked expressions, no store code is emitted. 1625 // marked expressions, no store code is emitted.
1626 expr->CalculateEmitStore(zone()); 1626 expr->CalculateEmitStore(zone());
1627 1627
1628 AccessorTable accessor_table(zone()); 1628 AccessorTable accessor_table(zone());
1629 bool has_seen_computed_name = false;
1629 for (int i = 0; i < expr->properties()->length(); i++) { 1630 for (int i = 0; i < expr->properties()->length(); i++) {
1630 ObjectLiteral::Property* property = expr->properties()->at(i); 1631 ObjectLiteral::Property* property = expr->properties()->at(i);
1631 if (property->IsCompileTimeValue()) continue;
1632 1632
1633 Literal* key = property->key(); 1633 if (!has_seen_computed_name && property->IsCompileTimeValue()) {
1634 continue;
1635 }
1636 if (property->kind() == ObjectLiteral::Property::COMPUTED_NAME) {
1637 has_seen_computed_name = true;
1638 }
1639
1640 Literal* literal_key = property->key()->AsLiteral();
1634 Expression* value = property->value(); 1641 Expression* value = property->value();
1635 if (!result_saved) { 1642 if (!result_saved) {
1636 __ push(eax); // Save result on the stack 1643 __ push(eax); // Save result on the stack
1637 result_saved = true; 1644 result_saved = true;
1638 } 1645 }
1639 switch (property->kind()) { 1646 switch (property->kind()) {
1640 case ObjectLiteral::Property::CONSTANT: 1647 case ObjectLiteral::Property::CONSTANT:
1641 UNREACHABLE(); 1648 ASSERT(has_seen_computed_name);
1649 // Fall through.
1642 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 1650 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1643 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); 1651 ASSERT(has_seen_computed_name ||
1652 !CompileTimeValue::IsCompileTimeValue(value));
1644 // Fall through. 1653 // Fall through.
1645 case ObjectLiteral::Property::COMPUTED: 1654 case ObjectLiteral::Property::COMPUTED:
1646 if (key->value()->IsInternalizedString()) { 1655 if (literal_key->value()->IsInternalizedString()) {
1647 if (property->emit_store()) { 1656 if (property->emit_store()) {
1648 VisitForAccumulatorValue(value); 1657 VisitForAccumulatorValue(value);
1649 __ mov(ecx, Immediate(key->value())); 1658 __ mov(ecx, Immediate(literal_key->value()));
1650 __ mov(edx, Operand(esp, 0)); 1659 __ mov(edx, Operand(esp, 0));
1651 CallStoreIC(key->LiteralFeedbackId()); 1660 CallStoreIC(literal_key->LiteralFeedbackId());
1652 PrepareForBailoutForId(key->id(), NO_REGISTERS); 1661 PrepareForBailoutForId(literal_key->id(), NO_REGISTERS);
1653 } else { 1662 } else {
1654 VisitForEffect(value); 1663 VisitForEffect(value);
1655 } 1664 }
1656 break; 1665 break;
1657 } 1666 }
1667 // Fall through.
1668 case ObjectLiteral::Property::COMPUTED_NAME:
1658 __ push(Operand(esp, 0)); // Duplicate receiver. 1669 __ push(Operand(esp, 0)); // Duplicate receiver.
1659 VisitForStackValue(key); 1670 VisitForStackValue(property->key());
1660 VisitForStackValue(value); 1671 VisitForStackValue(value);
1661 if (property->emit_store()) { 1672 if (property->emit_store()) {
1662 __ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes 1673 __ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes
1663 __ CallRuntime(Runtime::kSetProperty, 4); 1674 __ CallRuntime(Runtime::kSetProperty, 4);
1664 } else { 1675 } else {
1665 __ Drop(3); 1676 __ Drop(3);
1666 } 1677 }
1667 break; 1678 break;
1668 case ObjectLiteral::Property::PROTOTYPE: 1679 case ObjectLiteral::Property::PROTOTYPE:
1669 __ push(Operand(esp, 0)); // Duplicate receiver. 1680 __ push(Operand(esp, 0)); // Duplicate receiver.
1670 VisitForStackValue(value); 1681 VisitForStackValue(value);
1671 if (property->emit_store()) { 1682 if (property->emit_store()) {
1672 __ CallRuntime(Runtime::kSetPrototype, 2); 1683 __ CallRuntime(Runtime::kSetPrototype, 2);
1673 } else { 1684 } else {
1674 __ Drop(2); 1685 __ Drop(2);
1675 } 1686 }
1676 break; 1687 break;
1677 case ObjectLiteral::Property::GETTER: 1688 case ObjectLiteral::Property::GETTER:
1678 accessor_table.lookup(key)->second->getter = value; 1689 accessor_table.lookup(literal_key)->second->getter = value;
1679 break; 1690 break;
1680 case ObjectLiteral::Property::SETTER: 1691 case ObjectLiteral::Property::SETTER:
1681 accessor_table.lookup(key)->second->setter = value; 1692 accessor_table.lookup(literal_key)->second->setter = value;
1682 break; 1693 break;
1683 } 1694 }
1684 } 1695 }
1685 1696
1686 // Emit code to define accessors, using only a single call to the runtime for 1697 // Emit code to define accessors, using only a single call to the runtime for
1687 // each pair of corresponding getters and setters. 1698 // each pair of corresponding getters and setters.
1688 for (AccessorTable::Iterator it = accessor_table.begin(); 1699 for (AccessorTable::Iterator it = accessor_table.begin();
1689 it != accessor_table.end(); 1700 it != accessor_table.end();
1690 ++it) { 1701 ++it) {
1691 __ push(Operand(esp, 0)); // Duplicate receiver. 1702 __ push(Operand(esp, 0)); // Duplicate receiver.
(...skipping 3104 matching lines...) Expand 10 before | Expand all | Expand 10 after
4796 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4807 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4797 Assembler::target_address_at(call_target_address, 4808 Assembler::target_address_at(call_target_address,
4798 unoptimized_code)); 4809 unoptimized_code));
4799 return OSR_AFTER_STACK_CHECK; 4810 return OSR_AFTER_STACK_CHECK;
4800 } 4811 }
4801 4812
4802 4813
4803 } } // namespace v8::internal 4814 } } // namespace v8::internal
4804 4815
4805 #endif // V8_TARGET_ARCH_X87 4816 #endif // V8_TARGET_ARCH_X87
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698