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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: src/x64/full-codegen-x64.cc
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
index 8de422608bd7bb8334351614a253b8fdd7662f7a..04b6bb727de744ca1c63df5957193a27661243ac 100644
--- a/src/x64/full-codegen-x64.cc
+++ b/src/x64/full-codegen-x64.cc
@@ -1666,11 +1666,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(rax); // Save result on the stack
@@ -1678,25 +1685,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);
- __ Move(rcx, key->value());
+ __ Move(rcx, literal_key->value());
__ movp(rdx, Operand(rsp, 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(rsp, 0)); // Duplicate receiver.
- VisitForStackValue(key);
+ VisitForStackValue(property->key());
VisitForStackValue(value);
if (property->emit_store()) {
__ Push(Smi::FromInt(NONE)); // PropertyAttributes
@@ -1715,10 +1726,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