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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: src/x87/full-codegen-x87.cc
diff --git a/src/x87/full-codegen-x87.cc b/src/x87/full-codegen-x87.cc
index d5a98865846e1eefc94507abc8cf1ab6469f292c..5ccde53de04aefec4392cacd847447e911982617 100644
--- a/src/x87/full-codegen-x87.cc
+++ b/src/x87/full-codegen-x87.cc
@@ -1626,11 +1626,18 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
expr->CalculateEmitStore(zone());
AccessorTable accessor_table(zone());
+ bool has_seen_computed_name = false;
for (int i = 0; i < expr->properties()->length(); i++) {
ObjectLiteral::Property* property = expr->properties()->at(i);
- if (property->IsCompileTimeValue()) continue;
- Literal* key = property->key();
+ if (!has_seen_computed_name && property->IsCompileTimeValue()) {
+ continue;
+ }
+ if (property->kind() == ObjectLiteral::Property::COMPUTED_NAME) {
+ has_seen_computed_name = true;
+ }
+
+ Literal* literal_key = property->key()->AsLiteral();
Expression* value = property->value();
if (!result_saved) {
__ push(eax); // Save result on the stack
@@ -1638,25 +1645,29 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
}
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
- UNREACHABLE();
+ ASSERT(has_seen_computed_name);
+ // Fall through.
case ObjectLiteral::Property::MATERIALIZED_LITERAL:
- ASSERT(!CompileTimeValue::IsCompileTimeValue(value));
+ ASSERT(has_seen_computed_name ||
+ !CompileTimeValue::IsCompileTimeValue(value));
// Fall through.
case ObjectLiteral::Property::COMPUTED:
- if (key->value()->IsInternalizedString()) {
+ if (literal_key->value()->IsInternalizedString()) {
if (property->emit_store()) {
VisitForAccumulatorValue(value);
- __ mov(ecx, Immediate(key->value()));
+ __ mov(ecx, Immediate(literal_key->value()));
__ mov(edx, Operand(esp, 0));
- CallStoreIC(key->LiteralFeedbackId());
- PrepareForBailoutForId(key->id(), NO_REGISTERS);
+ CallStoreIC(literal_key->LiteralFeedbackId());
+ PrepareForBailoutForId(literal_key->id(), NO_REGISTERS);
} else {
VisitForEffect(value);
}
break;
}
+ // Fall through.
+ case ObjectLiteral::Property::COMPUTED_NAME:
__ push(Operand(esp, 0)); // Duplicate receiver.
- VisitForStackValue(key);
+ VisitForStackValue(property->key());
VisitForStackValue(value);
if (property->emit_store()) {
__ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes
@@ -1675,10 +1686,10 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
}
break;
case ObjectLiteral::Property::GETTER:
- accessor_table.lookup(key)->second->getter = value;
+ accessor_table.lookup(literal_key)->second->getter = value;
break;
case ObjectLiteral::Property::SETTER:
- accessor_table.lookup(key)->second->setter = value;
+ accessor_table.lookup(literal_key)->second->setter = value;
break;
}
}

Powered by Google App Engine
This is Rietveld 408576698