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

Unified Diff: src/ast.h

Issue 7399023: Pass isolate to AST ID functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: A bit less ugly Created 9 years, 5 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 b92f2db142bcc269c12dde4d8ae4d426b7790ee7..23df48b8b1e09a00ee434be3da2f4d2340559d26 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -169,9 +169,11 @@ class AstNode: public ZoneObject {
static void ResetIds() { Isolate::Current()->set_ast_node_id(0); }
protected:
- static unsigned GetNextId() { return ReserveIdRange(1); }
- static unsigned ReserveIdRange(int n) {
- Isolate* isolate = Isolate::Current();
+ static unsigned GetNextId(Isolate* isolate) {
+ return ReserveIdRange(isolate, 1);
+ }
+
+ static unsigned ReserveIdRange(Isolate* isolate, int n) {
unsigned tmp = isolate->ast_node_id();
isolate->set_ast_node_id(tmp + n);
return tmp;
@@ -219,7 +221,9 @@ class Expression: public AstNode {
kTest
};
- Expression() : id_(GetNextId()), test_id_(GetNextId()) {}
+ explicit Expression(Isolate* isolate)
+ : id_(GetNextId(isolate)),
+ test_id_(GetNextId(isolate)) {}
virtual int position() const {
UNREACHABLE();
@@ -286,6 +290,7 @@ class Expression: public AstNode {
*/
class ValidLeftHandSideSentinel: public Expression {
public:
+ explicit ValidLeftHandSideSentinel(Isolate* isolate) : Expression(isolate) {}
virtual bool IsValidLeftHandSide() { return true; }
virtual void Accept(AstVisitor* v) { UNREACHABLE(); }
virtual bool IsInlineable() const;
@@ -317,7 +322,7 @@ class BreakableStatement: public Statement {
int ExitId() const { return exit_id_; }
protected:
- inline BreakableStatement(ZoneStringList* labels, Type type);
+ BreakableStatement(Isolate* isolate, ZoneStringList* labels, Type type);
private:
ZoneStringList* labels_;
@@ -330,7 +335,10 @@ class BreakableStatement: public Statement {
class Block: public BreakableStatement {
public:
- inline Block(ZoneStringList* labels, int capacity, bool is_initializer_block);
+ inline Block(Isolate* isolate,
+ ZoneStringList* labels,
+ int capacity,
+ bool is_initializer_block);
DECLARE_NODE_TYPE(Block)
@@ -398,7 +406,7 @@ class IterationStatement: public BreakableStatement {
Label* continue_target() { return &continue_target_; }
protected:
- explicit inline IterationStatement(ZoneStringList* labels);
+ inline IterationStatement(Isolate* isolate, ZoneStringList* labels);
void Initialize(Statement* body) {
body_ = body;
@@ -413,7 +421,7 @@ class IterationStatement: public BreakableStatement {
class DoWhileStatement: public IterationStatement {
public:
- explicit inline DoWhileStatement(ZoneStringList* labels);
+ inline DoWhileStatement(Isolate* isolate, ZoneStringList* labels);
DECLARE_NODE_TYPE(DoWhileStatement)
@@ -446,7 +454,7 @@ class DoWhileStatement: public IterationStatement {
class WhileStatement: public IterationStatement {
public:
- explicit inline WhileStatement(ZoneStringList* labels);
+ inline WhileStatement(Isolate* isolate, ZoneStringList* labels);
DECLARE_NODE_TYPE(WhileStatement)
@@ -479,7 +487,7 @@ class WhileStatement: public IterationStatement {
class ForStatement: public IterationStatement {
public:
- explicit inline ForStatement(ZoneStringList* labels);
+ inline ForStatement(Isolate* isolate, ZoneStringList* labels);
DECLARE_NODE_TYPE(ForStatement)
@@ -528,7 +536,7 @@ class ForStatement: public IterationStatement {
class ForInStatement: public IterationStatement {
public:
- explicit inline ForInStatement(ZoneStringList* labels);
+ inline ForInStatement(Isolate* isolate, ZoneStringList* labels);
DECLARE_NODE_TYPE(ForInStatement)
@@ -645,7 +653,10 @@ class ExitContextStatement: public Statement {
class CaseClause: public ZoneObject {
public:
- CaseClause(Expression* label, ZoneList<Statement*>* statements, int pos);
+ CaseClause(Isolate* isolate,
+ Expression* label,
+ ZoneList<Statement*>* statements,
+ int pos);
bool is_default() const { return label_ == NULL; }
Expression* label() const {
@@ -680,7 +691,7 @@ class CaseClause: public ZoneObject {
class SwitchStatement: public BreakableStatement {
public:
- explicit inline SwitchStatement(ZoneStringList* labels);
+ inline SwitchStatement(Isolate* isolate, ZoneStringList* labels);
DECLARE_NODE_TYPE(SwitchStatement)
@@ -706,15 +717,16 @@ class SwitchStatement: public BreakableStatement {
// given if-statement has a then- or an else-part containing code.
class IfStatement: public Statement {
public:
- IfStatement(Expression* condition,
+ IfStatement(Isolate* isolate,
+ Expression* condition,
Statement* then_statement,
Statement* else_statement)
: condition_(condition),
then_statement_(then_statement),
else_statement_(else_statement),
- if_id_(GetNextId()),
- then_id_(GetNextId()),
- else_id_(GetNextId()) {
+ if_id_(GetNextId(isolate)),
+ then_id_(GetNextId(isolate)),
+ else_id_(GetNextId(isolate)) {
}
DECLARE_NODE_TYPE(IfStatement)
@@ -843,7 +855,8 @@ class EmptyStatement: public Statement {
class Literal: public Expression {
public:
- explicit Literal(Handle<Object> handle) : handle_(handle) { }
+ Literal(Isolate* isolate, Handle<Object> handle)
+ : Expression(isolate), handle_(handle) { }
DECLARE_NODE_TYPE(Literal)
@@ -896,8 +909,14 @@ class Literal: public Expression {
// Base class for literals that needs space in the corresponding JSFunction.
class MaterializedLiteral: public Expression {
public:
- explicit MaterializedLiteral(int literal_index, bool is_simple, int depth)
- : literal_index_(literal_index), is_simple_(is_simple), depth_(depth) {}
+ MaterializedLiteral(Isolate* isolate,
+ int literal_index,
+ bool is_simple,
+ int depth)
+ : Expression(isolate),
+ literal_index_(literal_index),
+ is_simple_(is_simple),
+ depth_(depth) {}
virtual MaterializedLiteral* AsMaterializedLiteral() { return this; }
@@ -953,14 +972,15 @@ class ObjectLiteral: public MaterializedLiteral {
bool emit_store_;
};
- ObjectLiteral(Handle<FixedArray> constant_properties,
+ ObjectLiteral(Isolate* isolate,
+ Handle<FixedArray> constant_properties,
ZoneList<Property*>* properties,
int literal_index,
bool is_simple,
bool fast_elements,
int depth,
bool has_function)
- : MaterializedLiteral(literal_index, is_simple, depth),
+ : MaterializedLiteral(isolate, literal_index, is_simple, depth),
constant_properties_(constant_properties),
properties_(properties),
fast_elements_(fast_elements),
@@ -999,10 +1019,11 @@ class ObjectLiteral: public MaterializedLiteral {
// Node for capturing a regexp literal.
class RegExpLiteral: public MaterializedLiteral {
public:
- RegExpLiteral(Handle<String> pattern,
+ RegExpLiteral(Isolate* isolate,
+ Handle<String> pattern,
Handle<String> flags,
int literal_index)
- : MaterializedLiteral(literal_index, false, 1),
+ : MaterializedLiteral(isolate, literal_index, false, 1),
pattern_(pattern),
flags_(flags) {}
@@ -1020,15 +1041,16 @@ class RegExpLiteral: public MaterializedLiteral {
// for minimizing the work when constructing it at runtime.
class ArrayLiteral: public MaterializedLiteral {
public:
- ArrayLiteral(Handle<FixedArray> constant_elements,
+ ArrayLiteral(Isolate* isolate,
+ Handle<FixedArray> constant_elements,
ZoneList<Expression*>* values,
int literal_index,
bool is_simple,
int depth)
- : MaterializedLiteral(literal_index, is_simple, depth),
+ : MaterializedLiteral(isolate, literal_index, is_simple, depth),
constant_elements_(constant_elements),
values_(values),
- first_element_id_(ReserveIdRange(values->length())) {}
+ first_element_id_(ReserveIdRange(isolate, values->length())) {}
DECLARE_NODE_TYPE(ArrayLiteral)
@@ -1047,7 +1069,7 @@ class ArrayLiteral: public MaterializedLiteral {
class VariableProxy: public Expression {
public:
- explicit VariableProxy(Variable* var);
+ VariableProxy(Isolate* isolate, Variable* var);
DECLARE_NODE_TYPE(VariableProxy)
@@ -1094,11 +1116,12 @@ class VariableProxy: public Expression {
bool is_trivial_;
int position_;
- VariableProxy(Handle<String> name,
+ VariableProxy(Isolate* isolate,
+ Handle<String> name,
bool is_this,
bool inside_with,
int position = RelocInfo::kNoPosition);
- explicit VariableProxy(bool is_this);
+ VariableProxy(Isolate* isolate, bool is_this);
friend class Scope;
};
@@ -1109,7 +1132,8 @@ class VariableProxySentinel: public VariableProxy {
virtual bool IsValidLeftHandSide() { return !is_this(); }
private:
- explicit VariableProxySentinel(bool is_this) : VariableProxy(is_this) { }
+ VariableProxySentinel(Isolate* isolate, bool is_this)
+ : VariableProxy(isolate, is_this) { }
friend class AstSentinels;
};
@@ -1139,8 +1163,8 @@ class Slot: public Expression {
LOOKUP
};
- Slot(Variable* var, Type type, int index)
- : var_(var), type_(type), index_(index) {
+ Slot(Isolate* isolate, Variable* var, Type type, int index)
+ : Expression(isolate), var_(var), type_(type), index_(index) {
ASSERT(var != NULL);
}
@@ -1171,8 +1195,13 @@ class Property: public Expression {
// properties should use the global object as receiver, not the base object
// of the resolved Reference.
enum Type { NORMAL, SYNTHETIC };
- Property(Expression* obj, Expression* key, int pos, Type type = NORMAL)
- : obj_(obj),
+ Property(Isolate* isolate,
+ Expression* obj,
+ Expression* key,
+ int pos,
+ Type type = NORMAL)
+ : Expression(isolate),
+ obj_(obj),
key_(key),
pos_(pos),
type_(type),
@@ -1224,14 +1253,18 @@ class Property: public Expression {
class Call: public Expression {
public:
- Call(Expression* expression, ZoneList<Expression*>* arguments, int pos)
- : expression_(expression),
+ Call(Isolate* isolate,
+ Expression* expression,
+ ZoneList<Expression*>* arguments,
+ int pos)
+ : Expression(isolate),
+ expression_(expression),
arguments_(arguments),
pos_(pos),
is_monomorphic_(false),
check_type_(RECEIVER_MAP_CHECK),
receiver_types_(NULL),
- return_id_(GetNextId()) {
+ return_id_(GetNextId(isolate)) {
}
DECLARE_NODE_TYPE(Call)
@@ -1310,8 +1343,14 @@ class AstSentinels {
class CallNew: public Expression {
public:
- CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos)
- : expression_(expression), arguments_(arguments), pos_(pos) { }
+ CallNew(Isolate* isolate,
+ Expression* expression,
+ ZoneList<Expression*>* arguments,
+ int pos)
+ : Expression(isolate),
+ expression_(expression),
+ arguments_(arguments),
+ pos_(pos) { }
DECLARE_NODE_TYPE(CallNew)
@@ -1334,10 +1373,14 @@ class CallNew: public Expression {
// implemented in JavaScript (see "v8natives.js").
class CallRuntime: public Expression {
public:
- CallRuntime(Handle<String> name,
+ CallRuntime(Isolate* isolate,
+ Handle<String> name,
const Runtime::Function* function,
ZoneList<Expression*>* arguments)
- : name_(name), function_(function), arguments_(arguments) { }
+ : Expression(isolate),
+ name_(name),
+ function_(function),
+ arguments_(arguments) { }
DECLARE_NODE_TYPE(CallRuntime)
@@ -1357,8 +1400,11 @@ class CallRuntime: public Expression {
class UnaryOperation: public Expression {
public:
- UnaryOperation(Token::Value op, Expression* expression, int pos)
- : op_(op), expression_(expression), pos_(pos) {
+ UnaryOperation(Isolate* isolate,
+ Token::Value op,
+ Expression* expression,
+ int pos)
+ : Expression(isolate), op_(op), expression_(expression), pos_(pos) {
ASSERT(Token::IsUnaryOp(op));
}
@@ -1381,14 +1427,15 @@ class UnaryOperation: public Expression {
class BinaryOperation: public Expression {
public:
- BinaryOperation(Token::Value op,
+ BinaryOperation(Isolate* isolate,
+ Token::Value op,
Expression* left,
Expression* right,
int pos)
- : op_(op), left_(left), right_(right), pos_(pos) {
+ : Expression(isolate), op_(op), left_(left), right_(right), pos_(pos) {
ASSERT(Token::IsBinaryOp(op));
right_id_ = (op == Token::AND || op == Token::OR)
- ? static_cast<int>(GetNextId())
+ ? static_cast<int>(GetNextId(isolate))
: AstNode::kNoNumber;
}
@@ -1419,13 +1466,18 @@ class BinaryOperation: public Expression {
class CountOperation: public Expression {
public:
- CountOperation(Token::Value op, bool is_prefix, Expression* expr, int pos)
- : op_(op),
+ CountOperation(Isolate* isolate,
+ Token::Value op,
+ bool is_prefix,
+ Expression* expr,
+ int pos)
+ : Expression(isolate),
+ op_(op),
is_prefix_(is_prefix),
expression_(expr),
pos_(pos),
- assignment_id_(GetNextId()),
- count_id_(GetNextId()),
+ assignment_id_(GetNextId(isolate)),
+ count_id_(GetNextId(isolate)),
receiver_types_(NULL) { }
DECLARE_NODE_TYPE(CountOperation)
@@ -1471,11 +1523,17 @@ class CountOperation: public Expression {
class CompareOperation: public Expression {
public:
- CompareOperation(Token::Value op,
+ CompareOperation(Isolate* isolate,
+ Token::Value op,
Expression* left,
Expression* right,
int pos)
- : op_(op), left_(left), right_(right), pos_(pos), compare_type_(NONE) {
+ : Expression(isolate),
+ op_(op),
+ left_(left),
+ right_(right),
+ pos_(pos),
+ compare_type_(NONE) {
ASSERT(Token::IsCompareOp(op));
}
@@ -1510,8 +1568,8 @@ class CompareOperation: public Expression {
class CompareToNull: public Expression {
public:
- CompareToNull(bool is_strict, Expression* expression)
- : is_strict_(is_strict), expression_(expression) { }
+ CompareToNull(Isolate* isolate, bool is_strict, Expression* expression)
+ : Expression(isolate), is_strict_(is_strict), expression_(expression) { }
DECLARE_NODE_TYPE(CompareToNull)
@@ -1529,18 +1587,20 @@ class CompareToNull: public Expression {
class Conditional: public Expression {
public:
- Conditional(Expression* condition,
+ Conditional(Isolate* isolate,
+ Expression* condition,
Expression* then_expression,
Expression* else_expression,
int then_expression_position,
int else_expression_position)
- : condition_(condition),
+ : Expression(isolate),
+ condition_(condition),
then_expression_(then_expression),
else_expression_(else_expression),
then_expression_position_(then_expression_position),
else_expression_position_(else_expression_position),
- then_id_(GetNextId()),
- else_id_(GetNextId()) {
+ then_id_(GetNextId(isolate)),
+ else_id_(GetNextId(isolate)) {
}
DECLARE_NODE_TYPE(Conditional)
@@ -1570,7 +1630,11 @@ class Conditional: public Expression {
class Assignment: public Expression {
public:
- Assignment(Token::Value op, Expression* target, Expression* value, int pos);
+ Assignment(Isolate* isolate,
+ Token::Value op,
+ Expression* target,
+ Expression* value,
+ int pos);
DECLARE_NODE_TYPE(Assignment)
@@ -1630,8 +1694,8 @@ class Assignment: public Expression {
class Throw: public Expression {
public:
- Throw(Expression* exception, int pos)
- : exception_(exception), pos_(pos) {}
+ Throw(Isolate* isolate, Expression* exception, int pos)
+ : Expression(isolate), exception_(exception), pos_(pos) {}
DECLARE_NODE_TYPE(Throw)
@@ -1647,7 +1711,8 @@ class Throw: public Expression {
class FunctionLiteral: public Expression {
public:
- FunctionLiteral(Handle<String> name,
+ FunctionLiteral(Isolate* isolate,
+ Handle<String> name,
Scope* scope,
ZoneList<Statement*>* body,
int materialized_literal_count,
@@ -1659,7 +1724,8 @@ class FunctionLiteral: public Expression {
int end_position,
bool is_expression,
bool has_duplicate_parameters)
- : name_(name),
+ : Expression(isolate),
+ name_(name),
scope_(scope),
body_(body),
materialized_literal_count_(materialized_literal_count),
@@ -1738,9 +1804,10 @@ class FunctionLiteral: public Expression {
class SharedFunctionInfoLiteral: public Expression {
public:
- explicit SharedFunctionInfoLiteral(
+ SharedFunctionInfoLiteral(
+ Isolate* isolate,
Handle<SharedFunctionInfo> shared_function_info)
- : shared_function_info_(shared_function_info) { }
+ : Expression(isolate), shared_function_info_(shared_function_info) { }
DECLARE_NODE_TYPE(SharedFunctionInfoLiteral)
@@ -1756,6 +1823,7 @@ class SharedFunctionInfoLiteral: public Expression {
class ThisFunction: public Expression {
public:
+ explicit ThisFunction(Isolate* isolate) : Expression(isolate) {}
DECLARE_NODE_TYPE(ThisFunction)
virtual bool IsInlineable() const;
};
« 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