Push the general AST id field down from ASTNode to Expression.

Almost all uses were below Expression already, only a single use in IfStatement
had to be handled explicitly (probably an oversight from earlier changes?). This
is a small step towards a less ad-hoc handling of IDs in the front end.
Review URL: http://codereview.chromium.org/7054034

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8118 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a01b45df
......@@ -135,7 +135,7 @@ class AstNode: public ZoneObject {
static const int kNoNumber = -1;
static const int kFunctionEntryId = 2; // Using 0 could disguise errors.
AstNode() : id_(GetNextId()) {
AstNode() {
Isolate* isolate = Isolate::Current();
isolate->set_ast_node_count(isolate->ast_node_count() + 1);
}
......@@ -164,15 +164,9 @@ class AstNode: public ZoneObject {
static int Count() { return Isolate::Current()->ast_node_count(); }
static void ResetIds() { Isolate::Current()->set_ast_node_id(0); }
unsigned id() const { return id_; }
protected:
static unsigned GetNextId() {
Isolate* isolate = Isolate::Current();
unsigned tmp = isolate->ast_node_id();
isolate->set_ast_node_id(tmp + 1);
return tmp;
}
static unsigned GetNextId() { return ReserveIdRange(1); }
static unsigned ReserveIdRange(int n) {
Isolate* isolate = Isolate::Current();
unsigned tmp = isolate->ast_node_id();
......@@ -180,9 +174,6 @@ class AstNode: public ZoneObject {
return tmp;
}
private:
unsigned id_;
friend class CaseClause; // Generates AST IDs.
};
......@@ -220,7 +211,7 @@ class Expression: public AstNode {
kTest
};
Expression() {}
Expression() : id_(GetNextId()) {}
virtual int position() const {
UNREACHABLE();
......@@ -278,8 +269,11 @@ class Expression: public AstNode {
external_array_type_ = array_type;
}
unsigned id() const { return id_; }
private:
ExternalArrayType external_array_type_;
unsigned id_;
};
......@@ -715,6 +709,7 @@ class IfStatement: public Statement {
: condition_(condition),
then_statement_(then_statement),
else_statement_(else_statement),
if_id_(GetNextId()),
then_id_(GetNextId()),
else_id_(GetNextId()) {
}
......@@ -730,6 +725,7 @@ class IfStatement: public Statement {
Statement* then_statement() const { return then_statement_; }
Statement* else_statement() const { return else_statement_; }
int IfId() const { return if_id_; }
int ThenId() const { return then_id_; }
int ElseId() const { return else_id_; }
......@@ -737,6 +733,7 @@ class IfStatement: public Statement {
Expression* condition_;
Statement* then_statement_;
Statement* else_statement_;
int if_id_;
int then_id_;
int else_id_;
};
......
......@@ -348,7 +348,7 @@ void FullCodeGenerator::PopulateDeoptimizationData(Handle<Code> code) {
}
void FullCodeGenerator::PrepareForBailout(AstNode* node, State state) {
void FullCodeGenerator::PrepareForBailout(Expression* node, State state) {
PrepareForBailoutForId(node->id(), state);
}
......@@ -942,7 +942,7 @@ void FullCodeGenerator::VisitIfStatement(IfStatement* stmt) {
PrepareForBailoutForId(stmt->ElseId(), NO_REGISTERS);
}
__ bind(&done);
PrepareForBailoutForId(stmt->id(), NO_REGISTERS);
PrepareForBailoutForId(stmt->IfId(), NO_REGISTERS);
}
......
......@@ -369,7 +369,7 @@ class FullCodeGenerator: public AstVisitor {
Label* fall_through);
// Bailout support.
void PrepareForBailout(AstNode* node, State state);
void PrepareForBailout(Expression* node, State state);
void PrepareForBailoutForId(int id, State state);
// Record a call's return site offset, used to rebuild the frame if the
......
......@@ -2443,7 +2443,7 @@ void HGraphBuilder::VisitIfStatement(IfStatement* stmt) {
cond_false = NULL;
}
HBasicBlock* join = CreateJoin(cond_true, cond_false, stmt->id());
HBasicBlock* join = CreateJoin(cond_true, cond_false, stmt->IfId());
set_current_block(join);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment