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/ast.h

Issue 650073002: vector-based ICs did not update type feedback counts correctly. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Ports. Created 6 years, 2 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/lithium-codegen-arm64.cc ('k') | src/ast.cc » ('j') | src/ic/ic.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index 5386d7d0f67556d6a662399f3e8f2676a92c3076..76ad10050031ce5c3138cf532a8153251ed33ec8 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -157,11 +157,25 @@ enum AstPropertiesFlag {
};
+class FeedbackVectorRequirements {
+ public:
+ FeedbackVectorRequirements(int slots, int ic_slots)
+ : slots_(slots), ic_slots_(ic_slots) {}
+
+ int slots() const { return slots_; }
+ int ic_slots() const { return ic_slots_; }
+
+ private:
+ int slots_;
+ int ic_slots_;
+};
+
+
class AstProperties FINAL BASE_EMBEDDED {
public:
class Flags : public EnumSet<AstPropertiesFlag, int> {};
-AstProperties() : node_count_(0), feedback_slots_(0) {}
+ AstProperties() : node_count_(0), feedback_slots_(0), ic_feedback_slots_(0) {}
Flags* flags() { return &flags_; }
int node_count() { return node_count_; }
@@ -172,10 +186,14 @@ AstProperties() : node_count_(0), feedback_slots_(0) {}
feedback_slots_ += count;
}
+ int ic_feedback_slots() const { return ic_feedback_slots_; }
+ void increase_ic_feedback_slots(int count) { ic_feedback_slots_ += count; }
+
private:
Flags flags_;
int node_count_;
int feedback_slots_;
+ int ic_feedback_slots_;
};
@@ -237,11 +255,13 @@ class AstNode: public ZoneObject {
// node types which don't actually have this. Note that this is conceptually
// not really nice, but multiple inheritance would introduce yet another
// vtable entry per node, something we don't want for space reasons.
- virtual int ComputeFeedbackSlotCount() {
- UNREACHABLE();
- return 0;
+ virtual FeedbackVectorRequirements ComputeFeedbackRequirements() {
+ return FeedbackVectorRequirements(0, 0);
}
virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { UNREACHABLE(); }
+ virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) {
+ UNREACHABLE();
+ }
private:
// Hidden to prevent accidental usage. It would have to load the
@@ -947,7 +967,9 @@ class ForInStatement FINAL : public ForEachStatement {
}
// Type feedback information.
- virtual int ComputeFeedbackSlotCount() { return 1; }
+ virtual FeedbackVectorRequirements ComputeFeedbackRequirements() {
+ return FeedbackVectorRequirements(1, 0);
+ }
virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) {
for_in_feedback_slot_ = slot;
}
@@ -1694,12 +1716,16 @@ class VariableProxy FINAL : public Expression {
// Bind this proxy to the variable var. Interfaces must match.
void BindTo(Variable* var);
- virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; }
- virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) {
+ virtual FeedbackVectorRequirements ComputeFeedbackRequirements() {
+ return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0);
+ }
+ virtual void SetFirstICFeedbackSlot(FeedbackVectorICSlot slot) {
variable_feedback_slot_ = slot;
}
- FeedbackVectorSlot VariableFeedbackSlot() { return variable_feedback_slot_; }
+ FeedbackVectorICSlot VariableFeedbackSlot() {
+ return variable_feedback_slot_;
+ }
protected:
VariableProxy(Zone* zone, Variable* var, int position, IdGen* id_gen);
@@ -1712,7 +1738,7 @@ class VariableProxy FINAL : public Expression {
Variable* var_; // if is_resolved_
};
Interface* interface_;
- FeedbackVectorSlot variable_feedback_slot_;
+ FeedbackVectorICSlot variable_feedback_slot_;
bool is_this_ : 1;
bool is_assigned_ : 1;
bool is_resolved_ : 1;
@@ -1757,12 +1783,14 @@ class Property FINAL : public Expression {
return obj()->IsSuperReference();
}
- virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; }
- virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) {
+ virtual FeedbackVectorRequirements ComputeFeedbackRequirements() {
+ return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0);
+ }
+ virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) {
property_feedback_slot_ = slot;
}
- FeedbackVectorSlot PropertyFeedbackSlot() const {
+ FeedbackVectorICSlot PropertyFeedbackSlot() const {
return property_feedback_slot_;
}
@@ -1771,7 +1799,7 @@ class Property FINAL : public Expression {
: Expression(zone, pos, num_ids(), id_gen),
obj_(obj),
key_(key),
- property_feedback_slot_(FeedbackVectorSlot::Invalid()),
+ property_feedback_slot_(FeedbackVectorICSlot::Invalid()),
is_for_call_(false),
is_uninitialized_(false),
is_string_access_(false) {}
@@ -1782,7 +1810,7 @@ class Property FINAL : public Expression {
private:
Expression* obj_;
Expression* key_;
- FeedbackVectorSlot property_feedback_slot_;
+ FeedbackVectorICSlot property_feedback_slot_;
SmallMapList receiver_types_;
bool is_for_call_ : 1;
@@ -1799,13 +1827,15 @@ class Call FINAL : public Expression {
ZoneList<Expression*>* arguments() const { return arguments_; }
// Type feedback information.
- virtual int ComputeFeedbackSlotCount() { return 1; }
- virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) {
+ virtual FeedbackVectorRequirements ComputeFeedbackRequirements() {
+ return FeedbackVectorRequirements(0, 1);
+ }
+ virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) {
call_feedback_slot_ = slot;
}
bool HasCallFeedbackSlot() const { return !call_feedback_slot_.IsInvalid(); }
- FeedbackVectorSlot CallFeedbackSlot() const { return call_feedback_slot_; }
+ FeedbackVectorICSlot CallFeedbackSlot() const { return call_feedback_slot_; }
virtual SmallMapList* GetReceiverTypes() OVERRIDE {
if (expression()->IsProperty()) {
@@ -1868,7 +1898,7 @@ class Call FINAL : public Expression {
: Expression(zone, pos, num_ids(), id_gen),
expression_(expression),
arguments_(arguments),
- call_feedback_slot_(FeedbackVectorSlot::Invalid()) {
+ call_feedback_slot_(FeedbackVectorICSlot::Invalid()) {
if (expression->IsProperty()) {
expression->AsProperty()->mark_for_call();
}
@@ -1883,7 +1913,7 @@ class Call FINAL : public Expression {
Handle<JSFunction> target_;
Handle<Cell> cell_;
Handle<AllocationSite> allocation_site_;
- FeedbackVectorSlot call_feedback_slot_;
+ FeedbackVectorICSlot call_feedback_slot_;
};
@@ -1895,8 +1925,8 @@ class CallNew FINAL : public Expression {
ZoneList<Expression*>* arguments() const { return arguments_; }
// Type feedback information.
- virtual int ComputeFeedbackSlotCount() {
- return FLAG_pretenuring_call_new ? 2 : 1;
+ virtual FeedbackVectorRequirements ComputeFeedbackRequirements() {
+ return FeedbackVectorRequirements(FLAG_pretenuring_call_new ? 2 : 1, 0);
}
virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) {
callnew_feedback_slot_ = slot;
@@ -1956,14 +1986,15 @@ class CallRuntime FINAL : public Expression {
bool is_jsruntime() const { return function_ == NULL; }
// Type feedback information.
- virtual int ComputeFeedbackSlotCount() {
- return (FLAG_vector_ics && is_jsruntime()) ? 1 : 0;
+ virtual FeedbackVectorRequirements ComputeFeedbackRequirements() {
+ return FeedbackVectorRequirements(
+ 0, (FLAG_vector_ics && is_jsruntime()) ? 1 : 0);
}
- virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) {
+ virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) {
callruntime_feedback_slot_ = slot;
}
- FeedbackVectorSlot CallRuntimeFeedbackSlot() {
+ FeedbackVectorICSlot CallRuntimeFeedbackSlot() {
return callruntime_feedback_slot_;
}
@@ -1979,7 +2010,7 @@ class CallRuntime FINAL : public Expression {
raw_name_(name),
function_(function),
arguments_(arguments),
- callruntime_feedback_slot_(FeedbackVectorSlot::Invalid()) {}
+ callruntime_feedback_slot_(FeedbackVectorICSlot::Invalid()) {}
static int num_ids() { return 1; }
int base_id() const { return Expression::base_id() + Expression::num_ids(); }
@@ -1988,7 +2019,7 @@ class CallRuntime FINAL : public Expression {
const AstRawString* raw_name_;
const Runtime::Function* function_;
ZoneList<Expression*>* arguments_;
- FeedbackVectorSlot callruntime_feedback_slot_;
+ FeedbackVectorICSlot callruntime_feedback_slot_;
};
@@ -2301,22 +2332,23 @@ class Yield FINAL : public Expression {
}
// Type feedback information.
- virtual int ComputeFeedbackSlotCount() {
- return (FLAG_vector_ics && yield_kind() == kDelegating) ? 3 : 0;
+ virtual FeedbackVectorRequirements ComputeFeedbackRequirements() {
+ return FeedbackVectorRequirements(
+ 0, (FLAG_vector_ics && yield_kind() == kDelegating) ? 3 : 0);
}
- virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) {
+ virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) {
yield_first_feedback_slot_ = slot;
}
- FeedbackVectorSlot KeyedLoadFeedbackSlot() {
+ FeedbackVectorICSlot KeyedLoadFeedbackSlot() {
return yield_first_feedback_slot_;
}
- FeedbackVectorSlot DoneFeedbackSlot() {
+ FeedbackVectorICSlot DoneFeedbackSlot() {
return KeyedLoadFeedbackSlot().next();
}
- FeedbackVectorSlot ValueFeedbackSlot() { return DoneFeedbackSlot().next(); }
+ FeedbackVectorICSlot ValueFeedbackSlot() { return DoneFeedbackSlot().next(); }
protected:
Yield(Zone* zone, Expression* generator_object, Expression* expression,
@@ -2326,14 +2358,14 @@ class Yield FINAL : public Expression {
expression_(expression),
yield_kind_(yield_kind),
index_(-1),
- yield_first_feedback_slot_(FeedbackVectorSlot::Invalid()) {}
+ yield_first_feedback_slot_(FeedbackVectorICSlot::Invalid()) {}
private:
Expression* generator_object_;
Expression* expression_;
Kind yield_kind_;
int index_;
- FeedbackVectorSlot yield_first_feedback_slot_;
+ FeedbackVectorICSlot yield_first_feedback_slot_;
};
@@ -2483,6 +2515,7 @@ class FunctionLiteral FINAL : public Expression {
int slot_count() {
return ast_properties_.feedback_slots();
}
+ int ic_slot_count() { return ast_properties_.ic_feedback_slots(); }
bool dont_optimize() { return dont_optimize_reason_ != kNoReason; }
BailoutReason dont_optimize_reason() { return dont_optimize_reason_; }
void set_dont_optimize_reason(BailoutReason reason) {
@@ -2621,12 +2654,14 @@ class SuperReference FINAL : public Expression {
}
// Type feedback information.
- virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; }
- virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) {
+ virtual FeedbackVectorRequirements ComputeFeedbackRequirements() {
+ return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0);
+ }
+ virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) {
homeobject_feedback_slot_ = slot;
}
- FeedbackVectorSlot HomeObjectFeedbackSlot() {
+ FeedbackVectorICSlot HomeObjectFeedbackSlot() {
DCHECK(!FLAG_vector_ics || !homeobject_feedback_slot_.IsInvalid());
return homeobject_feedback_slot_;
}
@@ -2635,7 +2670,7 @@ class SuperReference FINAL : public Expression {
SuperReference(Zone* zone, VariableProxy* this_var, int pos, IdGen* id_gen)
: Expression(zone, pos, num_ids(), id_gen),
this_var_(this_var),
- homeobject_feedback_slot_(FeedbackVectorSlot::Invalid()) {
+ homeobject_feedback_slot_(FeedbackVectorICSlot::Invalid()) {
DCHECK(this_var->is_this());
}
@@ -2644,7 +2679,7 @@ class SuperReference FINAL : public Expression {
private:
VariableProxy* this_var_;
- FeedbackVectorSlot homeobject_feedback_slot_;
+ FeedbackVectorICSlot homeobject_feedback_slot_;
};
@@ -3108,11 +3143,16 @@ class AstConstructionVisitor BASE_EMBEDDED {
}
void add_slot_node(AstNode* slot_node) {
- int count = slot_node->ComputeFeedbackSlotCount();
- if (count > 0) {
+ FeedbackVectorRequirements reqs = slot_node->ComputeFeedbackRequirements();
+ if (reqs.slots() > 0) {
slot_node->SetFirstFeedbackSlot(
FeedbackVectorSlot(properties_.feedback_slots()));
- properties_.increase_feedback_slots(count);
+ properties_.increase_feedback_slots(reqs.slots());
+ }
+ if (reqs.ic_slots() > 0) {
+ slot_node->SetFirstFeedbackICSlot(
+ FeedbackVectorICSlot(properties_.ic_feedback_slots()));
+ properties_.increase_ic_feedback_slots(reqs.ic_slots());
}
}
« no previous file with comments | « src/arm64/lithium-codegen-arm64.cc ('k') | src/ast.cc » ('j') | src/ic/ic.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698