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

Unified Diff: src/ast.cc

Issue 895693002: Fix issue with multiple properties and emit store. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: git rebase Created 5 years, 10 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 | « src/arm64/full-codegen-arm64.cc ('k') | src/compiler/ast-graph-builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast.cc
diff --git a/src/ast.cc b/src/ast.cc
index 584bf548c56ba9456a8ca9cd4d981406b9098166..057d0d50e6ffd653f3699c6eae02798a9a27ba9a 100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -235,6 +235,9 @@ bool ObjectLiteral::Property::emit_store() {
void ObjectLiteral::CalculateEmitStore(Zone* zone) {
+ const auto GETTER = ObjectLiteral::Property::GETTER;
+ const auto SETTER = ObjectLiteral::Property::SETTER;
+
ZoneAllocationPolicy allocator(zone);
ZoneHashMap table(Literal::Match, ZoneHashMap::kDefaultHashMapCapacity,
@@ -242,19 +245,23 @@ void ObjectLiteral::CalculateEmitStore(Zone* zone) {
for (int i = properties()->length() - 1; i >= 0; i--) {
ObjectLiteral::Property* property = properties()->at(i);
if (property->is_computed_name()) continue;
+ if (property->kind() == ObjectLiteral::Property::PROTOTYPE) continue;
Literal* literal = property->key()->AsLiteral();
- if (literal->value()->IsNull()) continue;
+ DCHECK(!literal->value()->IsNull());
+
+ // If there is an existing entry do not emit a store unless the previous
+ // entry was also an accessor.
uint32_t hash = literal->Hash();
- // If the key of a computed property value is in the table, do not emit
- // a store for the property later.
- if ((property->kind() == ObjectLiteral::Property::MATERIALIZED_LITERAL ||
- property->kind() == ObjectLiteral::Property::COMPUTED) &&
- table.Lookup(literal, hash, false, allocator) != NULL) {
- property->set_emit_store(false);
- } else if (property->kind() != ObjectLiteral::Property::PROTOTYPE) {
- // Add key to the table.
- table.Lookup(literal, hash, true, allocator);
+ ZoneHashMap::Entry* entry = table.Lookup(literal, hash, true, allocator);
+ if (entry->value != NULL) {
+ auto previous_kind =
+ static_cast<ObjectLiteral::Property*>(entry->value)->kind();
+ if (!((property->kind() == GETTER && previous_kind == SETTER) ||
+ (property->kind() == SETTER && previous_kind == GETTER))) {
+ property->set_emit_store(false);
+ }
}
+ entry->value = property;
}
}
« no previous file with comments | « src/arm64/full-codegen-arm64.cc ('k') | src/compiler/ast-graph-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698