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

Unified Diff: src/ast.cc

Issue 1321993004: Vector ICs: ObjectLiteral refactoring for Oracle feedback (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: ObjectLiteral refactorin. Created 5 years, 3 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/ast.cc
diff --git a/src/ast.cc b/src/ast.cc
index 19747d8b767be294e3a819db95f7beb14a3c68b2..558bba064b0ebf7bdbb161e21bf22527cd069938 100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -252,6 +252,8 @@ ObjectLiteralProperty::ObjectLiteralProperty(Expression* key, Expression* value,
: key_(key),
value_(value),
kind_(kind),
+ ic_slot_(FeedbackVectorICSlot::Invalid()),
+ ic_slot_count_(0),
emit_store_(true),
is_static_(is_static),
is_computed_name_(is_computed_name) {}
@@ -263,6 +265,8 @@ ObjectLiteralProperty::ObjectLiteralProperty(AstValueFactory* ast_value_factory,
bool is_computed_name)
: key_(key),
value_(value),
+ ic_slot_(FeedbackVectorICSlot::Invalid()),
+ ic_slot_count_(0),
emit_store_(true),
is_static_(is_static),
is_computed_name_(is_computed_name) {
@@ -287,35 +291,36 @@ FeedbackVectorRequirements ClassLiteral::ComputeFeedbackRequirements(
// This logic that computes the number of slots needed for vector store
// ICs must mirror FullCodeGenerator::VisitClassLiteral.
int ic_slots = 0;
+ if (NeedsProxySlot()) {
+ ic_slots++;
+ }
+
for (int i = 0; i < properties()->length(); i++) {
ObjectLiteral::Property* property = properties()->at(i);
Expression* value = property->value();
- if (FunctionLiteral::NeedsHomeObject(value)) ic_slots++;
- }
-
- if (scope() != NULL && class_variable_proxy()->var()->IsUnallocated()) {
- ic_slots++;
+ if (FunctionLiteral::NeedsHomeObject(value)) {
+ property->set_ic_slot_count(1);
+ ic_slots++;
+ }
}
-#ifdef DEBUG
- // FullCodeGenerator::VisitClassLiteral verifies that it consumes slot_count_
- // slots.
- slot_count_ = ic_slots;
-#endif
return FeedbackVectorRequirements(0, ic_slots);
}
-FeedbackVectorICSlot ClassLiteral::SlotForHomeObject(Expression* value,
- int* slot_index) const {
- if (FLAG_vector_stores && FunctionLiteral::NeedsHomeObject(value)) {
- DCHECK(slot_index != NULL && *slot_index >= 0 && *slot_index < slot_count_);
- FeedbackVectorICSlot slot = GetNthSlot(*slot_index);
- *slot_index += 1;
- return slot;
+void ClassLiteral::LayoutFeedbackSlots() {
+ int base_slot = slot_.ToInt();
+ if (NeedsProxySlot()) base_slot++;
+
+ for (int i = 0; i < properties()->length(); i++) {
+ ObjectLiteral::Property* property = properties()->at(i);
+ int count = property->ic_slot_count();
+ if (count > 0) {
+ property->set_base_slot(base_slot);
+ base_slot += property->ic_slot_count();
+ }
}
- return FeedbackVectorICSlot::Invalid();
}
@@ -336,13 +341,26 @@ bool ObjectLiteral::Property::emit_store() {
}
+void ObjectLiteral::LayoutFeedbackSlots() {
+ int base_slot = slot_.ToInt();
+ for (int i = 0; i < properties()->length(); i++) {
+ ObjectLiteral::Property* property = properties()->at(i);
+ property->set_base_slot(base_slot);
+ int count = property->ic_slot_count();
+ if (count > 0) {
+ property->set_base_slot(base_slot);
+ base_slot += property->ic_slot_count();
+ }
+ }
+}
+
+
FeedbackVectorRequirements ObjectLiteral::ComputeFeedbackRequirements(
Isolate* isolate, const ICSlotCache* cache) {
if (!FLAG_vector_stores) return FeedbackVectorRequirements(0, 0);
// This logic that computes the number of slots needed for vector store
// ics must mirror FullCodeGenerator::VisitObjectLiteral.
- int ic_slots = 0;
bool saw_computed_name = false;
for (int i = 0; i < properties()->length(); i++) {
ObjectLiteral::Property* property = properties()->at(i);
@@ -352,39 +370,35 @@ FeedbackVectorRequirements ObjectLiteral::ComputeFeedbackRequirements(
Expression* value = property->value();
if (saw_computed_name &&
property->kind() != ObjectLiteral::Property::PROTOTYPE) {
- if (FunctionLiteral::NeedsHomeObject(value)) ic_slots++;
+ if (FunctionLiteral::NeedsHomeObject(value)) {
+ property->set_ic_slot_count(1);
+ }
} else if (property->emit_store()) {
if (property->kind() == ObjectLiteral::Property::MATERIALIZED_LITERAL ||
property->kind() == ObjectLiteral::Property::COMPUTED) {
Literal* key = property->key()->AsLiteral();
- if (key->value()->IsInternalizedString()) ic_slots++;
- if (FunctionLiteral::NeedsHomeObject(value)) ic_slots++;
+ int slot_count = 0;
+ if (key->value()->IsInternalizedString()) slot_count++;
+ if (FunctionLiteral::NeedsHomeObject(value)) slot_count++;
+ property->set_ic_slot_count(slot_count);
} else if (property->kind() == ObjectLiteral::Property::GETTER ||
property->kind() == ObjectLiteral::Property::SETTER) {
// We might need a slot for the home object.
- if (FunctionLiteral::NeedsHomeObject(value)) ic_slots++;
+ if (FunctionLiteral::NeedsHomeObject(value)) {
+ property->set_ic_slot_count(1);
+ }
}
}
}
-#ifdef DEBUG
- // FullCodeGenerator::VisitObjectLiteral verifies that it consumes slot_count_
- // slots.
- slot_count_ = ic_slots;
-#endif
- return FeedbackVectorRequirements(0, ic_slots);
-}
-
-
-FeedbackVectorICSlot ObjectLiteral::SlotForHomeObject(Expression* value,
- int* slot_index) const {
- if (FLAG_vector_stores && FunctionLiteral::NeedsHomeObject(value)) {
- DCHECK(slot_index != NULL && *slot_index >= 0 && *slot_index < slot_count_);
- FeedbackVectorICSlot slot = GetNthSlot(*slot_index);
- *slot_index += 1;
- return slot;
+ // How many slots did we allocate?
+ int ic_slots = 0;
+ for (int i = 0; i < properties()->length(); i++) {
+ ObjectLiteral::Property* property = properties()->at(i);
+ ic_slots += property->ic_slot_count();
}
- return FeedbackVectorICSlot::Invalid();
+
+ return FeedbackVectorRequirements(0, ic_slots);
}

Powered by Google App Engine
This is Rietveld 408576698