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

Unified Diff: src/ast.cc

Issue 1161623002: VectorICs: allocating slots for store ics in ast nodes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Code comments. Created 5 years, 7 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/ast.h ('k') | src/ast-numbering.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 a73c61382322b4c793dc7c399038b6766e482bfa..a5ac36326969111878ac13887c903aa79bb61b0b 100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -121,16 +121,73 @@ FeedbackVectorRequirements VariableProxy::ComputeFeedbackRequirements(
}
+static int GetStoreICSlots(Expression* expr) {
+ int ic_slots = 0;
+ if (FLAG_vector_stores) {
+ Property* property = expr->AsProperty();
+ LhsKind assign_type = Property::GetAssignType(property);
+ if ((assign_type == VARIABLE &&
+ expr->AsVariableProxy()->var()->IsUnallocated()) ||
+ assign_type == NAMED_PROPERTY || assign_type == KEYED_PROPERTY) {
+ ic_slots++;
+ }
+ }
+ return ic_slots;
+}
+
+
+static Code::Kind GetStoreICKind(Expression* expr) {
+ LhsKind assign_type = Property::GetAssignType(expr->AsProperty());
+ return assign_type == KEYED_PROPERTY ? Code::KEYED_STORE_IC : Code::STORE_IC;
+}
+
+
+FeedbackVectorRequirements ForEachStatement::ComputeFeedbackRequirements(
+ Isolate* isolate, const ICSlotCache* cache) {
+ int ic_slots = GetStoreICSlots(each());
+ return FeedbackVectorRequirements(0, ic_slots);
+}
+
+
+Code::Kind ForEachStatement::FeedbackICSlotKind(int index) {
+ return GetStoreICKind(each());
+}
+
+
Assignment::Assignment(Zone* zone, Token::Value op, Expression* target,
Expression* value, int pos)
: Expression(zone, pos),
- bit_field_(IsUninitializedField::encode(false) |
- KeyTypeField::encode(ELEMENT) |
- StoreModeField::encode(STANDARD_STORE) |
- TokenField::encode(op)),
+ bit_field_(
+ IsUninitializedField::encode(false) | KeyTypeField::encode(ELEMENT) |
+ StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op)),
target_(target),
value_(value),
- binary_operation_(NULL) {}
+ binary_operation_(NULL),
+ slot_(FeedbackVectorICSlot::Invalid()) {}
+
+
+FeedbackVectorRequirements Assignment::ComputeFeedbackRequirements(
+ Isolate* isolate, const ICSlotCache* cache) {
+ int ic_slots = GetStoreICSlots(target());
+ return FeedbackVectorRequirements(0, ic_slots);
+}
+
+
+Code::Kind Assignment::FeedbackICSlotKind(int index) {
+ return GetStoreICKind(target());
+}
+
+
+FeedbackVectorRequirements CountOperation::ComputeFeedbackRequirements(
+ Isolate* isolate, const ICSlotCache* cache) {
+ int ic_slots = GetStoreICSlots(expression());
+ return FeedbackVectorRequirements(0, ic_slots);
+}
+
+
+Code::Kind CountOperation::FeedbackICSlotKind(int index) {
+ return GetStoreICKind(expression());
+}
Token::Value Assignment::binary_op() const {
@@ -253,6 +310,56 @@ bool ObjectLiteral::Property::emit_store() {
}
+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;
+ for (int i = 0; i < properties()->length(); i++) {
+ ObjectLiteral::Property* property = properties()->at(i);
+ if (property->IsCompileTimeValue()) continue;
+
+ Expression* value = property->value();
+ if (property->is_computed_name() &&
+ property->kind() != ObjectLiteral::Property::PROTOTYPE) {
+ if (FunctionLiteral::NeedsHomeObject(value)) ic_slots++;
+ } 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++;
+ } 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++;
+ }
+ }
+ }
+
+#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;
+ }
+ return FeedbackVectorICSlot::Invalid();
+}
+
+
void ObjectLiteral::CalculateEmitStore(Zone* zone) {
const auto GETTER = ObjectLiteral::Property::GETTER;
const auto SETTER = ObjectLiteral::Property::SETTER;
@@ -590,7 +697,10 @@ void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) {
bool Call::IsUsingCallFeedbackICSlot(Isolate* isolate) const {
CallType call_type = GetCallType(isolate);
- if (IsUsingCallFeedbackSlot(isolate) || call_type == POSSIBLY_EVAL_CALL) {
+ if (call_type == POSSIBLY_EVAL_CALL) {
+ return false;
+ }
+ if (call_type == SUPER_CALL && !FLAG_vector_stores) {
return false;
}
return true;
@@ -599,7 +709,7 @@ bool Call::IsUsingCallFeedbackICSlot(Isolate* isolate) const {
bool Call::IsUsingCallFeedbackSlot(Isolate* isolate) const {
// SuperConstructorCall uses a CallConstructStub, which wants
- // a Slot, not an IC slot.
+ // a Slot, in addition to any IC slots requested elsewhere.
return GetCallType(isolate) == SUPER_CALL;
}
@@ -608,8 +718,6 @@ FeedbackVectorRequirements Call::ComputeFeedbackRequirements(
Isolate* isolate, const ICSlotCache* cache) {
int ic_slots = IsUsingCallFeedbackICSlot(isolate) ? 1 : 0;
int slots = IsUsingCallFeedbackSlot(isolate) ? 1 : 0;
- // A Call uses either a slot or an IC slot.
- DCHECK((ic_slots & slots) == 0);
return FeedbackVectorRequirements(slots, ic_slots);
}
« no previous file with comments | « src/ast.h ('k') | src/ast-numbering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698