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

Unified Diff: src/ast.h

Issue 641373002: Introduce FeedbackVectorSlot type - better than int. (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') | no next file with comments »
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 1f227b90b11ff1d628f1a42a8029aa15245d8437..f0dd6fd910f4780a11f002cd830f3ff2befd39e0 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -238,12 +238,11 @@ 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.
- static const int kInvalidFeedbackSlot = -1;
virtual int ComputeFeedbackSlotCount() {
UNREACHABLE();
return 0;
}
- virtual void SetFirstFeedbackSlot(int slot) { UNREACHABLE(); }
+ virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { UNREACHABLE(); }
protected:
// Some nodes re-use bailout IDs for type feedback.
@@ -941,10 +940,12 @@ class ForInStatement FINAL : public ForEachStatement {
// Type feedback information.
virtual int ComputeFeedbackSlotCount() { return 1; }
- virtual void SetFirstFeedbackSlot(int slot) { for_in_feedback_slot_ = slot; }
+ virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) {
+ for_in_feedback_slot_ = slot;
+ }
- int ForInFeedbackSlot() {
- DCHECK(for_in_feedback_slot_ != kInvalidFeedbackSlot);
+ FeedbackVectorSlot ForInFeedbackSlot() {
+ DCHECK(!for_in_feedback_slot_.IsInvalid());
return for_in_feedback_slot_;
}
@@ -962,12 +963,12 @@ class ForInStatement FINAL : public ForEachStatement {
IdGen* id_gen)
: ForEachStatement(zone, labels, pos, id_gen),
for_in_type_(SLOW_FOR_IN),
- for_in_feedback_slot_(kInvalidFeedbackSlot),
+ for_in_feedback_slot_(FeedbackVectorSlot::Invalid()),
body_id_(id_gen->GetNextId()),
prepare_id_(id_gen->GetNextId()) {}
ForInType for_in_type_;
- int for_in_feedback_slot_;
+ FeedbackVectorSlot for_in_feedback_slot_;
const BailoutId body_id_;
const BailoutId prepare_id_;
};
@@ -1672,11 +1673,11 @@ class VariableProxy FINAL : public Expression {
void BindTo(Variable* var);
virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; }
- virtual void SetFirstFeedbackSlot(int slot) {
+ virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) {
variable_feedback_slot_ = slot;
}
- int VariableFeedbackSlot() { return variable_feedback_slot_; }
+ FeedbackVectorSlot VariableFeedbackSlot() { return variable_feedback_slot_; }
protected:
VariableProxy(Zone* zone, Variable* var, int position, IdGen* id_gen);
@@ -1689,7 +1690,7 @@ class VariableProxy FINAL : public Expression {
Variable* var_; // if is_resolved_
};
Interface* interface_;
- int variable_feedback_slot_;
+ FeedbackVectorSlot variable_feedback_slot_;
bool is_this_ : 1;
bool is_assigned_ : 1;
bool is_resolved_ : 1;
@@ -1735,11 +1736,13 @@ class Property FINAL : public Expression {
TypeFeedbackId PropertyFeedbackId() { return reuse(id()); }
virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; }
- virtual void SetFirstFeedbackSlot(int slot) {
+ virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) {
property_feedback_slot_ = slot;
}
- int PropertyFeedbackSlot() const { return property_feedback_slot_; }
+ FeedbackVectorSlot PropertyFeedbackSlot() const {
+ return property_feedback_slot_;
+ }
protected:
Property(Zone* zone, Expression* obj, Expression* key, int pos, IdGen* id_gen)
@@ -1747,7 +1750,7 @@ class Property FINAL : public Expression {
obj_(obj),
key_(key),
load_id_(id_gen->GetNextId()),
- property_feedback_slot_(kInvalidFeedbackSlot),
+ property_feedback_slot_(FeedbackVectorSlot::Invalid()),
is_for_call_(false),
is_uninitialized_(false),
is_string_access_(false) {}
@@ -1756,7 +1759,7 @@ class Property FINAL : public Expression {
Expression* obj_;
Expression* key_;
const BailoutId load_id_;
- int property_feedback_slot_;
+ FeedbackVectorSlot property_feedback_slot_;
SmallMapList receiver_types_;
bool is_for_call_ : 1;
@@ -1774,14 +1777,12 @@ class Call FINAL : public Expression {
// Type feedback information.
virtual int ComputeFeedbackSlotCount() { return 1; }
- virtual void SetFirstFeedbackSlot(int slot) {
+ virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) {
call_feedback_slot_ = slot;
}
- bool HasCallFeedbackSlot() const {
- return call_feedback_slot_ != kInvalidFeedbackSlot;
- }
- int CallFeedbackSlot() const { return call_feedback_slot_; }
+ bool HasCallFeedbackSlot() const { return !call_feedback_slot_.IsInvalid(); }
+ FeedbackVectorSlot CallFeedbackSlot() const { return call_feedback_slot_; }
virtual SmallMapList* GetReceiverTypes() OVERRIDE {
if (expression()->IsProperty()) {
@@ -1844,7 +1845,7 @@ class Call FINAL : public Expression {
: Expression(zone, pos, id_gen),
expression_(expression),
arguments_(arguments),
- call_feedback_slot_(kInvalidFeedbackSlot),
+ call_feedback_slot_(FeedbackVectorSlot::Invalid()),
return_id_(id_gen->GetNextId()),
eval_or_lookup_id_(id_gen->GetNextId()) {
if (expression->IsProperty()) {
@@ -1859,7 +1860,7 @@ class Call FINAL : public Expression {
Handle<JSFunction> target_;
Handle<Cell> cell_;
Handle<AllocationSite> allocation_site_;
- int call_feedback_slot_;
+ FeedbackVectorSlot call_feedback_slot_;
const BailoutId return_id_;
// TODO(jarin) Only allocate the bailout id for the POSSIBLY_EVAL_CALL and
@@ -1879,18 +1880,14 @@ class CallNew FINAL : public Expression {
virtual int ComputeFeedbackSlotCount() {
return FLAG_pretenuring_call_new ? 2 : 1;
}
- virtual void SetFirstFeedbackSlot(int slot) {
+ virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) {
callnew_feedback_slot_ = slot;
}
- int CallNewFeedbackSlot() {
- DCHECK(callnew_feedback_slot_ != kInvalidFeedbackSlot);
- return callnew_feedback_slot_;
- }
- int AllocationSiteFeedbackSlot() {
- DCHECK(callnew_feedback_slot_ != kInvalidFeedbackSlot);
+ FeedbackVectorSlot CallNewFeedbackSlot() { return callnew_feedback_slot_; }
+ FeedbackVectorSlot AllocationSiteFeedbackSlot() {
DCHECK(FLAG_pretenuring_call_new);
- return callnew_feedback_slot_ + 1;
+ return CallNewFeedbackSlot().next();
}
void RecordTypeFeedback(TypeFeedbackOracle* oracle);
@@ -1911,7 +1908,7 @@ class CallNew FINAL : public Expression {
expression_(expression),
arguments_(arguments),
is_monomorphic_(false),
- callnew_feedback_slot_(kInvalidFeedbackSlot),
+ callnew_feedback_slot_(FeedbackVectorSlot::Invalid()),
return_id_(id_gen->GetNextId()) {}
private:
@@ -1921,7 +1918,7 @@ class CallNew FINAL : public Expression {
bool is_monomorphic_;
Handle<JSFunction> target_;
Handle<AllocationSite> allocation_site_;
- int callnew_feedback_slot_;
+ FeedbackVectorSlot callnew_feedback_slot_;
const BailoutId return_id_;
};
@@ -1945,13 +1942,11 @@ class CallRuntime FINAL : public Expression {
virtual int ComputeFeedbackSlotCount() {
return (FLAG_vector_ics && is_jsruntime()) ? 1 : 0;
}
- virtual void SetFirstFeedbackSlot(int slot) {
+ virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) {
callruntime_feedback_slot_ = slot;
}
- int CallRuntimeFeedbackSlot() {
- DCHECK(!is_jsruntime() ||
- callruntime_feedback_slot_ != kInvalidFeedbackSlot);
+ FeedbackVectorSlot CallRuntimeFeedbackSlot() {
return callruntime_feedback_slot_;
}
@@ -1964,13 +1959,14 @@ class CallRuntime FINAL : public Expression {
: Expression(zone, pos, id_gen),
raw_name_(name),
function_(function),
- arguments_(arguments) {}
+ arguments_(arguments),
+ callruntime_feedback_slot_(FeedbackVectorSlot::Invalid()) {}
private:
const AstRawString* raw_name_;
const Runtime::Function* function_;
ZoneList<Expression*>* arguments_;
- int callruntime_feedback_slot_;
+ FeedbackVectorSlot callruntime_feedback_slot_;
};
@@ -2278,24 +2274,19 @@ class Yield FINAL : public Expression {
virtual int ComputeFeedbackSlotCount() {
return (FLAG_vector_ics && yield_kind() == kDelegating) ? 3 : 0;
}
- virtual void SetFirstFeedbackSlot(int slot) {
+ virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) {
yield_first_feedback_slot_ = slot;
}
- int KeyedLoadFeedbackSlot() {
- DCHECK(yield_first_feedback_slot_ != kInvalidFeedbackSlot);
+ FeedbackVectorSlot KeyedLoadFeedbackSlot() {
return yield_first_feedback_slot_;
}
- int DoneFeedbackSlot() {
- DCHECK(yield_first_feedback_slot_ != kInvalidFeedbackSlot);
- return yield_first_feedback_slot_ + 1;
+ FeedbackVectorSlot DoneFeedbackSlot() {
+ return KeyedLoadFeedbackSlot().next();
}
- int ValueFeedbackSlot() {
- DCHECK(yield_first_feedback_slot_ != kInvalidFeedbackSlot);
- return yield_first_feedback_slot_ + 2;
- }
+ FeedbackVectorSlot ValueFeedbackSlot() { return DoneFeedbackSlot().next(); }
protected:
Yield(Zone* zone, Expression* generator_object, Expression* expression,
@@ -2305,14 +2296,14 @@ class Yield FINAL : public Expression {
expression_(expression),
yield_kind_(yield_kind),
index_(-1),
- yield_first_feedback_slot_(kInvalidFeedbackSlot) {}
+ yield_first_feedback_slot_(FeedbackVectorSlot::Invalid()) {}
private:
Expression* generator_object_;
Expression* expression_;
Kind yield_kind_;
int index_;
- int yield_first_feedback_slot_;
+ FeedbackVectorSlot yield_first_feedback_slot_;
};
@@ -2599,13 +2590,12 @@ class SuperReference FINAL : public Expression {
// Type feedback information.
virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; }
- virtual void SetFirstFeedbackSlot(int slot) {
+ virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) {
homeobject_feedback_slot_ = slot;
}
- int HomeObjectFeedbackSlot() {
- DCHECK(!FLAG_vector_ics ||
- homeobject_feedback_slot_ != kInvalidFeedbackSlot);
+ FeedbackVectorSlot HomeObjectFeedbackSlot() {
+ DCHECK(!FLAG_vector_ics || !homeobject_feedback_slot_.IsInvalid());
return homeobject_feedback_slot_;
}
@@ -2613,12 +2603,12 @@ class SuperReference FINAL : public Expression {
SuperReference(Zone* zone, VariableProxy* this_var, int pos, IdGen* id_gen)
: Expression(zone, pos, id_gen),
this_var_(this_var),
- homeobject_feedback_slot_(kInvalidFeedbackSlot) {
+ homeobject_feedback_slot_(FeedbackVectorSlot::Invalid()) {
DCHECK(this_var->is_this());
}
VariableProxy* this_var_;
- int homeobject_feedback_slot_;
+ FeedbackVectorSlot homeobject_feedback_slot_;
};
@@ -3084,7 +3074,8 @@ class AstConstructionVisitor BASE_EMBEDDED {
void add_slot_node(AstNode* slot_node) {
int count = slot_node->ComputeFeedbackSlotCount();
if (count > 0) {
- slot_node->SetFirstFeedbackSlot(properties_.feedback_slots());
+ slot_node->SetFirstFeedbackSlot(
+ FeedbackVectorSlot(properties_.feedback_slots()));
properties_.increase_feedback_slots(count);
}
}
« no previous file with comments | « src/arm64/lithium-codegen-arm64.cc ('k') | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698