Commit 77d06401 authored by marja@chromium.org's avatar marja@chromium.org

Take ast node id counting away from Isolate.

When we're going to parse multiple scripts in parallel, we cannot have the
Isolate count the ast node ids.

Now the counter is stored in CompilationInfo instead. This is because we need to
add ast nodes after parsing too.

R=rossberg@chromium.org
BUG=

Review URL: https://codereview.chromium.org/490173002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23301 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2229575b
...@@ -59,8 +59,9 @@ bool Expression::IsUndefinedLiteral(Isolate* isolate) const { ...@@ -59,8 +59,9 @@ bool Expression::IsUndefinedLiteral(Isolate* isolate) const {
} }
VariableProxy::VariableProxy(Zone* zone, Variable* var, int position) VariableProxy::VariableProxy(Zone* zone, Variable* var, int position,
: Expression(zone, position), IdGen* id_gen)
: Expression(zone, position, id_gen),
name_(var->raw_name()), name_(var->raw_name()),
var_(NULL), // Will be set by the call to BindTo. var_(NULL), // Will be set by the call to BindTo.
is_this_(var->is_this()), is_this_(var->is_this()),
...@@ -71,19 +72,15 @@ VariableProxy::VariableProxy(Zone* zone, Variable* var, int position) ...@@ -71,19 +72,15 @@ VariableProxy::VariableProxy(Zone* zone, Variable* var, int position)
} }
VariableProxy::VariableProxy(Zone* zone, VariableProxy::VariableProxy(Zone* zone, const AstRawString* name, bool is_this,
const AstRawString* name, Interface* interface, int position, IdGen* id_gen)
bool is_this, : Expression(zone, position, id_gen),
Interface* interface,
int position)
: Expression(zone, position),
name_(name), name_(name),
var_(NULL), var_(NULL),
is_this_(is_this), is_this_(is_this),
is_assigned_(false), is_assigned_(false),
interface_(interface), interface_(interface),
variable_feedback_slot_(kInvalidFeedbackSlot) { variable_feedback_slot_(kInvalidFeedbackSlot) {}
}
void VariableProxy::BindTo(Variable* var) { void VariableProxy::BindTo(Variable* var) {
...@@ -101,19 +98,16 @@ void VariableProxy::BindTo(Variable* var) { ...@@ -101,19 +98,16 @@ void VariableProxy::BindTo(Variable* var) {
} }
Assignment::Assignment(Zone* zone, Assignment::Assignment(Zone* zone, Token::Value op, Expression* target,
Token::Value op, Expression* value, int pos, IdGen* id_gen)
Expression* target, : Expression(zone, pos, id_gen),
Expression* value,
int pos)
: Expression(zone, pos),
op_(op), op_(op),
target_(target), target_(target),
value_(value), value_(value),
binary_operation_(NULL), binary_operation_(NULL),
assignment_id_(GetNextId(zone)), assignment_id_(id_gen->GetNextId()),
is_uninitialized_(false), is_uninitialized_(false),
store_mode_(STANDARD_STORE) { } store_mode_(STANDARD_STORE) {}
Token::Value Assignment::binary_op() const { Token::Value Assignment::binary_op() const {
...@@ -993,17 +987,14 @@ RegExpAlternative::RegExpAlternative(ZoneList<RegExpTree*>* nodes) ...@@ -993,17 +987,14 @@ RegExpAlternative::RegExpAlternative(ZoneList<RegExpTree*>* nodes)
} }
CaseClause::CaseClause(Zone* zone, CaseClause::CaseClause(Zone* zone, Expression* label,
Expression* label, ZoneList<Statement*>* statements, int pos, IdGen* id_gen)
ZoneList<Statement*>* statements, : Expression(zone, pos, id_gen),
int pos)
: Expression(zone, pos),
label_(label), label_(label),
statements_(statements), statements_(statements),
compare_type_(Type::None(zone)), compare_type_(Type::None(zone)),
compare_id_(AstNode::GetNextId(zone)), compare_id_(id_gen->GetNextId()),
entry_id_(AstNode::GetNextId(zone)) { entry_id_(id_gen->GetNextId()) {}
}
#define REGULAR_NODE(NodeType) \ #define REGULAR_NODE(NodeType) \
......
...@@ -181,6 +181,22 @@ AstProperties() : node_count_(0), feedback_slots_(0) {} ...@@ -181,6 +181,22 @@ AstProperties() : node_count_(0), feedback_slots_(0) {}
class AstNode: public ZoneObject { class AstNode: public ZoneObject {
public: public:
// For generating IDs for AstNodes.
class IdGen {
public:
explicit IdGen(int id = 0) : id_(id) {}
int GetNextId() { return ReserveIdRange(1); }
int ReserveIdRange(int n) {
int tmp = id_;
id_ += n;
return tmp;
}
private:
int id_;
};
#define DECLARE_TYPE_ENUM(type) k##type, #define DECLARE_TYPE_ENUM(type) k##type,
enum NodeType { enum NodeType {
AST_NODE_LIST(DECLARE_TYPE_ENUM) AST_NODE_LIST(DECLARE_TYPE_ENUM)
...@@ -217,16 +233,6 @@ class AstNode: public ZoneObject { ...@@ -217,16 +233,6 @@ class AstNode: public ZoneObject {
virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; }
protected: protected:
static int GetNextId(Zone* zone) {
return ReserveIdRange(zone, 1);
}
static int ReserveIdRange(Zone* zone, int n) {
int tmp = zone->isolate()->ast_node_id();
zone->isolate()->set_ast_node_id(tmp + n);
return tmp;
}
// Some nodes re-use bailout IDs for type feedback. // Some nodes re-use bailout IDs for type feedback.
static TypeFeedbackId reuse(BailoutId id) { static TypeFeedbackId reuse(BailoutId id) {
return TypeFeedbackId(id.ToInt()); return TypeFeedbackId(id.ToInt());
...@@ -372,17 +378,14 @@ class Expression : public AstNode { ...@@ -372,17 +378,14 @@ class Expression : public AstNode {
TypeFeedbackId test_id() const { return test_id_; } TypeFeedbackId test_id() const { return test_id_; }
protected: protected:
Expression(Zone* zone, int pos) Expression(Zone* zone, int pos, IdGen* id_gen)
: AstNode(pos), : AstNode(pos),
zone_(zone),
bounds_(Bounds::Unbounded(zone)), bounds_(Bounds::Unbounded(zone)),
parenthesization_level_(0), parenthesization_level_(0),
id_(GetNextId(zone)), id_(id_gen->GetNextId()),
test_id_(GetNextId(zone)) {} test_id_(id_gen->GetNextId()) {}
void set_to_boolean_types(byte types) { to_boolean_types_ = types; } void set_to_boolean_types(byte types) { to_boolean_types_ = types; }
Zone* zone_;
private: private:
Bounds bounds_; Bounds bounds_;
byte to_boolean_types_; byte to_boolean_types_;
...@@ -421,14 +424,13 @@ class BreakableStatement : public Statement { ...@@ -421,14 +424,13 @@ class BreakableStatement : public Statement {
BailoutId ExitId() const { return exit_id_; } BailoutId ExitId() const { return exit_id_; }
protected: protected:
BreakableStatement( BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels,
Zone* zone, ZoneList<const AstRawString*>* labels, BreakableType breakable_type, int position, IdGen* id_gen)
BreakableType breakable_type, int position)
: Statement(zone, position), : Statement(zone, position),
labels_(labels), labels_(labels),
breakable_type_(breakable_type), breakable_type_(breakable_type),
entry_id_(GetNextId(zone)), entry_id_(id_gen->GetNextId()),
exit_id_(GetNextId(zone)) { exit_id_(id_gen->GetNextId()) {
DCHECK(labels == NULL || labels->length() > 0); DCHECK(labels == NULL || labels->length() > 0);
} }
...@@ -464,17 +466,13 @@ class Block V8_FINAL : public BreakableStatement { ...@@ -464,17 +466,13 @@ class Block V8_FINAL : public BreakableStatement {
void set_scope(Scope* scope) { scope_ = scope; } void set_scope(Scope* scope) { scope_ = scope; }
protected: protected:
Block(Zone* zone, Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity,
ZoneList<const AstRawString*>* labels, bool is_initializer_block, int pos, IdGen* id_gen)
int capacity, : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos, id_gen),
bool is_initializer_block,
int pos)
: BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos),
statements_(capacity, zone), statements_(capacity, zone),
is_initializer_block_(is_initializer_block), is_initializer_block_(is_initializer_block),
decls_id_(GetNextId(zone)), decls_id_(id_gen->GetNextId()),
scope_(NULL) { scope_(NULL) {}
}
private: private:
ZoneList<Statement*> statements_; ZoneList<Statement*> statements_;
...@@ -739,11 +737,11 @@ class IterationStatement : public BreakableStatement { ...@@ -739,11 +737,11 @@ class IterationStatement : public BreakableStatement {
Label* continue_target() { return &continue_target_; } Label* continue_target() { return &continue_target_; }
protected: protected:
IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
: BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), IdGen* id_gen)
: BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, id_gen),
body_(NULL), body_(NULL),
osr_entry_id_(GetNextId(zone)) { osr_entry_id_(id_gen->GetNextId()) {}
}
void Initialize(Statement* body) { void Initialize(Statement* body) {
body_ = body; body_ = body;
...@@ -773,12 +771,12 @@ class DoWhileStatement V8_FINAL : public IterationStatement { ...@@ -773,12 +771,12 @@ class DoWhileStatement V8_FINAL : public IterationStatement {
BailoutId BackEdgeId() const { return back_edge_id_; } BailoutId BackEdgeId() const { return back_edge_id_; }
protected: protected:
DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
: IterationStatement(zone, labels, pos), IdGen* id_gen)
: IterationStatement(zone, labels, pos, id_gen),
cond_(NULL), cond_(NULL),
continue_id_(GetNextId(zone)), continue_id_(id_gen->GetNextId()),
back_edge_id_(GetNextId(zone)) { back_edge_id_(id_gen->GetNextId()) {}
}
private: private:
Expression* cond_; Expression* cond_;
...@@ -810,12 +808,12 @@ class WhileStatement V8_FINAL : public IterationStatement { ...@@ -810,12 +808,12 @@ class WhileStatement V8_FINAL : public IterationStatement {
BailoutId BodyId() const { return body_id_; } BailoutId BodyId() const { return body_id_; }
protected: protected:
WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
: IterationStatement(zone, labels, pos), IdGen* id_gen)
: IterationStatement(zone, labels, pos, id_gen),
cond_(NULL), cond_(NULL),
may_have_function_literal_(true), may_have_function_literal_(true),
body_id_(GetNextId(zone)) { body_id_(id_gen->GetNextId()) {}
}
private: private:
Expression* cond_; Expression* cond_;
...@@ -861,16 +859,16 @@ class ForStatement V8_FINAL : public IterationStatement { ...@@ -861,16 +859,16 @@ class ForStatement V8_FINAL : public IterationStatement {
void set_loop_variable(Variable* var) { loop_variable_ = var; } void set_loop_variable(Variable* var) { loop_variable_ = var; }
protected: protected:
ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
: IterationStatement(zone, labels, pos), IdGen* id_gen)
: IterationStatement(zone, labels, pos, id_gen),
init_(NULL), init_(NULL),
cond_(NULL), cond_(NULL),
next_(NULL), next_(NULL),
may_have_function_literal_(true), may_have_function_literal_(true),
loop_variable_(NULL), loop_variable_(NULL),
continue_id_(GetNextId(zone)), continue_id_(id_gen->GetNextId()),
body_id_(GetNextId(zone)) { body_id_(id_gen->GetNextId()) {}
}
private: private:
Statement* init_; Statement* init_;
...@@ -903,8 +901,11 @@ class ForEachStatement : public IterationStatement { ...@@ -903,8 +901,11 @@ class ForEachStatement : public IterationStatement {
Expression* subject() const { return subject_; } Expression* subject() const { return subject_; }
protected: protected:
ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
: IterationStatement(zone, labels, pos), each_(NULL), subject_(NULL) {} IdGen* id_gen)
: IterationStatement(zone, labels, pos, id_gen),
each_(NULL),
subject_(NULL) {}
private: private:
Expression* each_; Expression* each_;
...@@ -940,13 +941,13 @@ class ForInStatement V8_FINAL : public ForEachStatement, ...@@ -940,13 +941,13 @@ class ForInStatement V8_FINAL : public ForEachStatement,
virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; }
protected: protected:
ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
: ForEachStatement(zone, labels, pos), IdGen* id_gen)
: ForEachStatement(zone, labels, pos, id_gen),
for_in_type_(SLOW_FOR_IN), for_in_type_(SLOW_FOR_IN),
for_in_feedback_slot_(kInvalidFeedbackSlot), for_in_feedback_slot_(kInvalidFeedbackSlot),
body_id_(GetNextId(zone)), body_id_(id_gen->GetNextId()),
prepare_id_(GetNextId(zone)) { prepare_id_(id_gen->GetNextId()) {}
}
ForInType for_in_type_; ForInType for_in_type_;
int for_in_feedback_slot_; int for_in_feedback_slot_;
...@@ -1003,14 +1004,14 @@ class ForOfStatement V8_FINAL : public ForEachStatement { ...@@ -1003,14 +1004,14 @@ class ForOfStatement V8_FINAL : public ForEachStatement {
BailoutId BackEdgeId() const { return back_edge_id_; } BailoutId BackEdgeId() const { return back_edge_id_; }
protected: protected:
ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
: ForEachStatement(zone, labels, pos), IdGen* id_gen)
: ForEachStatement(zone, labels, pos, id_gen),
assign_iterator_(NULL), assign_iterator_(NULL),
next_result_(NULL), next_result_(NULL),
result_done_(NULL), result_done_(NULL),
assign_each_(NULL), assign_each_(NULL),
back_edge_id_(GetNextId(zone)) { back_edge_id_(id_gen->GetNextId()) {}
}
Expression* assign_iterator_; Expression* assign_iterator_;
Expression* next_result_; Expression* next_result_;
...@@ -1135,10 +1136,8 @@ class CaseClause V8_FINAL : public Expression { ...@@ -1135,10 +1136,8 @@ class CaseClause V8_FINAL : public Expression {
void set_compare_type(Type* type) { compare_type_ = type; } void set_compare_type(Type* type) { compare_type_ = type; }
private: private:
CaseClause(Zone* zone, CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements,
Expression* label, int pos, IdGen* id_gen);
ZoneList<Statement*>* statements,
int pos);
Expression* label_; Expression* label_;
Label body_target_; Label body_target_;
...@@ -1163,10 +1162,11 @@ class SwitchStatement V8_FINAL : public BreakableStatement { ...@@ -1163,10 +1162,11 @@ class SwitchStatement V8_FINAL : public BreakableStatement {
ZoneList<CaseClause*>* cases() const { return cases_; } ZoneList<CaseClause*>* cases() const { return cases_; }
protected: protected:
SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
: BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), IdGen* id_gen)
: BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, id_gen),
tag_(NULL), tag_(NULL),
cases_(NULL) { } cases_(NULL) {}
private: private:
Expression* tag_; Expression* tag_;
...@@ -1200,19 +1200,15 @@ class IfStatement V8_FINAL : public Statement { ...@@ -1200,19 +1200,15 @@ class IfStatement V8_FINAL : public Statement {
BailoutId ElseId() const { return else_id_; } BailoutId ElseId() const { return else_id_; }
protected: protected:
IfStatement(Zone* zone, IfStatement(Zone* zone, Expression* condition, Statement* then_statement,
Expression* condition, Statement* else_statement, int pos, IdGen* id_gen)
Statement* then_statement,
Statement* else_statement,
int pos)
: Statement(zone, pos), : Statement(zone, pos),
condition_(condition), condition_(condition),
then_statement_(then_statement), then_statement_(then_statement),
else_statement_(else_statement), else_statement_(else_statement),
if_id_(GetNextId(zone)), if_id_(id_gen->GetNextId()),
then_id_(GetNextId(zone)), then_id_(id_gen->GetNextId()),
else_id_(GetNextId(zone)) { else_id_(id_gen->GetNextId()) {}
}
private: private:
Expression* condition_; Expression* condition_;
...@@ -1327,8 +1323,8 @@ class DebuggerStatement V8_FINAL : public Statement { ...@@ -1327,8 +1323,8 @@ class DebuggerStatement V8_FINAL : public Statement {
BailoutId DebugBreakId() const { return debugger_id_; } BailoutId DebugBreakId() const { return debugger_id_; }
protected: protected:
explicit DebuggerStatement(Zone* zone, int pos) explicit DebuggerStatement(Zone* zone, int pos, IdGen* id_gen)
: Statement(zone, pos), debugger_id_(GetNextId(zone)) {} : Statement(zone, pos), debugger_id_(id_gen->GetNextId()) {}
private: private:
const BailoutId debugger_id_; const BailoutId debugger_id_;
...@@ -1385,10 +1381,10 @@ class Literal V8_FINAL : public Expression { ...@@ -1385,10 +1381,10 @@ class Literal V8_FINAL : public Expression {
TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); } TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); }
protected: protected:
Literal(Zone* zone, const AstValue* value, int position) Literal(Zone* zone, const AstValue* value, int position, IdGen* id_gen)
: Expression(zone, position), : Expression(zone, position, id_gen),
value_(value), value_(value),
isolate_(zone->isolate()) { } isolate_(zone->isolate()) {}
private: private:
Handle<String> ToString(); Handle<String> ToString();
...@@ -1413,10 +1409,8 @@ class MaterializedLiteral : public Expression { ...@@ -1413,10 +1409,8 @@ class MaterializedLiteral : public Expression {
} }
protected: protected:
MaterializedLiteral(Zone* zone, MaterializedLiteral(Zone* zone, int literal_index, int pos, IdGen* id_gen)
int literal_index, : Expression(zone, pos, id_gen),
int pos)
: Expression(zone, pos),
literal_index_(literal_index), literal_index_(literal_index),
is_simple_(false), is_simple_(false),
depth_(0) {} depth_(0) {}
...@@ -1543,13 +1537,10 @@ class ObjectLiteral V8_FINAL : public MaterializedLiteral { ...@@ -1543,13 +1537,10 @@ class ObjectLiteral V8_FINAL : public MaterializedLiteral {
}; };
protected: protected:
ObjectLiteral(Zone* zone, ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index,
ZoneList<Property*>* properties, int boilerplate_properties, bool has_function, int pos,
int literal_index, IdGen* id_gen)
int boilerplate_properties, : MaterializedLiteral(zone, literal_index, pos, id_gen),
bool has_function,
int pos)
: MaterializedLiteral(zone, literal_index, pos),
properties_(properties), properties_(properties),
boilerplate_properties_(boilerplate_properties), boilerplate_properties_(boilerplate_properties),
fast_elements_(false), fast_elements_(false),
...@@ -1575,12 +1566,10 @@ class RegExpLiteral V8_FINAL : public MaterializedLiteral { ...@@ -1575,12 +1566,10 @@ class RegExpLiteral V8_FINAL : public MaterializedLiteral {
Handle<String> flags() const { return flags_->string(); } Handle<String> flags() const { return flags_->string(); }
protected: protected:
RegExpLiteral(Zone* zone, RegExpLiteral(Zone* zone, const AstRawString* pattern,
const AstRawString* pattern, const AstRawString* flags, int literal_index, int pos,
const AstRawString* flags, IdGen* id_gen)
int literal_index, : MaterializedLiteral(zone, literal_index, pos, id_gen),
int pos)
: MaterializedLiteral(zone, literal_index, pos),
pattern_(pattern), pattern_(pattern),
flags_(flags) { flags_(flags) {
set_depth(1); set_depth(1);
...@@ -1623,13 +1612,11 @@ class ArrayLiteral V8_FINAL : public MaterializedLiteral { ...@@ -1623,13 +1612,11 @@ class ArrayLiteral V8_FINAL : public MaterializedLiteral {
}; };
protected: protected:
ArrayLiteral(Zone* zone, ArrayLiteral(Zone* zone, ZoneList<Expression*>* values, int literal_index,
ZoneList<Expression*>* values, int pos, IdGen* id_gen)
int literal_index, : MaterializedLiteral(zone, literal_index, pos, id_gen),
int pos)
: MaterializedLiteral(zone, literal_index, pos),
values_(values), values_(values),
first_element_id_(ReserveIdRange(zone, values->length())) {} first_element_id_(id_gen->ReserveIdRange(values->length())) {}
private: private:
Handle<FixedArray> constant_elements_; Handle<FixedArray> constant_elements_;
...@@ -1668,13 +1655,10 @@ class VariableProxy V8_FINAL : public Expression, public FeedbackSlotInterface { ...@@ -1668,13 +1655,10 @@ class VariableProxy V8_FINAL : public Expression, public FeedbackSlotInterface {
int VariableFeedbackSlot() { return variable_feedback_slot_; } int VariableFeedbackSlot() { return variable_feedback_slot_; }
protected: protected:
VariableProxy(Zone* zone, Variable* var, int position); VariableProxy(Zone* zone, Variable* var, int position, IdGen* id_gen);
VariableProxy(Zone* zone, VariableProxy(Zone* zone, const AstRawString* name, bool is_this,
const AstRawString* name, Interface* interface, int position, IdGen* id_gen);
bool is_this,
Interface* interface,
int position);
const AstRawString* name_; const AstRawString* name_;
Variable* var_; // resolved variable, or NULL Variable* var_; // resolved variable, or NULL
...@@ -1731,11 +1715,11 @@ class Property V8_FINAL : public Expression, public FeedbackSlotInterface { ...@@ -1731,11 +1715,11 @@ class Property V8_FINAL : public Expression, public FeedbackSlotInterface {
int PropertyFeedbackSlot() const { return property_feedback_slot_; } int PropertyFeedbackSlot() const { return property_feedback_slot_; }
protected: protected:
Property(Zone* zone, Expression* obj, Expression* key, int pos) Property(Zone* zone, Expression* obj, Expression* key, int pos, IdGen* id_gen)
: Expression(zone, pos), : Expression(zone, pos, id_gen),
obj_(obj), obj_(obj),
key_(key), key_(key),
load_id_(GetNextId(zone)), load_id_(id_gen->GetNextId()),
property_feedback_slot_(kInvalidFeedbackSlot), property_feedback_slot_(kInvalidFeedbackSlot),
is_for_call_(false), is_for_call_(false),
is_uninitialized_(false), is_uninitialized_(false),
...@@ -1827,15 +1811,13 @@ class Call V8_FINAL : public Expression, public FeedbackSlotInterface { ...@@ -1827,15 +1811,13 @@ class Call V8_FINAL : public Expression, public FeedbackSlotInterface {
#endif #endif
protected: protected:
Call(Zone* zone, Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments,
Expression* expression, int pos, IdGen* id_gen)
ZoneList<Expression*>* arguments, : Expression(zone, pos, id_gen),
int pos)
: Expression(zone, pos),
expression_(expression), expression_(expression),
arguments_(arguments), arguments_(arguments),
call_feedback_slot_(kInvalidFeedbackSlot), call_feedback_slot_(kInvalidFeedbackSlot),
return_id_(GetNextId(zone)) { return_id_(id_gen->GetNextId()) {
if (expression->IsProperty()) { if (expression->IsProperty()) {
expression->AsProperty()->mark_for_call(); expression->AsProperty()->mark_for_call();
} }
...@@ -1892,17 +1874,15 @@ class CallNew V8_FINAL : public Expression, public FeedbackSlotInterface { ...@@ -1892,17 +1874,15 @@ class CallNew V8_FINAL : public Expression, public FeedbackSlotInterface {
BailoutId ReturnId() const { return return_id_; } BailoutId ReturnId() const { return return_id_; }
protected: protected:
CallNew(Zone* zone, CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments,
Expression* expression, int pos, IdGen* id_gen)
ZoneList<Expression*>* arguments, : Expression(zone, pos, id_gen),
int pos)
: Expression(zone, pos),
expression_(expression), expression_(expression),
arguments_(arguments), arguments_(arguments),
is_monomorphic_(false), is_monomorphic_(false),
elements_kind_(GetInitialFastElementsKind()), elements_kind_(GetInitialFastElementsKind()),
callnew_feedback_slot_(kInvalidFeedbackSlot), callnew_feedback_slot_(kInvalidFeedbackSlot),
return_id_(GetNextId(zone)) { } return_id_(id_gen->GetNextId()) {}
private: private:
Expression* expression_; Expression* expression_;
...@@ -1949,15 +1929,13 @@ class CallRuntime V8_FINAL : public Expression, public FeedbackSlotInterface { ...@@ -1949,15 +1929,13 @@ class CallRuntime V8_FINAL : public Expression, public FeedbackSlotInterface {
TypeFeedbackId CallRuntimeFeedbackId() const { return reuse(id()); } TypeFeedbackId CallRuntimeFeedbackId() const { return reuse(id()); }
protected: protected:
CallRuntime(Zone* zone, CallRuntime(Zone* zone, const AstRawString* name,
const AstRawString* name,
const Runtime::Function* function, const Runtime::Function* function,
ZoneList<Expression*>* arguments, ZoneList<Expression*>* arguments, int pos, IdGen* id_gen)
int pos) : Expression(zone, pos, id_gen),
: Expression(zone, pos),
raw_name_(name), raw_name_(name),
function_(function), function_(function),
arguments_(arguments) { } arguments_(arguments) {}
private: private:
const AstRawString* raw_name_; const AstRawString* raw_name_;
...@@ -1981,15 +1959,13 @@ class UnaryOperation V8_FINAL : public Expression { ...@@ -1981,15 +1959,13 @@ class UnaryOperation V8_FINAL : public Expression {
TypeFeedbackOracle* oracle) V8_OVERRIDE; TypeFeedbackOracle* oracle) V8_OVERRIDE;
protected: protected:
UnaryOperation(Zone* zone, UnaryOperation(Zone* zone, Token::Value op, Expression* expression, int pos,
Token::Value op, IdGen* id_gen)
Expression* expression, : Expression(zone, pos, id_gen),
int pos)
: Expression(zone, pos),
op_(op), op_(op),
expression_(expression), expression_(expression),
materialize_true_id_(GetNextId(zone)), materialize_true_id_(id_gen->GetNextId()),
materialize_false_id_(GetNextId(zone)) { materialize_false_id_(id_gen->GetNextId()) {
DCHECK(Token::IsUnaryOp(op)); DCHECK(Token::IsUnaryOp(op));
} }
...@@ -2028,16 +2004,13 @@ class BinaryOperation V8_FINAL : public Expression { ...@@ -2028,16 +2004,13 @@ class BinaryOperation V8_FINAL : public Expression {
TypeFeedbackOracle* oracle) V8_OVERRIDE; TypeFeedbackOracle* oracle) V8_OVERRIDE;
protected: protected:
BinaryOperation(Zone* zone, BinaryOperation(Zone* zone, Token::Value op, Expression* left,
Token::Value op, Expression* right, int pos, IdGen* id_gen)
Expression* left, : Expression(zone, pos, id_gen),
Expression* right,
int pos)
: Expression(zone, pos),
op_(op), op_(op),
left_(left), left_(left),
right_(right), right_(right),
right_id_(GetNextId(zone)) { right_id_(id_gen->GetNextId()) {
DCHECK(Token::IsBinaryOp(op)); DCHECK(Token::IsBinaryOp(op));
} }
...@@ -2090,18 +2063,15 @@ class CountOperation V8_FINAL : public Expression { ...@@ -2090,18 +2063,15 @@ class CountOperation V8_FINAL : public Expression {
TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); } TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); }
protected: protected:
CountOperation(Zone* zone, CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr,
Token::Value op, int pos, IdGen* id_gen)
bool is_prefix, : Expression(zone, pos, id_gen),
Expression* expr,
int pos)
: Expression(zone, pos),
op_(op), op_(op),
is_prefix_(is_prefix), is_prefix_(is_prefix),
store_mode_(STANDARD_STORE), store_mode_(STANDARD_STORE),
expression_(expr), expression_(expr),
assignment_id_(GetNextId(zone)), assignment_id_(id_gen->GetNextId()),
count_id_(GetNextId(zone)) {} count_id_(id_gen->GetNextId()) {}
private: private:
Token::Value op_; Token::Value op_;
...@@ -2136,12 +2106,9 @@ class CompareOperation V8_FINAL : public Expression { ...@@ -2136,12 +2106,9 @@ class CompareOperation V8_FINAL : public Expression {
bool IsLiteralCompareNull(Expression** expr); bool IsLiteralCompareNull(Expression** expr);
protected: protected:
CompareOperation(Zone* zone, CompareOperation(Zone* zone, Token::Value op, Expression* left,
Token::Value op, Expression* right, int pos, IdGen* id_gen)
Expression* left, : Expression(zone, pos, id_gen),
Expression* right,
int pos)
: Expression(zone, pos),
op_(op), op_(op),
left_(left), left_(left),
right_(right), right_(right),
...@@ -2170,17 +2137,14 @@ class Conditional V8_FINAL : public Expression { ...@@ -2170,17 +2137,14 @@ class Conditional V8_FINAL : public Expression {
BailoutId ElseId() const { return else_id_; } BailoutId ElseId() const { return else_id_; }
protected: protected:
Conditional(Zone* zone, Conditional(Zone* zone, Expression* condition, Expression* then_expression,
Expression* condition, Expression* else_expression, int position, IdGen* id_gen)
Expression* then_expression, : Expression(zone, position, id_gen),
Expression* else_expression,
int position)
: Expression(zone, position),
condition_(condition), condition_(condition),
then_expression_(then_expression), then_expression_(then_expression),
else_expression_(else_expression), else_expression_(else_expression),
then_id_(GetNextId(zone)), then_id_(id_gen->GetNextId()),
else_id_(GetNextId(zone)) { } else_id_(id_gen->GetNextId()) {}
private: private:
Expression* condition_; Expression* condition_;
...@@ -2228,11 +2192,8 @@ class Assignment V8_FINAL : public Expression { ...@@ -2228,11 +2192,8 @@ class Assignment V8_FINAL : public Expression {
void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; }
protected: protected:
Assignment(Zone* zone, Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value,
Token::Value op, int pos, IdGen* id_gen);
Expression* target,
Expression* value,
int pos);
template<class Visitor> template<class Visitor>
void Init(Zone* zone, AstNodeFactory<Visitor>* factory) { void Init(Zone* zone, AstNodeFactory<Visitor>* factory) {
...@@ -2308,17 +2269,14 @@ class Yield V8_FINAL : public Expression, public FeedbackSlotInterface { ...@@ -2308,17 +2269,14 @@ class Yield V8_FINAL : public Expression, public FeedbackSlotInterface {
} }
protected: protected:
Yield(Zone* zone, Yield(Zone* zone, Expression* generator_object, Expression* expression,
Expression* generator_object, Kind yield_kind, int pos, IdGen* id_gen)
Expression* expression, : Expression(zone, pos, id_gen),
Kind yield_kind,
int pos)
: Expression(zone, pos),
generator_object_(generator_object), generator_object_(generator_object),
expression_(expression), expression_(expression),
yield_kind_(yield_kind), yield_kind_(yield_kind),
index_(-1), index_(-1),
yield_first_feedback_slot_(kInvalidFeedbackSlot) { } yield_first_feedback_slot_(kInvalidFeedbackSlot) {}
private: private:
Expression* generator_object_; Expression* generator_object_;
...@@ -2336,8 +2294,8 @@ class Throw V8_FINAL : public Expression { ...@@ -2336,8 +2294,8 @@ class Throw V8_FINAL : public Expression {
Expression* exception() const { return exception_; } Expression* exception() const { return exception_; }
protected: protected:
Throw(Zone* zone, Expression* exception, int pos) Throw(Zone* zone, Expression* exception, int pos, IdGen* id_gen)
: Expression(zone, pos), exception_(exception) {} : Expression(zone, pos, id_gen), exception_(exception) {}
private: private:
Expression* exception_; Expression* exception_;
...@@ -2488,8 +2446,8 @@ class FunctionLiteral V8_FINAL : public Expression { ...@@ -2488,8 +2446,8 @@ class FunctionLiteral V8_FINAL : public Expression {
ParameterFlag has_duplicate_parameters, ParameterFlag has_duplicate_parameters,
IsFunctionFlag is_function, IsFunctionFlag is_function,
IsParenthesizedFlag is_parenthesized, KindFlag kind, IsParenthesizedFlag is_parenthesized, KindFlag kind,
int position) int position, IdGen* id_gen)
: Expression(zone, position), : Expression(zone, position, id_gen),
raw_name_(name), raw_name_(name),
scope_(scope), scope_(scope),
body_(body), body_(body),
...@@ -2548,8 +2506,8 @@ class NativeFunctionLiteral V8_FINAL : public Expression { ...@@ -2548,8 +2506,8 @@ class NativeFunctionLiteral V8_FINAL : public Expression {
protected: protected:
NativeFunctionLiteral(Zone* zone, const AstRawString* name, NativeFunctionLiteral(Zone* zone, const AstRawString* name,
v8::Extension* extension, int pos) v8::Extension* extension, int pos, IdGen* id_gen)
: Expression(zone, pos), name_(name), extension_(extension) {} : Expression(zone, pos, id_gen), name_(name), extension_(extension) {}
private: private:
const AstRawString* name_; const AstRawString* name_;
...@@ -2562,7 +2520,8 @@ class ThisFunction V8_FINAL : public Expression { ...@@ -2562,7 +2520,8 @@ class ThisFunction V8_FINAL : public Expression {
DECLARE_NODE_TYPE(ThisFunction) DECLARE_NODE_TYPE(ThisFunction)
protected: protected:
explicit ThisFunction(Zone* zone, int pos): Expression(zone, pos) {} ThisFunction(Zone* zone, int pos, IdGen* id_gen)
: Expression(zone, pos, id_gen) {}
}; };
...@@ -2575,8 +2534,8 @@ class SuperReference V8_FINAL : public Expression { ...@@ -2575,8 +2534,8 @@ class SuperReference V8_FINAL : public Expression {
TypeFeedbackId HomeObjectFeedbackId() { return reuse(id()); } TypeFeedbackId HomeObjectFeedbackId() { return reuse(id()); }
protected: protected:
explicit SuperReference(Zone* zone, VariableProxy* this_var, int pos) SuperReference(Zone* zone, VariableProxy* this_var, int pos, IdGen* id_gen)
: Expression(zone, pos), this_var_(this_var) { : Expression(zone, pos, id_gen), this_var_(this_var) {
DCHECK(this_var->is_this()); DCHECK(this_var->is_this());
} }
...@@ -3063,8 +3022,9 @@ class AstNullVisitor BASE_EMBEDDED { ...@@ -3063,8 +3022,9 @@ class AstNullVisitor BASE_EMBEDDED {
template<class Visitor> template<class Visitor>
class AstNodeFactory V8_FINAL BASE_EMBEDDED { class AstNodeFactory V8_FINAL BASE_EMBEDDED {
public: public:
explicit AstNodeFactory(Zone* zone, AstValueFactory* ast_value_factory) AstNodeFactory(Zone* zone, AstValueFactory* ast_value_factory,
: zone_(zone), ast_value_factory_(ast_value_factory) {} AstNode::IdGen* id_gen)
: zone_(zone), ast_value_factory_(ast_value_factory), id_gen_(id_gen) {}
Visitor* visitor() { return &visitor_; } Visitor* visitor() { return &visitor_; }
...@@ -3142,14 +3102,14 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3142,14 +3102,14 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
int capacity, int capacity,
bool is_initializer_block, bool is_initializer_block,
int pos) { int pos) {
Block* block = new(zone_) Block( Block* block = new (zone_)
zone_, labels, capacity, is_initializer_block, pos); Block(zone_, labels, capacity, is_initializer_block, pos, id_gen_);
VISIT_AND_RETURN(Block, block) VISIT_AND_RETURN(Block, block)
} }
#define STATEMENT_WITH_LABELS(NodeType) \ #define STATEMENT_WITH_LABELS(NodeType) \
NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \ NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \
NodeType* stmt = new(zone_) NodeType(zone_, labels, pos); \ NodeType* stmt = new (zone_) NodeType(zone_, labels, pos, id_gen_); \
VISIT_AND_RETURN(NodeType, stmt); \ VISIT_AND_RETURN(NodeType, stmt); \
} }
STATEMENT_WITH_LABELS(DoWhileStatement) STATEMENT_WITH_LABELS(DoWhileStatement)
...@@ -3163,11 +3123,13 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3163,11 +3123,13 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
int pos) { int pos) {
switch (visit_mode) { switch (visit_mode) {
case ForEachStatement::ENUMERATE: { case ForEachStatement::ENUMERATE: {
ForInStatement* stmt = new(zone_) ForInStatement(zone_, labels, pos); ForInStatement* stmt =
new (zone_) ForInStatement(zone_, labels, pos, id_gen_);
VISIT_AND_RETURN(ForInStatement, stmt); VISIT_AND_RETURN(ForInStatement, stmt);
} }
case ForEachStatement::ITERATE: { case ForEachStatement::ITERATE: {
ForOfStatement* stmt = new(zone_) ForOfStatement(zone_, labels, pos); ForOfStatement* stmt =
new (zone_) ForOfStatement(zone_, labels, pos, id_gen_);
VISIT_AND_RETURN(ForOfStatement, stmt); VISIT_AND_RETURN(ForOfStatement, stmt);
} }
} }
...@@ -3215,8 +3177,8 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3215,8 +3177,8 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
Statement* then_statement, Statement* then_statement,
Statement* else_statement, Statement* else_statement,
int pos) { int pos) {
IfStatement* stmt = new(zone_) IfStatement( IfStatement* stmt = new (zone_) IfStatement(
zone_, condition, then_statement, else_statement, pos); zone_, condition, then_statement, else_statement, pos, id_gen_);
VISIT_AND_RETURN(IfStatement, stmt) VISIT_AND_RETURN(IfStatement, stmt)
} }
...@@ -3241,7 +3203,8 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3241,7 +3203,8 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
} }
DebuggerStatement* NewDebuggerStatement(int pos) { DebuggerStatement* NewDebuggerStatement(int pos) {
DebuggerStatement* stmt = new(zone_) DebuggerStatement(zone_, pos); DebuggerStatement* stmt =
new (zone_) DebuggerStatement(zone_, pos, id_gen_);
VISIT_AND_RETURN(DebuggerStatement, stmt) VISIT_AND_RETURN(DebuggerStatement, stmt)
} }
...@@ -3252,63 +3215,63 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3252,63 +3215,63 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
CaseClause* NewCaseClause( CaseClause* NewCaseClause(
Expression* label, ZoneList<Statement*>* statements, int pos) { Expression* label, ZoneList<Statement*>* statements, int pos) {
CaseClause* clause = CaseClause* clause =
new(zone_) CaseClause(zone_, label, statements, pos); new (zone_) CaseClause(zone_, label, statements, pos, id_gen_);
VISIT_AND_RETURN(CaseClause, clause) VISIT_AND_RETURN(CaseClause, clause)
} }
Literal* NewStringLiteral(const AstRawString* string, int pos) { Literal* NewStringLiteral(const AstRawString* string, int pos) {
Literal* lit = Literal* lit = new (zone_)
new (zone_) Literal(zone_, ast_value_factory_->NewString(string), pos); Literal(zone_, ast_value_factory_->NewString(string), pos, id_gen_);
VISIT_AND_RETURN(Literal, lit) VISIT_AND_RETURN(Literal, lit)
} }
// A JavaScript symbol (ECMA-262 edition 6). // A JavaScript symbol (ECMA-262 edition 6).
Literal* NewSymbolLiteral(const char* name, int pos) { Literal* NewSymbolLiteral(const char* name, int pos) {
Literal* lit = Literal* lit = new (zone_)
new (zone_) Literal(zone_, ast_value_factory_->NewSymbol(name), pos); Literal(zone_, ast_value_factory_->NewSymbol(name), pos, id_gen_);
VISIT_AND_RETURN(Literal, lit) VISIT_AND_RETURN(Literal, lit)
} }
Literal* NewNumberLiteral(double number, int pos) { Literal* NewNumberLiteral(double number, int pos) {
Literal* lit = new (zone_) Literal* lit = new (zone_)
Literal(zone_, ast_value_factory_->NewNumber(number), pos); Literal(zone_, ast_value_factory_->NewNumber(number), pos, id_gen_);
VISIT_AND_RETURN(Literal, lit) VISIT_AND_RETURN(Literal, lit)
} }
Literal* NewSmiLiteral(int number, int pos) { Literal* NewSmiLiteral(int number, int pos) {
Literal* lit = Literal* lit = new (zone_)
new (zone_) Literal(zone_, ast_value_factory_->NewSmi(number), pos); Literal(zone_, ast_value_factory_->NewSmi(number), pos, id_gen_);
VISIT_AND_RETURN(Literal, lit) VISIT_AND_RETURN(Literal, lit)
} }
Literal* NewBooleanLiteral(bool b, int pos) { Literal* NewBooleanLiteral(bool b, int pos) {
Literal* lit = Literal* lit = new (zone_)
new (zone_) Literal(zone_, ast_value_factory_->NewBoolean(b), pos); Literal(zone_, ast_value_factory_->NewBoolean(b), pos, id_gen_);
VISIT_AND_RETURN(Literal, lit) VISIT_AND_RETURN(Literal, lit)
} }
Literal* NewStringListLiteral(ZoneList<const AstRawString*>* strings, Literal* NewStringListLiteral(ZoneList<const AstRawString*>* strings,
int pos) { int pos) {
Literal* lit = new (zone_) Literal* lit = new (zone_) Literal(
Literal(zone_, ast_value_factory_->NewStringList(strings), pos); zone_, ast_value_factory_->NewStringList(strings), pos, id_gen_);
VISIT_AND_RETURN(Literal, lit) VISIT_AND_RETURN(Literal, lit)
} }
Literal* NewNullLiteral(int pos) { Literal* NewNullLiteral(int pos) {
Literal* lit = Literal* lit =
new (zone_) Literal(zone_, ast_value_factory_->NewNull(), pos); new (zone_) Literal(zone_, ast_value_factory_->NewNull(), pos, id_gen_);
VISIT_AND_RETURN(Literal, lit) VISIT_AND_RETURN(Literal, lit)
} }
Literal* NewUndefinedLiteral(int pos) { Literal* NewUndefinedLiteral(int pos) {
Literal* lit = Literal* lit = new (zone_)
new (zone_) Literal(zone_, ast_value_factory_->NewUndefined(), pos); Literal(zone_, ast_value_factory_->NewUndefined(), pos, id_gen_);
VISIT_AND_RETURN(Literal, lit) VISIT_AND_RETURN(Literal, lit)
} }
Literal* NewTheHoleLiteral(int pos) { Literal* NewTheHoleLiteral(int pos) {
Literal* lit = Literal* lit = new (zone_)
new (zone_) Literal(zone_, ast_value_factory_->NewTheHole(), pos); Literal(zone_, ast_value_factory_->NewTheHole(), pos, id_gen_);
VISIT_AND_RETURN(Literal, lit) VISIT_AND_RETURN(Literal, lit)
} }
...@@ -3318,9 +3281,9 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3318,9 +3281,9 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
int boilerplate_properties, int boilerplate_properties,
bool has_function, bool has_function,
int pos) { int pos) {
ObjectLiteral* lit = new(zone_) ObjectLiteral( ObjectLiteral* lit = new (zone_)
zone_, properties, literal_index, boilerplate_properties, ObjectLiteral(zone_, properties, literal_index, boilerplate_properties,
has_function, pos); has_function, pos, id_gen_);
VISIT_AND_RETURN(ObjectLiteral, lit) VISIT_AND_RETURN(ObjectLiteral, lit)
} }
...@@ -3343,22 +3306,22 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3343,22 +3306,22 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
const AstRawString* flags, const AstRawString* flags,
int literal_index, int literal_index,
int pos) { int pos) {
RegExpLiteral* lit = RegExpLiteral* lit = new (zone_)
new(zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos); RegExpLiteral(zone_, pattern, flags, literal_index, pos, id_gen_);
VISIT_AND_RETURN(RegExpLiteral, lit); VISIT_AND_RETURN(RegExpLiteral, lit);
} }
ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values,
int literal_index, int literal_index,
int pos) { int pos) {
ArrayLiteral* lit = new(zone_) ArrayLiteral( ArrayLiteral* lit =
zone_, values, literal_index, pos); new (zone_) ArrayLiteral(zone_, values, literal_index, pos, id_gen_);
VISIT_AND_RETURN(ArrayLiteral, lit) VISIT_AND_RETURN(ArrayLiteral, lit)
} }
VariableProxy* NewVariableProxy(Variable* var, VariableProxy* NewVariableProxy(Variable* var,
int pos = RelocInfo::kNoPosition) { int pos = RelocInfo::kNoPosition) {
VariableProxy* proxy = new(zone_) VariableProxy(zone_, var, pos); VariableProxy* proxy = new (zone_) VariableProxy(zone_, var, pos, id_gen_);
VISIT_AND_RETURN(VariableProxy, proxy) VISIT_AND_RETURN(VariableProxy, proxy)
} }
...@@ -3366,27 +3329,28 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3366,27 +3329,28 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
bool is_this, bool is_this,
Interface* interface = Interface::NewValue(), Interface* interface = Interface::NewValue(),
int position = RelocInfo::kNoPosition) { int position = RelocInfo::kNoPosition) {
VariableProxy* proxy = VariableProxy* proxy = new (zone_)
new(zone_) VariableProxy(zone_, name, is_this, interface, position); VariableProxy(zone_, name, is_this, interface, position, id_gen_);
VISIT_AND_RETURN(VariableProxy, proxy) VISIT_AND_RETURN(VariableProxy, proxy)
} }
Property* NewProperty(Expression* obj, Expression* key, int pos) { Property* NewProperty(Expression* obj, Expression* key, int pos) {
Property* prop = new(zone_) Property(zone_, obj, key, pos); Property* prop = new (zone_) Property(zone_, obj, key, pos, id_gen_);
VISIT_AND_RETURN(Property, prop) VISIT_AND_RETURN(Property, prop)
} }
Call* NewCall(Expression* expression, Call* NewCall(Expression* expression,
ZoneList<Expression*>* arguments, ZoneList<Expression*>* arguments,
int pos) { int pos) {
Call* call = new(zone_) Call(zone_, expression, arguments, pos); Call* call = new (zone_) Call(zone_, expression, arguments, pos, id_gen_);
VISIT_AND_RETURN(Call, call) VISIT_AND_RETURN(Call, call)
} }
CallNew* NewCallNew(Expression* expression, CallNew* NewCallNew(Expression* expression,
ZoneList<Expression*>* arguments, ZoneList<Expression*>* arguments,
int pos) { int pos) {
CallNew* call = new(zone_) CallNew(zone_, expression, arguments, pos); CallNew* call =
new (zone_) CallNew(zone_, expression, arguments, pos, id_gen_);
VISIT_AND_RETURN(CallNew, call) VISIT_AND_RETURN(CallNew, call)
} }
...@@ -3395,7 +3359,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3395,7 +3359,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
ZoneList<Expression*>* arguments, ZoneList<Expression*>* arguments,
int pos) { int pos) {
CallRuntime* call = CallRuntime* call =
new(zone_) CallRuntime(zone_, name, function, arguments, pos); new (zone_) CallRuntime(zone_, name, function, arguments, pos, id_gen_);
VISIT_AND_RETURN(CallRuntime, call) VISIT_AND_RETURN(CallRuntime, call)
} }
...@@ -3403,7 +3367,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3403,7 +3367,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
Expression* expression, Expression* expression,
int pos) { int pos) {
UnaryOperation* node = UnaryOperation* node =
new(zone_) UnaryOperation(zone_, op, expression, pos); new (zone_) UnaryOperation(zone_, op, expression, pos, id_gen_);
VISIT_AND_RETURN(UnaryOperation, node) VISIT_AND_RETURN(UnaryOperation, node)
} }
...@@ -3412,7 +3376,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3412,7 +3376,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
Expression* right, Expression* right,
int pos) { int pos) {
BinaryOperation* node = BinaryOperation* node =
new(zone_) BinaryOperation(zone_, op, left, right, pos); new (zone_) BinaryOperation(zone_, op, left, right, pos, id_gen_);
VISIT_AND_RETURN(BinaryOperation, node) VISIT_AND_RETURN(BinaryOperation, node)
} }
...@@ -3421,7 +3385,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3421,7 +3385,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
Expression* expr, Expression* expr,
int pos) { int pos) {
CountOperation* node = CountOperation* node =
new(zone_) CountOperation(zone_, op, is_prefix, expr, pos); new (zone_) CountOperation(zone_, op, is_prefix, expr, pos, id_gen_);
VISIT_AND_RETURN(CountOperation, node) VISIT_AND_RETURN(CountOperation, node)
} }
...@@ -3430,7 +3394,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3430,7 +3394,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
Expression* right, Expression* right,
int pos) { int pos) {
CompareOperation* node = CompareOperation* node =
new(zone_) CompareOperation(zone_, op, left, right, pos); new (zone_) CompareOperation(zone_, op, left, right, pos, id_gen_);
VISIT_AND_RETURN(CompareOperation, node) VISIT_AND_RETURN(CompareOperation, node)
} }
...@@ -3438,8 +3402,8 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3438,8 +3402,8 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
Expression* then_expression, Expression* then_expression,
Expression* else_expression, Expression* else_expression,
int position) { int position) {
Conditional* cond = new(zone_) Conditional( Conditional* cond = new (zone_) Conditional(
zone_, condition, then_expression, else_expression, position); zone_, condition, then_expression, else_expression, position, id_gen_);
VISIT_AND_RETURN(Conditional, cond) VISIT_AND_RETURN(Conditional, cond)
} }
...@@ -3448,7 +3412,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3448,7 +3412,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
Expression* value, Expression* value,
int pos) { int pos) {
Assignment* assign = Assignment* assign =
new(zone_) Assignment(zone_, op, target, value, pos); new (zone_) Assignment(zone_, op, target, value, pos, id_gen_);
assign->Init(zone_, this); assign->Init(zone_, this);
VISIT_AND_RETURN(Assignment, assign) VISIT_AND_RETURN(Assignment, assign)
} }
...@@ -3458,13 +3422,13 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3458,13 +3422,13 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
Yield::Kind yield_kind, Yield::Kind yield_kind,
int pos) { int pos) {
if (!expression) expression = NewUndefinedLiteral(pos); if (!expression) expression = NewUndefinedLiteral(pos);
Yield* yield = new(zone_) Yield( Yield* yield = new (zone_)
zone_, generator_object, expression, yield_kind, pos); Yield(zone_, generator_object, expression, yield_kind, pos, id_gen_);
VISIT_AND_RETURN(Yield, yield) VISIT_AND_RETURN(Yield, yield)
} }
Throw* NewThrow(Expression* exception, int pos) { Throw* NewThrow(Expression* exception, int pos) {
Throw* t = new(zone_) Throw(zone_, exception, pos); Throw* t = new (zone_) Throw(zone_, exception, pos, id_gen_);
VISIT_AND_RETURN(Throw, t) VISIT_AND_RETURN(Throw, t)
} }
...@@ -3480,8 +3444,8 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3480,8 +3444,8 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
FunctionLiteral* lit = new (zone_) FunctionLiteral( FunctionLiteral* lit = new (zone_) FunctionLiteral(
zone_, name, ast_value_factory, scope, body, materialized_literal_count, zone_, name, ast_value_factory, scope, body, materialized_literal_count,
expected_property_count, handler_count, parameter_count, function_type, expected_property_count, handler_count, parameter_count, function_type,
has_duplicate_parameters, is_function, is_parenthesized, kind, has_duplicate_parameters, is_function, is_parenthesized, kind, position,
position); id_gen_);
// Top-level literal doesn't count for the AST's properties. // Top-level literal doesn't count for the AST's properties.
if (is_function == FunctionLiteral::kIsFunction) { if (is_function == FunctionLiteral::kIsFunction) {
visitor_.VisitFunctionLiteral(lit); visitor_.VisitFunctionLiteral(lit);
...@@ -3489,21 +3453,22 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3489,21 +3453,22 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
return lit; return lit;
} }
NativeFunctionLiteral* NewNativeFunctionLiteral( NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name,
const AstRawString* name, v8::Extension* extension, v8::Extension* extension,
int pos) { int pos) {
NativeFunctionLiteral* lit = NativeFunctionLiteral* lit =
new(zone_) NativeFunctionLiteral(zone_, name, extension, pos); new (zone_) NativeFunctionLiteral(zone_, name, extension, pos, id_gen_);
VISIT_AND_RETURN(NativeFunctionLiteral, lit) VISIT_AND_RETURN(NativeFunctionLiteral, lit)
} }
ThisFunction* NewThisFunction(int pos) { ThisFunction* NewThisFunction(int pos) {
ThisFunction* fun = new(zone_) ThisFunction(zone_, pos); ThisFunction* fun = new (zone_) ThisFunction(zone_, pos, id_gen_);
VISIT_AND_RETURN(ThisFunction, fun) VISIT_AND_RETURN(ThisFunction, fun)
} }
SuperReference* NewSuperReference(VariableProxy* this_var, int pos) { SuperReference* NewSuperReference(VariableProxy* this_var, int pos) {
SuperReference* super = new (zone_) SuperReference(zone_, this_var, pos); SuperReference* super =
new (zone_) SuperReference(zone_, this_var, pos, id_gen_);
VISIT_AND_RETURN(SuperReference, super); VISIT_AND_RETURN(SuperReference, super);
} }
...@@ -3513,6 +3478,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { ...@@ -3513,6 +3478,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
Zone* zone_; Zone* zone_;
Visitor visitor_; Visitor visitor_;
AstValueFactory* ast_value_factory_; AstValueFactory* ast_value_factory_;
AstNode::IdGen* id_gen_;
}; };
......
...@@ -44,8 +44,7 @@ ScriptData::ScriptData(const byte* data, int length) ...@@ -44,8 +44,7 @@ ScriptData::ScriptData(const byte* data, int length)
} }
CompilationInfo::CompilationInfo(Handle<Script> script, CompilationInfo::CompilationInfo(Handle<Script> script, Zone* zone)
Zone* zone)
: flags_(StrictModeField::encode(SLOPPY)), : flags_(StrictModeField::encode(SLOPPY)),
script_(script), script_(script),
osr_ast_id_(BailoutId::None()), osr_ast_id_(BailoutId::None()),
...@@ -86,8 +85,7 @@ CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info, ...@@ -86,8 +85,7 @@ CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info,
} }
CompilationInfo::CompilationInfo(Handle<JSFunction> closure, CompilationInfo::CompilationInfo(Handle<JSFunction> closure, Zone* zone)
Zone* zone)
: flags_(StrictModeField::encode(SLOPPY) | IsLazy::encode(true)), : flags_(StrictModeField::encode(SLOPPY) | IsLazy::encode(true)),
closure_(closure), closure_(closure),
shared_info_(Handle<SharedFunctionInfo>(closure->shared())), shared_info_(Handle<SharedFunctionInfo>(closure->shared())),
...@@ -103,8 +101,7 @@ CompilationInfo::CompilationInfo(Handle<JSFunction> closure, ...@@ -103,8 +101,7 @@ CompilationInfo::CompilationInfo(Handle<JSFunction> closure,
} }
CompilationInfo::CompilationInfo(HydrogenCodeStub* stub, CompilationInfo::CompilationInfo(HydrogenCodeStub* stub, Isolate* isolate,
Isolate* isolate,
Zone* zone) Zone* zone)
: flags_(StrictModeField::encode(SLOPPY) | IsLazy::encode(true)), : flags_(StrictModeField::encode(SLOPPY) | IsLazy::encode(true)),
osr_ast_id_(BailoutId::None()), osr_ast_id_(BailoutId::None()),
......
...@@ -365,6 +365,8 @@ class CompilationInfo { ...@@ -365,6 +365,8 @@ class CompilationInfo {
ast_value_factory_owned_ = owned; ast_value_factory_owned_ = owned;
} }
AstNode::IdGen* ast_node_id_gen() { return &ast_node_id_gen_; }
protected: protected:
CompilationInfo(Handle<Script> script, CompilationInfo(Handle<Script> script,
Zone* zone); Zone* zone);
...@@ -511,6 +513,7 @@ class CompilationInfo { ...@@ -511,6 +513,7 @@ class CompilationInfo {
AstValueFactory* ast_value_factory_; AstValueFactory* ast_value_factory_;
bool ast_value_factory_owned_; bool ast_value_factory_owned_;
AstNode::IdGen ast_node_id_gen_;
DISALLOW_COPY_AND_ASSIGN(CompilationInfo); DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
}; };
......
...@@ -357,9 +357,6 @@ typedef List<HeapObject*> DebugObjectCache; ...@@ -357,9 +357,6 @@ typedef List<HeapObject*> DebugObjectCache;
V(Object*, string_stream_current_security_token, NULL) \ V(Object*, string_stream_current_security_token, NULL) \
/* Serializer state. */ \ /* Serializer state. */ \
V(ExternalReferenceTable*, external_reference_table, NULL) \ V(ExternalReferenceTable*, external_reference_table, NULL) \
/* AstNode state. */ \
V(int, ast_node_id, 0) \
V(unsigned, ast_node_count, 0) \
V(int, pending_microtask_count, 0) \ V(int, pending_microtask_count, 0) \
V(bool, autorun_microtasks, true) \ V(bool, autorun_microtasks, true) \
V(HStatistics*, hstatistics, NULL) \ V(HStatistics*, hstatistics, NULL) \
......
...@@ -345,19 +345,18 @@ class ParserTraits::Checkpoint ...@@ -345,19 +345,18 @@ class ParserTraits::Checkpoint
: public ParserBase<ParserTraits>::CheckpointBase { : public ParserBase<ParserTraits>::CheckpointBase {
public: public:
explicit Checkpoint(ParserBase<ParserTraits>* parser) explicit Checkpoint(ParserBase<ParserTraits>* parser)
: CheckpointBase(parser) { : CheckpointBase(parser), parser_(parser) {
isolate_ = parser->zone()->isolate(); saved_ast_node_id_gen_ = *parser_->ast_node_id_gen_;
saved_ast_node_id_ = isolate_->ast_node_id();
} }
void Restore() { void Restore() {
CheckpointBase::Restore(); CheckpointBase::Restore();
isolate_->set_ast_node_id(saved_ast_node_id_); *parser_->ast_node_id_gen_ = saved_ast_node_id_gen_;
} }
private: private:
Isolate* isolate_; ParserBase<ParserTraits>* parser_;
int saved_ast_node_id_; AstNode::IdGen saved_ast_node_id_gen_;
}; };
...@@ -732,9 +731,9 @@ FunctionLiteral* ParserTraits::ParseFunctionLiteral( ...@@ -732,9 +731,9 @@ FunctionLiteral* ParserTraits::ParseFunctionLiteral(
Parser::Parser(CompilationInfo* info) Parser::Parser(CompilationInfo* info)
: ParserBase<ParserTraits>(&scanner_, : ParserBase<ParserTraits>(
info->isolate()->stack_guard()->real_climit(), &scanner_, info->isolate()->stack_guard()->real_climit(),
info->extension(), NULL, info->zone(), this), info->extension(), NULL, info->zone(), info->ast_node_id_gen(), this),
isolate_(info->isolate()), isolate_(info->isolate()),
script_(info->script()), script_(info->script()),
scanner_(isolate_->unicode_cache()), scanner_(isolate_->unicode_cache()),
...@@ -749,7 +748,6 @@ Parser::Parser(CompilationInfo* info) ...@@ -749,7 +748,6 @@ Parser::Parser(CompilationInfo* info)
pending_error_arg_(NULL), pending_error_arg_(NULL),
pending_error_char_arg_(NULL) { pending_error_char_arg_(NULL) {
DCHECK(!script_.is_null()); DCHECK(!script_.is_null());
isolate_->set_ast_node_id(0);
set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping); set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping);
set_allow_modules(!info->is_native() && FLAG_harmony_modules); set_allow_modules(!info->is_native() && FLAG_harmony_modules);
set_allow_natives_syntax(FLAG_allow_natives_syntax || info->is_native()); set_allow_natives_syntax(FLAG_allow_natives_syntax || info->is_native());
...@@ -861,7 +859,7 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, ...@@ -861,7 +859,7 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info,
// Enters 'scope'. // Enters 'scope'.
FunctionState function_state(&function_state_, &scope_, scope, zone(), FunctionState function_state(&function_state_, &scope_, scope, zone(),
ast_value_factory_); ast_value_factory_, info->ast_node_id_gen());
scope_->SetStrictMode(info->strict_mode()); scope_->SetStrictMode(info->strict_mode());
ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone());
...@@ -979,7 +977,7 @@ FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source) { ...@@ -979,7 +977,7 @@ FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source) {
} }
original_scope_ = scope; original_scope_ = scope;
FunctionState function_state(&function_state_, &scope_, scope, zone(), FunctionState function_state(&function_state_, &scope_, scope, zone(),
ast_value_factory_); ast_value_factory_, info()->ast_node_id_gen());
DCHECK(scope->strict_mode() == SLOPPY || info()->strict_mode() == STRICT); DCHECK(scope->strict_mode() == SLOPPY || info()->strict_mode() == STRICT);
DCHECK(info()->strict_mode() == shared_info->strict_mode()); DCHECK(info()->strict_mode() == shared_info->strict_mode());
scope->SetStrictMode(shared_info->strict_mode()); scope->SetStrictMode(shared_info->strict_mode());
...@@ -3442,7 +3440,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral( ...@@ -3442,7 +3440,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
// Parse function body. // Parse function body.
{ {
FunctionState function_state(&function_state_, &scope_, scope, zone(), FunctionState function_state(&function_state_, &scope_, scope, zone(),
ast_value_factory_); ast_value_factory_, info()->ast_node_id_gen());
scope_->SetScopeName(function_name); scope_->SetScopeName(function_name);
if (is_generator) { if (is_generator) {
......
...@@ -378,17 +378,17 @@ class ParserTraits { ...@@ -378,17 +378,17 @@ class ParserTraits {
explicit ParserTraits(Parser* parser) : parser_(parser) {} explicit ParserTraits(Parser* parser) : parser_(parser) {}
// Custom operations executed when FunctionStates are created and destructed. // Custom operations executed when FunctionStates are created and destructed.
template<typename FunctionState> template <typename FunctionState>
static void SetUpFunctionState(FunctionState* function_state, Zone* zone) { static void SetUpFunctionState(FunctionState* function_state) {
Isolate* isolate = zone->isolate(); function_state->saved_id_gen_ = *function_state->ast_node_id_gen_;
function_state->saved_ast_node_id_ = isolate->ast_node_id(); *function_state->ast_node_id_gen_ =
isolate->set_ast_node_id(BailoutId::FirstUsable().ToInt()); AstNode::IdGen(BailoutId::FirstUsable().ToInt());
} }
template<typename FunctionState> template <typename FunctionState>
static void TearDownFunctionState(FunctionState* function_state, Zone* zone) { static void TearDownFunctionState(FunctionState* function_state) {
if (function_state->outer_function_state_ != NULL) { if (function_state->outer_function_state_ != NULL) {
zone->isolate()->set_ast_node_id(function_state->saved_ast_node_id_); *function_state->ast_node_id_gen_ = function_state->saved_id_gen_;
} }
} }
......
...@@ -68,6 +68,7 @@ class ParserBase : public Traits { ...@@ -68,6 +68,7 @@ class ParserBase : public Traits {
ParserBase(Scanner* scanner, uintptr_t stack_limit, v8::Extension* extension, ParserBase(Scanner* scanner, uintptr_t stack_limit, v8::Extension* extension,
ParserRecorder* log, typename Traits::Type::Zone* zone, ParserRecorder* log, typename Traits::Type::Zone* zone,
AstNode::IdGen* ast_node_id_gen,
typename Traits::Type::Parser this_object) typename Traits::Type::Parser this_object)
: Traits(this_object), : Traits(this_object),
parenthesized_function_(false), parenthesized_function_(false),
...@@ -84,7 +85,8 @@ class ParserBase : public Traits { ...@@ -84,7 +85,8 @@ class ParserBase : public Traits {
allow_natives_syntax_(false), allow_natives_syntax_(false),
allow_generators_(false), allow_generators_(false),
allow_arrow_functions_(false), allow_arrow_functions_(false),
zone_(zone) {} zone_(zone),
ast_node_id_gen_(ast_node_id_gen) {}
// Getters that indicate whether certain syntactical constructs are // Getters that indicate whether certain syntactical constructs are
// allowed to be parsed by this instance of the parser. // allowed to be parsed by this instance of the parser.
...@@ -156,17 +158,18 @@ class ParserBase : public Traits { ...@@ -156,17 +158,18 @@ class ParserBase : public Traits {
class FunctionState BASE_EMBEDDED { class FunctionState BASE_EMBEDDED {
public: public:
FunctionState( FunctionState(FunctionState** function_state_stack,
FunctionState** function_state_stack,
typename Traits::Type::Scope** scope_stack, typename Traits::Type::Scope** scope_stack,
typename Traits::Type::Scope* scope, typename Traits::Type::Scope* scope,
typename Traits::Type::Zone* zone = NULL, typename Traits::Type::Zone* zone = NULL,
AstValueFactory* ast_value_factory = NULL); AstValueFactory* ast_value_factory = NULL,
AstNode::IdGen* ast_node_id_gen = NULL);
FunctionState(FunctionState** function_state_stack, FunctionState(FunctionState** function_state_stack,
typename Traits::Type::Scope** scope_stack, typename Traits::Type::Scope** scope_stack,
typename Traits::Type::Scope** scope, typename Traits::Type::Scope** scope,
typename Traits::Type::Zone* zone = NULL, typename Traits::Type::Zone* zone = NULL,
AstValueFactory* ast_value_factory = NULL); AstValueFactory* ast_value_factory = NULL,
AstNode::IdGen* ast_node_id_gen = NULL);
~FunctionState(); ~FunctionState();
int NextMaterializedLiteralIndex() { int NextMaterializedLiteralIndex() {
...@@ -222,7 +225,8 @@ class ParserBase : public Traits { ...@@ -222,7 +225,8 @@ class ParserBase : public Traits {
FunctionState* outer_function_state_; FunctionState* outer_function_state_;
typename Traits::Type::Scope** scope_stack_; typename Traits::Type::Scope** scope_stack_;
typename Traits::Type::Scope* outer_scope_; typename Traits::Type::Scope* outer_scope_;
int saved_ast_node_id_; // Only used by ParserTraits. AstNode::IdGen* ast_node_id_gen_; // Only used by ParserTraits.
AstNode::IdGen saved_id_gen_; // Ditto.
typename Traits::Type::Zone* extra_param_; typename Traits::Type::Zone* extra_param_;
typename Traits::Type::Factory factory_; typename Traits::Type::Factory factory_;
...@@ -281,6 +285,7 @@ class ParserBase : public Traits { ...@@ -281,6 +285,7 @@ class ParserBase : public Traits {
void set_stack_overflow() { stack_overflow_ = true; } void set_stack_overflow() { stack_overflow_ = true; }
Mode mode() const { return mode_; } Mode mode() const { return mode_; }
typename Traits::Type::Zone* zone() const { return zone_; } typename Traits::Type::Zone* zone() const { return zone_; }
AstNode::IdGen* ast_node_id_gen() const { return ast_node_id_gen_; }
INLINE(Token::Value peek()) { INLINE(Token::Value peek()) {
if (stack_overflow_) return Token::ILLEGAL; if (stack_overflow_) return Token::ILLEGAL;
...@@ -576,6 +581,7 @@ class ParserBase : public Traits { ...@@ -576,6 +581,7 @@ class ParserBase : public Traits {
bool allow_arrow_functions_; bool allow_arrow_functions_;
typename Traits::Type::Zone* zone_; // Only used by Parser. typename Traits::Type::Zone* zone_; // Only used by Parser.
AstNode::IdGen* ast_node_id_gen_;
}; };
...@@ -940,7 +946,7 @@ class PreParserScope { ...@@ -940,7 +946,7 @@ class PreParserScope {
class PreParserFactory { class PreParserFactory {
public: public:
explicit PreParserFactory(void* extra_param1, void* extra_param2) {} PreParserFactory(void*, void*, void*) {}
PreParserExpression NewStringLiteral(PreParserIdentifier identifier, PreParserExpression NewStringLiteral(PreParserIdentifier identifier,
int pos) { int pos) {
return PreParserExpression::Default(); return PreParserExpression::Default();
...@@ -1106,10 +1112,10 @@ class PreParserTraits { ...@@ -1106,10 +1112,10 @@ class PreParserTraits {
// Custom operations executed when FunctionStates are created and // Custom operations executed when FunctionStates are created and
// destructed. (The PreParser doesn't need to do anything.) // destructed. (The PreParser doesn't need to do anything.)
template<typename FunctionState> template <typename FunctionState>
static void SetUpFunctionState(FunctionState* function_state, void*) {} static void SetUpFunctionState(FunctionState* function_state) {}
template<typename FunctionState> template <typename FunctionState>
static void TearDownFunctionState(FunctionState* function_state, void*) {} static void TearDownFunctionState(FunctionState* function_state) {}
// Helper functions for recursive descent. // Helper functions for recursive descent.
static bool IsEvalOrArguments(PreParserIdentifier identifier) { static bool IsEvalOrArguments(PreParserIdentifier identifier) {
...@@ -1362,7 +1368,7 @@ class PreParser : public ParserBase<PreParserTraits> { ...@@ -1362,7 +1368,7 @@ class PreParser : public ParserBase<PreParserTraits> {
}; };
PreParser(Scanner* scanner, ParserRecorder* log, uintptr_t stack_limit) PreParser(Scanner* scanner, ParserRecorder* log, uintptr_t stack_limit)
: ParserBase<PreParserTraits>(scanner, stack_limit, NULL, log, NULL, : ParserBase<PreParserTraits>(scanner, stack_limit, NULL, log, NULL, NULL,
this) {} this) {}
// Pre-parse the program from the character stream; returns true on // Pre-parse the program from the character stream; returns true on
...@@ -1497,13 +1503,12 @@ PreParserStatementList PreParserTraits::ParseEagerFunctionBody( ...@@ -1497,13 +1503,12 @@ PreParserStatementList PreParserTraits::ParseEagerFunctionBody(
} }
template<class Traits> template <class Traits>
ParserBase<Traits>::FunctionState::FunctionState( ParserBase<Traits>::FunctionState::FunctionState(
FunctionState** function_state_stack, FunctionState** function_state_stack,
typename Traits::Type::Scope** scope_stack, typename Traits::Type::Scope** scope_stack,
typename Traits::Type::Scope* scope, typename Traits::Type::Scope* scope, typename Traits::Type::Zone* zone,
typename Traits::Type::Zone* extra_param, AstValueFactory* ast_value_factory, AstNode::IdGen* ast_node_id_gen)
AstValueFactory* ast_value_factory)
: next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize), : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize),
next_handler_index_(0), next_handler_index_(0),
expected_property_count_(0), expected_property_count_(0),
...@@ -1513,12 +1518,11 @@ ParserBase<Traits>::FunctionState::FunctionState( ...@@ -1513,12 +1518,11 @@ ParserBase<Traits>::FunctionState::FunctionState(
outer_function_state_(*function_state_stack), outer_function_state_(*function_state_stack),
scope_stack_(scope_stack), scope_stack_(scope_stack),
outer_scope_(*scope_stack), outer_scope_(*scope_stack),
saved_ast_node_id_(0), ast_node_id_gen_(ast_node_id_gen),
extra_param_(extra_param), factory_(zone, ast_value_factory, ast_node_id_gen) {
factory_(extra_param, ast_value_factory) {
*scope_stack_ = scope; *scope_stack_ = scope;
*function_state_stack = this; *function_state_stack = this;
Traits::SetUpFunctionState(this, extra_param); Traits::SetUpFunctionState(this);
} }
...@@ -1526,9 +1530,8 @@ template <class Traits> ...@@ -1526,9 +1530,8 @@ template <class Traits>
ParserBase<Traits>::FunctionState::FunctionState( ParserBase<Traits>::FunctionState::FunctionState(
FunctionState** function_state_stack, FunctionState** function_state_stack,
typename Traits::Type::Scope** scope_stack, typename Traits::Type::Scope** scope_stack,
typename Traits::Type::Scope** scope, typename Traits::Type::Scope** scope, typename Traits::Type::Zone* zone,
typename Traits::Type::Zone* extra_param, AstValueFactory* ast_value_factory, AstNode::IdGen* ast_node_id_gen)
AstValueFactory* ast_value_factory)
: next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize), : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize),
next_handler_index_(0), next_handler_index_(0),
expected_property_count_(0), expected_property_count_(0),
...@@ -1538,12 +1541,11 @@ ParserBase<Traits>::FunctionState::FunctionState( ...@@ -1538,12 +1541,11 @@ ParserBase<Traits>::FunctionState::FunctionState(
outer_function_state_(*function_state_stack), outer_function_state_(*function_state_stack),
scope_stack_(scope_stack), scope_stack_(scope_stack),
outer_scope_(*scope_stack), outer_scope_(*scope_stack),
saved_ast_node_id_(0), ast_node_id_gen_(ast_node_id_gen),
extra_param_(extra_param), factory_(zone, ast_value_factory, ast_node_id_gen) {
factory_(extra_param, ast_value_factory) {
*scope_stack_ = *scope; *scope_stack_ = *scope;
*function_state_stack = this; *function_state_stack = this;
Traits::SetUpFunctionState(this, extra_param); Traits::SetUpFunctionState(this);
} }
...@@ -1551,7 +1553,7 @@ template <class Traits> ...@@ -1551,7 +1553,7 @@ template <class Traits>
ParserBase<Traits>::FunctionState::~FunctionState() { ParserBase<Traits>::FunctionState::~FunctionState() {
*scope_stack_ = outer_scope_; *scope_stack_ = outer_scope_;
*function_state_stack_ = outer_function_state_; *function_state_stack_ = outer_function_state_;
Traits::TearDownFunctionState(this, extra_param_); Traits::TearDownFunctionState(this);
} }
...@@ -2514,7 +2516,7 @@ typename ParserBase<Traits>::ExpressionT ParserBase< ...@@ -2514,7 +2516,7 @@ typename ParserBase<Traits>::ExpressionT ParserBase<
{ {
FunctionState function_state(&function_state_, &scope_, &scope, zone(), FunctionState function_state(&function_state_, &scope_, &scope, zone(),
this->ast_value_factory()); this->ast_value_factory(), ast_node_id_gen_);
Scanner::Location dupe_error_loc = Scanner::Location::invalid(); Scanner::Location dupe_error_loc = Scanner::Location::invalid();
num_parameters = Traits::DeclareArrowParametersFromExpression( num_parameters = Traits::DeclareArrowParametersFromExpression(
params_ast, scope_, &dupe_error_loc, ok); params_ast, scope_, &dupe_error_loc, ok);
......
...@@ -15,14 +15,14 @@ namespace internal { ...@@ -15,14 +15,14 @@ namespace internal {
class Processor: public AstVisitor { class Processor: public AstVisitor {
public: public:
Processor(Variable* result, Zone* zone) Processor(Variable* result, Zone* zone, AstNode::IdGen* ast_node_id_gen)
: result_(result), : result_(result),
result_assigned_(false), result_assigned_(false),
is_set_(false), is_set_(false),
in_try_(false), in_try_(false),
// Passing a null AstValueFactory is fine, because Processor doesn't // Passing a null AstValueFactory is fine, because Processor doesn't
// need to create strings or literals. // need to create strings or literals.
factory_(zone, NULL) { factory_(zone, NULL, ast_node_id_gen) {
InitializeAstVisitor(zone); InitializeAstVisitor(zone);
} }
...@@ -240,7 +240,7 @@ bool Rewriter::Rewrite(CompilationInfo* info) { ...@@ -240,7 +240,7 @@ bool Rewriter::Rewrite(CompilationInfo* info) {
scope->NewTemporary(info->ast_value_factory()->dot_result_string()); scope->NewTemporary(info->ast_value_factory()->dot_result_string());
// The name string must be internalized at this point. // The name string must be internalized at this point.
DCHECK(!result->name().is_null()); DCHECK(!result->name().is_null());
Processor processor(result, info->zone()); Processor processor(result, info->zone(), info->ast_node_id_gen());
processor.Process(body); processor.Process(body);
if (processor.HasStackOverflow()) return false; if (processor.HasStackOverflow()) return false;
......
...@@ -267,9 +267,8 @@ bool Scope::Analyze(CompilationInfo* info) { ...@@ -267,9 +267,8 @@ bool Scope::Analyze(CompilationInfo* info) {
// Allocate the variables. // Allocate the variables.
{ {
// Passing NULL as AstValueFactory is ok, because AllocateVariables doesn't AstNodeFactory<AstNullVisitor> ast_node_factory(
// need to create new strings or values. info->zone(), info->ast_value_factory(), info->ast_node_id_gen());
AstNodeFactory<AstNullVisitor> ast_node_factory(info->zone(), NULL);
if (!top->AllocateVariables(info, &ast_node_factory)) return false; if (!top->AllocateVariables(info, &ast_node_factory)) return false;
} }
......
...@@ -63,9 +63,9 @@ class Zone { ...@@ -63,9 +63,9 @@ class Zone {
inline void adjust_segment_bytes_allocated(int delta); inline void adjust_segment_bytes_allocated(int delta);
inline unsigned allocation_size() { return allocation_size_; } inline unsigned allocation_size() const { return allocation_size_; }
inline Isolate* isolate() { return isolate_; } inline Isolate* isolate() const { return isolate_; }
private: private:
friend class Isolate; friend class Isolate;
......
...@@ -41,7 +41,8 @@ TEST(List) { ...@@ -41,7 +41,8 @@ TEST(List) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Zone zone(isolate); Zone zone(isolate);
AstNodeFactory<AstNullVisitor> factory(&zone, NULL); AstNode::IdGen id_gen;
AstNodeFactory<AstNullVisitor> factory(&zone, NULL, &id_gen);
AstNode* node = factory.NewEmptyStatement(RelocInfo::kNoPosition); AstNode* node = factory.NewEmptyStatement(RelocInfo::kNoPosition);
list->Add(node); list->Add(node);
CHECK_EQ(1, list->length()); CHECK_EQ(1, list->length());
......
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