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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: src/mips/full-codegen-mips.cc
diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc
index da4756aed3b2f97bd6b36f004b74b895f4d58c62..bdc6f14f982afa23855aebd4a627f565c08f3463 100644
--- a/src/mips/full-codegen-mips.cc
+++ b/src/mips/full-codegen-mips.cc
@@ -1690,11 +1690,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(v0); // Save result on stack.
@@ -1702,28 +1709,32 @@ 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(property->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(a0, result_register());
- __ li(a2, Operand(key->value()));
+ __ li(a2, Operand(literal_key->value()));
__ lw(a1, MemOperand(sp));
- 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:
// Duplicate receiver on stack.
__ lw(a0, MemOperand(sp));
__ push(a0);
- VisitForStackValue(key);
+ VisitForStackValue(property->key());
VisitForStackValue(value);
if (property->emit_store()) {
__ li(a0, Operand(Smi::FromInt(NONE))); // PropertyAttributes.
@@ -1745,10 +1756,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