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

Unified Diff: src/arm/full-codegen-arm.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
« no previous file with comments | « no previous file | src/arm64/full-codegen-arm64.cc » ('j') | test/mjsunit/object-literal-computed-names.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/arm/full-codegen-arm.cc
diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc
index bb4618ae45d68fb35c8ebceb02de8f757b4b0373..b77705f9c71c8755e89579a2785a1e115866c8ac 100644
--- a/src/arm/full-codegen-arm.cc
+++ b/src/arm/full-codegen-arm.cc
@@ -1680,11 +1680,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(r0); // Save result on stack
@@ -1692,27 +1699,31 @@ 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(r2, Operand(key->value()));
+ __ mov(r2, Operand(literal_key->value()));
__ ldr(r1, 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.
__ ldr(r0, MemOperand(sp));
__ push(r0);
- VisitForStackValue(key);
+ VisitForStackValue(property->key());
VisitForStackValue(value);
if (property->emit_store()) {
__ mov(r0, Operand(Smi::FromInt(NONE))); // PropertyAttributes
@@ -1735,10 +1746,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;
}
}
« no previous file with comments | « no previous file | src/arm64/full-codegen-arm64.cc » ('j') | test/mjsunit/object-literal-computed-names.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698