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

Unified Diff: src/ast.h

Issue 569573002: Remove redundant ids from AST (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Cleaner structure for reserving ids in AST Created 6 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
« no previous file with comments | « no previous file | 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 c5a924c43d914f10246f7b8513a0cb0417dfae01..36b1e8a8ab007f4164f8b41e15a134fc8eaae381 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -149,6 +149,22 @@ typedef ZoneList<Handle<Object> > ZoneObjectList;
} \
template<class> friend class AstNodeFactory;
+#define RESERVE_ID_RANGE() \
+ id_gen->ReserveIdRange(kClassIdRange)
+
+#define NEXT_ID(SUPER) \
+ this->SUPER::NextId()
+
+#define NEXT_ID_FUNC(ID) \
+ int NextId() const { \
+ return ID.ToInt() + kClassIdRange; \
+ }
+
+#define NEXT_ID_FUNC_BASE(SUPER) \
+ int NextId() const { \
+ return this->SUPER::NextId() + kClassIdRange; \
+ }
+
enum AstPropertiesFlag {
kDontSelfOptimize,
@@ -186,7 +202,6 @@ class AstNode: public ZoneObject {
public:
explicit IdGen(int id = 0) : id_(id) {}
- int GetNextId() { return ReserveIdRange(1); }
int ReserveIdRange(int n) {
int tmp = id_;
id_ += n;
@@ -375,24 +390,26 @@ class Expression : public AstNode {
byte to_boolean_types() const { return to_boolean_types_; }
BailoutId id() const { return id_; }
- TypeFeedbackId test_id() const { return test_id_; }
+ TypeFeedbackId test_id() const { return TypeFeedbackId(id_.ToInt() + 1); }
protected:
Expression(Zone* zone, int pos, IdGen* id_gen)
: AstNode(pos),
bounds_(Bounds::Unbounded(zone)),
parenthesization_level_(0),
- id_(id_gen->GetNextId()),
- test_id_(id_gen->GetNextId()) {}
+ id_(RESERVE_ID_RANGE()) {}
+
void set_to_boolean_types(byte types) { to_boolean_types_ = types; }
+ NEXT_ID_FUNC(id_);
+
private:
Bounds bounds_;
byte to_boolean_types_;
unsigned parenthesization_level_;
const BailoutId id_;
- const TypeFeedbackId test_id_;
+ static const int kClassIdRange = 2; // id and test id
};
@@ -421,7 +438,7 @@ class BreakableStatement : public Statement {
}
BailoutId EntryId() const { return entry_id_; }
- BailoutId ExitId() const { return exit_id_; }
+ BailoutId ExitId() const { return BailoutId(entry_id_.ToInt() + 1); }
protected:
BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels,
@@ -429,18 +446,19 @@ class BreakableStatement : public Statement {
: Statement(zone, position),
labels_(labels),
breakable_type_(breakable_type),
- entry_id_(id_gen->GetNextId()),
- exit_id_(id_gen->GetNextId()) {
+ entry_id_(RESERVE_ID_RANGE()) {
DCHECK(labels == NULL || labels->length() > 0);
}
+ NEXT_ID_FUNC(entry_id_);
private:
ZoneList<const AstRawString*>* labels_;
BreakableType breakable_type_;
Label break_target_;
+
const BailoutId entry_id_;
- const BailoutId exit_id_;
+ static const int kClassIdRange = 2; // Entry and exit ids
};
@@ -455,7 +473,7 @@ class Block FINAL : public BreakableStatement {
ZoneList<Statement*>* statements() { return &statements_; }
bool is_initializer_block() const { return is_initializer_block_; }
- BailoutId DeclsId() const { return decls_id_; }
+ BailoutId DeclsId() const { return BailoutId(NEXT_ID(BreakableStatement)); }
virtual bool IsJump() const OVERRIDE {
return !statements_.is_empty() && statements_.last()->IsJump()
@@ -471,14 +489,22 @@ class Block FINAL : public BreakableStatement {
: BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos, id_gen),
statements_(capacity, zone),
is_initializer_block_(is_initializer_block),
- decls_id_(id_gen->GetNextId()),
- scope_(NULL) {}
+ scope_(NULL) {
+#ifdef DEBUG
+ int decls_id =
+#endif
+ RESERVE_ID_RANGE();
+ DCHECK(decls_id == DeclsId().ToInt());
+ }
+
+ NEXT_ID_FUNC_BASE(BreakableStatement)
private:
ZoneList<Statement*> statements_;
bool is_initializer_block_;
- const BailoutId decls_id_;
Scope* scope_;
+
+ static const int kClassIdRange = 1; // decls id
};
@@ -729,7 +755,9 @@ class IterationStatement : public BreakableStatement {
Statement* body() const { return body_; }
- BailoutId OsrEntryId() const { return osr_entry_id_; }
+ BailoutId OsrEntryId() const {
+ return BailoutId(NEXT_ID(BreakableStatement));
+ }
virtual BailoutId ContinueId() const = 0;
virtual BailoutId StackCheckId() const = 0;
@@ -740,18 +768,25 @@ class IterationStatement : public BreakableStatement {
IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
IdGen* id_gen)
: BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, id_gen),
- body_(NULL),
- osr_entry_id_(id_gen->GetNextId()) {}
+ body_(NULL) {
+#ifdef DEBUG
+ int osr_entry_id =
+#endif
+ RESERVE_ID_RANGE();
+ DCHECK(osr_entry_id == OsrEntryId().ToInt());
+ }
void Initialize(Statement* body) {
body_ = body;
}
+ NEXT_ID_FUNC_BASE(BreakableStatement);
+
private:
Statement* body_;
Label continue_target_;
- const BailoutId osr_entry_id_;
+ static const int kClassIdRange = 1; // Osr entry id
};
@@ -766,23 +801,32 @@ class DoWhileStatement FINAL : public IterationStatement {
Expression* cond() const { return cond_; }
- virtual BailoutId ContinueId() const OVERRIDE { return continue_id_; }
- virtual BailoutId StackCheckId() const OVERRIDE { return back_edge_id_; }
- BailoutId BackEdgeId() const { return back_edge_id_; }
+ virtual BailoutId ContinueId() const OVERRIDE {
+ return BailoutId(NEXT_ID(IterationStatement));
+ }
+ virtual BailoutId StackCheckId() const OVERRIDE {
+ return BailoutId(NEXT_ID(IterationStatement) + 1);
+ }
+ BailoutId BackEdgeId() const {
+ return BailoutId(NEXT_ID(IterationStatement) + 1);
+ }
protected:
DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
IdGen* id_gen)
: IterationStatement(zone, labels, pos, id_gen),
- cond_(NULL),
- continue_id_(id_gen->GetNextId()),
- back_edge_id_(id_gen->GetNextId()) {}
+ cond_(NULL) {
+#ifdef DEBUG
+ int continue_id =
+#endif
+ RESERVE_ID_RANGE();
+ DCHECK(continue_id == ContinueId().ToInt());
+ }
private:
Expression* cond_;
- const BailoutId continue_id_;
- const BailoutId back_edge_id_;
+ static const int kClassIdRange = 2; // Continue and back edge ids
};
@@ -804,16 +848,23 @@ class WhileStatement FINAL : public IterationStatement {
}
virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); }
- virtual BailoutId StackCheckId() const OVERRIDE { return body_id_; }
- BailoutId BodyId() const { return body_id_; }
+ virtual BailoutId StackCheckId() const OVERRIDE {
+ return BailoutId(NEXT_ID(IterationStatement));
+ }
+ BailoutId BodyId() const { return BailoutId(NEXT_ID(IterationStatement)); }
protected:
WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
IdGen* id_gen)
: IterationStatement(zone, labels, pos, id_gen),
cond_(NULL),
- may_have_function_literal_(true),
- body_id_(id_gen->GetNextId()) {}
+ may_have_function_literal_(true) {
+#ifdef DEBUG
+ int body_id =
+#endif
+ RESERVE_ID_RANGE();
+ DCHECK(body_id == BodyId().ToInt());
+ }
private:
Expression* cond_;
@@ -821,7 +872,7 @@ class WhileStatement FINAL : public IterationStatement {
// True if there is a function literal subexpression in the condition.
bool may_have_function_literal_;
- const BailoutId body_id_;
+ static const int kClassIdRange = 1; // Body id
};
@@ -850,9 +901,15 @@ class ForStatement FINAL : public IterationStatement {
may_have_function_literal_ = value;
}
- virtual BailoutId ContinueId() const OVERRIDE { return continue_id_; }
- virtual BailoutId StackCheckId() const OVERRIDE { return body_id_; }
- BailoutId BodyId() const { return body_id_; }
+ virtual BailoutId ContinueId() const OVERRIDE {
+ return BailoutId(NEXT_ID(IterationStatement));
+ }
+ virtual BailoutId StackCheckId() const OVERRIDE {
+ return BailoutId(NEXT_ID(IterationStatement) + 1);
+ }
+ BailoutId BodyId() const {
+ return BailoutId(NEXT_ID(IterationStatement) + 1);
+ }
bool is_fast_smi_loop() { return loop_variable_ != NULL; }
Variable* loop_variable() { return loop_variable_; }
@@ -866,9 +923,13 @@ class ForStatement FINAL : public IterationStatement {
cond_(NULL),
next_(NULL),
may_have_function_literal_(true),
- loop_variable_(NULL),
- continue_id_(id_gen->GetNextId()),
- body_id_(id_gen->GetNextId()) {}
+ loop_variable_(NULL) {
+#ifdef DEBUG
+ int continue_id =
+#endif
+ RESERVE_ID_RANGE();
+ DCHECK(continue_id == ContinueId().ToInt());
+ }
private:
Statement* init_;
@@ -879,8 +940,7 @@ class ForStatement FINAL : public IterationStatement {
bool may_have_function_literal_;
Variable* loop_variable_;
- const BailoutId continue_id_;
- const BailoutId body_id_;
+ static const int kClassIdRange = 2; // Continue and body ids
};
@@ -907,9 +967,13 @@ class ForEachStatement : public IterationStatement {
each_(NULL),
subject_(NULL) {}
+ NEXT_ID_FUNC_BASE(IterationStatement)
+
private:
Expression* each_;
Expression* subject_;
+
+ static const int kClassIdRange = 0; // No ids
};
@@ -935,24 +999,31 @@ class ForInStatement FINAL : public ForEachStatement,
ForInType for_in_type() const { return for_in_type_; }
void set_for_in_type(ForInType type) { for_in_type_ = type; }
- BailoutId BodyId() const { return body_id_; }
- BailoutId PrepareId() const { return prepare_id_; }
+ BailoutId BodyId() const { return BailoutId(NEXT_ID(ForEachStatement)); }
+ BailoutId PrepareId() const {
+ return BailoutId(NEXT_ID(ForEachStatement) + 1);
+ }
virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); }
- virtual BailoutId StackCheckId() const OVERRIDE { return body_id_; }
+ virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); }
protected:
ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
IdGen* id_gen)
: ForEachStatement(zone, labels, pos, id_gen),
for_in_type_(SLOW_FOR_IN),
- for_in_feedback_slot_(kInvalidFeedbackSlot),
- body_id_(id_gen->GetNextId()),
- prepare_id_(id_gen->GetNextId()) {}
+ for_in_feedback_slot_(kInvalidFeedbackSlot) {
+#ifdef DEBUG
+ int body_id =
+#endif
+ RESERVE_ID_RANGE();
+ DCHECK(body_id == BodyId().ToInt());
+ }
ForInType for_in_type_;
int for_in_feedback_slot_;
- const BailoutId body_id_;
- const BailoutId prepare_id_;
+
+ private:
+ static const int kClassIdRange = 2; // Body and prepare ids
};
@@ -1001,7 +1072,7 @@ class ForOfStatement FINAL : public ForEachStatement {
virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); }
virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); }
- BailoutId BackEdgeId() const { return back_edge_id_; }
+ BailoutId BackEdgeId() const { return BailoutId(NEXT_ID(ForEachStatement)); }
protected:
ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
@@ -1010,14 +1081,21 @@ class ForOfStatement FINAL : public ForEachStatement {
assign_iterator_(NULL),
next_result_(NULL),
result_done_(NULL),
- assign_each_(NULL),
- back_edge_id_(id_gen->GetNextId()) {}
+ assign_each_(NULL) {
+#ifdef DEBUG
+ int back_edge_id =
+#endif
+ RESERVE_ID_RANGE();
+ DCHECK(back_edge_id == BackEdgeId().ToInt());
+ }
Expression* assign_iterator_;
Expression* next_result_;
Expression* result_done_;
Expression* assign_each_;
- const BailoutId back_edge_id_;
+
+ private:
+ static const int kClassIdRange = 1; // Back edge id
};
@@ -1128,10 +1206,10 @@ class CaseClause FINAL : public Expression {
Label* body_target() { return &body_target_; }
ZoneList<Statement*>* statements() const { return statements_; }
- BailoutId EntryId() const { return entry_id_; }
+ BailoutId EntryId() const { return BailoutId(NEXT_ID(Expression) + 1); }
// Type feedback information.
- TypeFeedbackId CompareId() { return compare_id_; }
+ TypeFeedbackId CompareId() { return TypeFeedbackId(NEXT_ID(Expression)); }
Type* compare_type() { return compare_type_; }
void set_compare_type(Type* type) { compare_type_ = type; }
@@ -1144,8 +1222,7 @@ class CaseClause FINAL : public Expression {
ZoneList<Statement*>* statements_;
Type* compare_type_;
- const TypeFeedbackId compare_id_;
- const BailoutId entry_id_;
+ static const int kClassIdRange = 2; // Compare and entry ids
};
@@ -1196,8 +1273,8 @@ class IfStatement FINAL : public Statement {
}
BailoutId IfId() const { return if_id_; }
- BailoutId ThenId() const { return then_id_; }
- BailoutId ElseId() const { return else_id_; }
+ BailoutId ThenId() const { return BailoutId(if_id_.ToInt() + 1); }
+ BailoutId ElseId() const { return BailoutId(if_id_.ToInt() + 2); }
protected:
IfStatement(Zone* zone, Expression* condition, Statement* then_statement,
@@ -1206,17 +1283,15 @@ class IfStatement FINAL : public Statement {
condition_(condition),
then_statement_(then_statement),
else_statement_(else_statement),
- if_id_(id_gen->GetNextId()),
- then_id_(id_gen->GetNextId()),
- else_id_(id_gen->GetNextId()) {}
+ if_id_(RESERVE_ID_RANGE()) {}
private:
Expression* condition_;
Statement* then_statement_;
Statement* else_statement_;
const BailoutId if_id_;
- const BailoutId then_id_;
- const BailoutId else_id_;
+
+ static const int kClassIdRange = 3; // If, then, else ids
};
@@ -1324,7 +1399,7 @@ class DebuggerStatement FINAL : public Statement {
protected:
explicit DebuggerStatement(Zone* zone, int pos, IdGen* id_gen)
- : Statement(zone, pos), debugger_id_(id_gen->GetNextId()) {}
+ : Statement(zone, pos), debugger_id_(id_gen->ReserveIdRange(1)) {}
private:
const BailoutId debugger_id_;
@@ -1678,7 +1753,7 @@ class Property FINAL : public Expression, public FeedbackSlotInterface {
Expression* obj() const { return obj_; }
Expression* key() const { return key_; }
- BailoutId LoadId() const { return load_id_; }
+ BailoutId LoadId() const { return BailoutId(NEXT_ID(Expression)); }
bool IsStringAccess() const { return is_string_access_; }
@@ -1719,22 +1794,28 @@ class Property FINAL : public Expression, public FeedbackSlotInterface {
: Expression(zone, pos, id_gen),
obj_(obj),
key_(key),
- load_id_(id_gen->GetNextId()),
property_feedback_slot_(kInvalidFeedbackSlot),
is_for_call_(false),
is_uninitialized_(false),
- is_string_access_(false) {}
+ is_string_access_(false) {
+#ifdef DEBUG
+ int load_id =
+#endif
+ RESERVE_ID_RANGE();
+ DCHECK(load_id == LoadId().ToInt());
+ }
private:
Expression* obj_;
Expression* key_;
- const BailoutId load_id_;
int property_feedback_slot_;
SmallMapList receiver_types_;
bool is_for_call_ : 1;
bool is_uninitialized_ : 1;
bool is_string_access_ : 1;
+
+ static const int kClassIdRange = 1; // Load id
};
@@ -1791,7 +1872,7 @@ class Call FINAL : public Expression, public FeedbackSlotInterface {
}
bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupIterator* it);
- BailoutId ReturnId() const { return return_id_; }
+ BailoutId ReturnId() const { return BailoutId(NEXT_ID(Expression)); }
enum CallType {
POSSIBLY_EVAL_CALL,
@@ -1816,8 +1897,12 @@ class Call FINAL : public Expression, public FeedbackSlotInterface {
: Expression(zone, pos, id_gen),
expression_(expression),
arguments_(arguments),
- call_feedback_slot_(kInvalidFeedbackSlot),
- return_id_(id_gen->GetNextId()) {
+ call_feedback_slot_(kInvalidFeedbackSlot) {
+#ifdef DEBUG
+ int return_id =
+#endif
+ RESERVE_ID_RANGE();
+ DCHECK(return_id == ReturnId().ToInt());
if (expression->IsProperty()) {
expression->AsProperty()->mark_for_call();
}
@@ -1832,7 +1917,7 @@ class Call FINAL : public Expression, public FeedbackSlotInterface {
Handle<AllocationSite> allocation_site_;
int call_feedback_slot_;
- const BailoutId return_id_;
+ static const int kClassIdRange = 1; // Return id
};
@@ -1871,7 +1956,7 @@ class CallNew FINAL : public Expression, public FeedbackSlotInterface {
static int feedback_slots() { return 1; }
- BailoutId ReturnId() const { return return_id_; }
+ BailoutId ReturnId() const { return BailoutId(NEXT_ID(Expression)); }
protected:
CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments,
@@ -1881,8 +1966,13 @@ class CallNew FINAL : public Expression, public FeedbackSlotInterface {
arguments_(arguments),
is_monomorphic_(false),
elements_kind_(GetInitialFastElementsKind()),
- callnew_feedback_slot_(kInvalidFeedbackSlot),
- return_id_(id_gen->GetNextId()) {}
+ callnew_feedback_slot_(kInvalidFeedbackSlot) {
+#ifdef DEBUG
+ int return_id =
+#endif
+ RESERVE_ID_RANGE();
+ DCHECK(return_id = ReturnId().ToInt());
+ }
private:
Expression* expression_;
@@ -1894,7 +1984,7 @@ class CallNew FINAL : public Expression, public FeedbackSlotInterface {
Handle<AllocationSite> allocation_site_;
int callnew_feedback_slot_;
- const BailoutId return_id_;
+ static const int kClassIdRange = 1; // Return id
};
@@ -1952,8 +2042,10 @@ class UnaryOperation FINAL : public Expression {
Token::Value op() const { return op_; }
Expression* expression() const { return expression_; }
- BailoutId MaterializeTrueId() { return materialize_true_id_; }
- BailoutId MaterializeFalseId() { return materialize_false_id_; }
+ // For unary not (Token::NOT), the AST ids where true and false will
+ // actually be materialized, respectively.
+ BailoutId MaterializeTrueId() { return BailoutId(NEXT_ID(Expression)); }
+ BailoutId MaterializeFalseId() { return BailoutId(NEXT_ID(Expression) + 1); }
virtual void RecordToBooleanTypeFeedback(
TypeFeedbackOracle* oracle) OVERRIDE;
@@ -1963,9 +2055,12 @@ class UnaryOperation FINAL : public Expression {
IdGen* id_gen)
: Expression(zone, pos, id_gen),
op_(op),
- expression_(expression),
- materialize_true_id_(id_gen->GetNextId()),
- materialize_false_id_(id_gen->GetNextId()) {
+ expression_(expression) {
+#ifdef DEBUG
+ int materialize_true_id =
+#endif
+ RESERVE_ID_RANGE();
+ DCHECK(materialize_true_id == MaterializeTrueId().ToInt());
DCHECK(Token::IsUnaryOp(op));
}
@@ -1973,10 +2068,7 @@ class UnaryOperation FINAL : public Expression {
Token::Value op_;
Expression* expression_;
- // For unary not (Token::NOT), the AST ids where true and false will
- // actually be materialized, respectively.
- const BailoutId materialize_true_id_;
- const BailoutId materialize_false_id_;
+ static const int kClassIdRange = 2; // Materialize true and false ids
};
@@ -1994,7 +2086,9 @@ class BinaryOperation FINAL : public Expression {
allocation_site_ = allocation_site;
}
- BailoutId RightId() const { return right_id_; }
+ // The short-circuit logical operations need an AST ID for their
+ // right-hand subexpression.
+ BailoutId RightId() const { return BailoutId(NEXT_ID(Expression)); }
TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); }
Maybe<int> fixed_right_arg() const { return fixed_right_arg_; }
@@ -2009,8 +2103,12 @@ class BinaryOperation FINAL : public Expression {
: Expression(zone, pos, id_gen),
op_(op),
left_(left),
- right_(right),
- right_id_(id_gen->GetNextId()) {
+ right_(right) {
+#ifdef DEBUG
+ int right_id =
+#endif
+ RESERVE_ID_RANGE();
+ DCHECK(right_id == RightId().ToInt());
DCHECK(Token::IsBinaryOp(op));
}
@@ -2024,9 +2122,7 @@ class BinaryOperation FINAL : public Expression {
// type for the RHS.
Maybe<int> fixed_right_arg_;
- // The short-circuit logical operations need an AST ID for their
- // right-hand subexpression.
- const BailoutId right_id_;
+ static const int kClassIdRange = 1; // Right id
};
@@ -2057,9 +2153,11 @@ class CountOperation FINAL : public Expression {
void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; }
void set_type(Type* type) { type_ = type; }
- BailoutId AssignmentId() const { return assignment_id_; }
+ BailoutId AssignmentId() const { return BailoutId(NEXT_ID(Expression)); }
- TypeFeedbackId CountBinOpFeedbackId() const { return count_id_; }
+ TypeFeedbackId CountBinOpFeedbackId() const {
+ return TypeFeedbackId(NEXT_ID(Expression) + 1);
+ }
TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); }
protected:
@@ -2069,9 +2167,13 @@ class CountOperation FINAL : public Expression {
op_(op),
is_prefix_(is_prefix),
store_mode_(STANDARD_STORE),
- expression_(expr),
- assignment_id_(id_gen->GetNextId()),
- count_id_(id_gen->GetNextId()) {}
+ expression_(expr) {
+#ifdef DEBUG
+ int assignment_id =
+#endif
+ RESERVE_ID_RANGE();
+ DCHECK(assignment_id == AssignmentId().ToInt());
+ }
private:
Token::Value op_;
@@ -2081,9 +2183,9 @@ class CountOperation FINAL : public Expression {
Type* type_;
Expression* expression_;
- const BailoutId assignment_id_;
- const TypeFeedbackId count_id_;
SmallMapList receiver_types_;
+
+ static const int kClassIdRange = 2; // Assignment and count ids
};
@@ -2133,8 +2235,8 @@ class Conditional FINAL : public Expression {
Expression* then_expression() const { return then_expression_; }
Expression* else_expression() const { return else_expression_; }
- BailoutId ThenId() const { return then_id_; }
- BailoutId ElseId() const { return else_id_; }
+ BailoutId ThenId() const { return BailoutId(NEXT_ID(Expression)); }
+ BailoutId ElseId() const { return BailoutId(NEXT_ID(Expression) + 1); }
protected:
Conditional(Zone* zone, Expression* condition, Expression* then_expression,
@@ -2142,16 +2244,20 @@ class Conditional FINAL : public Expression {
: Expression(zone, position, id_gen),
condition_(condition),
then_expression_(then_expression),
- else_expression_(else_expression),
- then_id_(id_gen->GetNextId()),
- else_id_(id_gen->GetNextId()) {}
+ else_expression_(else_expression) {
+#ifdef DEBUG
+ int then_id =
+#endif
+ RESERVE_ID_RANGE();
+ DCHECK(then_id == ThenId().ToInt());
+ }
private:
Expression* condition_;
Expression* then_expression_;
Expression* else_expression_;
- const BailoutId then_id_;
- const BailoutId else_id_;
+
+ static const int kClassIdRange = 2; // Then and else ids
};
@@ -2171,7 +2277,7 @@ class Assignment FINAL : public Expression {
// This check relies on the definition order of token in token.h.
bool is_compound() const { return op() > Token::ASSIGN; }
- BailoutId AssignmentId() const { return assignment_id_; }
+ BailoutId AssignmentId() const { return BailoutId(NEXT_ID(Expression)); }
// Type feedback information.
TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); }
@@ -2209,12 +2315,13 @@ class Assignment FINAL : public Expression {
Expression* target_;
Expression* value_;
BinaryOperation* binary_operation_;
- const BailoutId assignment_id_;
bool is_uninitialized_ : 1;
KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed,
// must have extra bit.
SmallMapList receiver_types_;
+
+ static const int kClassIdRange = 1; // Assignment id
};
@@ -2545,6 +2652,10 @@ class SuperReference FINAL : public Expression {
#undef DECLARE_NODE_TYPE
+#undef RESERVE_ID_RANGE
+#undef NEXT_ID
+#undef NEXT_ID_FUNC
+#undef NEXT_ID_FUNC_BASE
// ----------------------------------------------------------------------------
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698