diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-07-21 22:20:37 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-07-21 22:20:37 -0700 |
commit | f319e126218dcaafdb0ccf7e968ff839f8327bba (patch) | |
tree | 209546d94cdc6c19f69ef92e3ec057301369f416 /deps/v8/src/ast.h | |
parent | ef1be160d66b7da8bc2da857b1c33c6f680d86f1 (diff) | |
download | node-new-f319e126218dcaafdb0ccf7e968ff839f8327bba.tar.gz |
Upgrade V8 to 3.4.14
Diffstat (limited to 'deps/v8/src/ast.h')
-rw-r--r-- | deps/v8/src/ast.h | 213 |
1 files changed, 145 insertions, 68 deletions
diff --git a/deps/v8/src/ast.h b/deps/v8/src/ast.h index 27d82cb341..23df48b8b1 100644 --- a/deps/v8/src/ast.h +++ b/deps/v8/src/ast.h @@ -134,11 +134,15 @@ class AstNode: public ZoneObject { static const int kNoNumber = -1; static const int kFunctionEntryId = 2; // Using 0 could disguise errors. - AstNode() { - Isolate* isolate = Isolate::Current(); + // Override ZoneObject's new to count allocated AST nodes. + void* operator new(size_t size, Zone* zone) { + Isolate* isolate = zone->isolate(); isolate->set_ast_node_count(isolate->ast_node_count() + 1); + return zone->New(static_cast<int>(size)); } + AstNode() {} + virtual ~AstNode() { } virtual void Accept(AstVisitor* v) = 0; @@ -165,14 +169,21 @@ 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; } + private: + // Hidden to prevent accidental usage. It would have to load the + // current zone from the TLS. + void* operator new(size_t size); + friend class CaseClause; // Generates AST IDs. }; @@ -210,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(); @@ -277,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; @@ -308,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_; @@ -321,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) @@ -389,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; @@ -404,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) @@ -437,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) @@ -470,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) @@ -519,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) @@ -636,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 { @@ -671,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) @@ -697,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) @@ -834,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) @@ -887,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; } @@ -944,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), @@ -990,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) {} @@ -1011,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) @@ -1038,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) @@ -1085,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; }; @@ -1100,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; }; @@ -1130,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); } @@ -1162,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), @@ -1215,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) @@ -1301,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) @@ -1325,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) @@ -1348,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)); } @@ -1372,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; } @@ -1410,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) @@ -1462,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)); } @@ -1501,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) @@ -1520,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) @@ -1561,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) @@ -1621,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) @@ -1638,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, @@ -1650,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), @@ -1729,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) @@ -1747,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; }; |