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

Unified Diff: src/arm64/full-codegen-arm64.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/arm64/full-codegen-arm64.cc
diff --git a/src/arm64/full-codegen-arm64.cc b/src/arm64/full-codegen-arm64.cc
index ba3b5d086e6a515f24d7c8e012707dcd181eb9ea..80051e1f0baab56f2b8b13471abd3e4fda1fbed9 100644
--- a/src/arm64/full-codegen-arm64.cc
+++ b/src/arm64/full-codegen-arm64.cc
@@ -1681,11 +1681,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(x0); // Save result on stack
@@ -1693,34 +1700,38 @@ 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(x2, Operand(key->value()));
+ __ Mov(x2, Operand(literal_key->value()));
__ Peek(x1, 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:
if (property->emit_store()) {
// Duplicate receiver on stack.
__ Peek(x0, 0);
__ Push(x0);
- VisitForStackValue(key);
+ VisitForStackValue(property->key());
VisitForStackValue(value);
__ Mov(x0, Smi::FromInt(NONE)); // PropertyAttributes
__ Push(x0);
__ CallRuntime(Runtime::kSetProperty, 4);
} else {
- VisitForEffect(key);
+ VisitForEffect(property->key());
VisitForEffect(value);
}
break;
@@ -1736,10 +1747,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