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

Side by Side Diff: src/ast/ast.h

Issue 2205013002: Revert of Put Scopes into temporary Zone (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/ast/ast.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_AST_AST_H_ 5 #ifndef V8_AST_AST_H_
6 #define V8_AST_AST_H_ 6 #define V8_AST_AST_H_
7 7
8 #include "src/ast/ast-value-factory.h" 8 #include "src/ast/ast-value-factory.h"
9 #include "src/ast/modules.h" 9 #include "src/ast/modules.h"
10 #include "src/ast/variables.h" 10 #include "src/ast/variables.h"
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 void set_next_unresolved(VariableProxy* next) { next_unresolved_ = next; } 1683 void set_next_unresolved(VariableProxy* next) { next_unresolved_ = next; }
1684 VariableProxy* next_unresolved() { return next_unresolved_; } 1684 VariableProxy* next_unresolved() { return next_unresolved_; }
1685 1685
1686 protected: 1686 protected:
1687 VariableProxy(Zone* zone, Variable* var, int start_position, 1687 VariableProxy(Zone* zone, Variable* var, int start_position,
1688 int end_position); 1688 int end_position);
1689 1689
1690 VariableProxy(Zone* zone, const AstRawString* name, 1690 VariableProxy(Zone* zone, const AstRawString* name,
1691 Variable::Kind variable_kind, int start_position, 1691 Variable::Kind variable_kind, int start_position,
1692 int end_position); 1692 int end_position);
1693 VariableProxy(Zone* zone, const VariableProxy* copy_from);
1694 static int parent_num_ids() { return Expression::num_ids(); } 1693 static int parent_num_ids() { return Expression::num_ids(); }
1695 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1694 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1696 1695
1697 class IsThisField : public BitField8<bool, 0, 1> {}; 1696 class IsThisField : public BitField8<bool, 0, 1> {};
1698 class IsAssignedField : public BitField8<bool, 1, 1> {}; 1697 class IsAssignedField : public BitField8<bool, 1, 1> {};
1699 class IsResolvedField : public BitField8<bool, 2, 1> {}; 1698 class IsResolvedField : public BitField8<bool, 2, 1> {};
1700 class IsNewTargetField : public BitField8<bool, 3, 1> {}; 1699 class IsNewTargetField : public BitField8<bool, 3, 1> {};
1701 1700
1702 // Start with 16-bit (or smaller) field, which should get packed together 1701 // Start with 16-bit (or smaller) field, which should get packed together
1703 // with Expression's trailing 16-bit field. 1702 // with Expression's trailing 16-bit field.
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
3037 AST_REWRITE(Type, _list->at(_index), _list->Set(_index, replacement)); \ 3036 AST_REWRITE(Type, _list->at(_index), _list->Set(_index, replacement)); \
3038 } while (false) 3037 } while (false)
3039 3038
3040 3039
3041 // ---------------------------------------------------------------------------- 3040 // ----------------------------------------------------------------------------
3042 // AstNode factory 3041 // AstNode factory
3043 3042
3044 class AstNodeFactory final BASE_EMBEDDED { 3043 class AstNodeFactory final BASE_EMBEDDED {
3045 public: 3044 public:
3046 explicit AstNodeFactory(AstValueFactory* ast_value_factory) 3045 explicit AstNodeFactory(AstValueFactory* ast_value_factory)
3047 : zone_(nullptr), ast_value_factory_(ast_value_factory) { 3046 : local_zone_(nullptr),
3047 parser_zone_(nullptr),
3048 ast_value_factory_(ast_value_factory) {
3048 if (ast_value_factory != nullptr) { 3049 if (ast_value_factory != nullptr) {
3049 zone_ = ast_value_factory->zone(); 3050 local_zone_ = ast_value_factory->zone();
3051 parser_zone_ = ast_value_factory->zone();
3050 } 3052 }
3051 } 3053 }
3052 3054
3053 AstValueFactory* ast_value_factory() const { return ast_value_factory_; } 3055 AstValueFactory* ast_value_factory() const { return ast_value_factory_; }
3054 void set_ast_value_factory(AstValueFactory* ast_value_factory) { 3056 void set_ast_value_factory(AstValueFactory* ast_value_factory) {
3055 ast_value_factory_ = ast_value_factory; 3057 ast_value_factory_ = ast_value_factory;
3056 zone_ = ast_value_factory->zone(); 3058 local_zone_ = ast_value_factory->zone();
3059 parser_zone_ = ast_value_factory->zone();
3057 } 3060 }
3058 3061
3059 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, 3062 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy,
3060 VariableMode mode, Scope* scope, 3063 VariableMode mode, Scope* scope,
3061 int pos) { 3064 int pos) {
3062 return new (zone_) VariableDeclaration(zone_, proxy, mode, scope, pos); 3065 return new (parser_zone_)
3066 VariableDeclaration(parser_zone_, proxy, mode, scope, pos);
3063 } 3067 }
3064 3068
3065 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, 3069 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy,
3066 VariableMode mode, 3070 VariableMode mode,
3067 FunctionLiteral* fun, 3071 FunctionLiteral* fun,
3068 Scope* scope, 3072 Scope* scope,
3069 int pos) { 3073 int pos) {
3070 return new (zone_) FunctionDeclaration(zone_, proxy, mode, fun, scope, pos); 3074 return new (parser_zone_)
3075 FunctionDeclaration(parser_zone_, proxy, mode, fun, scope, pos);
3071 } 3076 }
3072 3077
3073 Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity, 3078 Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity,
3074 bool ignore_completion_value, int pos) { 3079 bool ignore_completion_value, int pos) {
3075 return new (zone_) 3080 return new (local_zone_)
3076 Block(zone_, labels, capacity, ignore_completion_value, pos); 3081 Block(local_zone_, labels, capacity, ignore_completion_value, pos);
3077 } 3082 }
3078 3083
3079 #define STATEMENT_WITH_LABELS(NodeType) \ 3084 #define STATEMENT_WITH_LABELS(NodeType) \
3080 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \ 3085 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \
3081 return new (zone_) NodeType(zone_, labels, pos); \ 3086 return new (local_zone_) NodeType(local_zone_, labels, pos); \
3082 } 3087 }
3083 STATEMENT_WITH_LABELS(DoWhileStatement) 3088 STATEMENT_WITH_LABELS(DoWhileStatement)
3084 STATEMENT_WITH_LABELS(WhileStatement) 3089 STATEMENT_WITH_LABELS(WhileStatement)
3085 STATEMENT_WITH_LABELS(ForStatement) 3090 STATEMENT_WITH_LABELS(ForStatement)
3086 STATEMENT_WITH_LABELS(SwitchStatement) 3091 STATEMENT_WITH_LABELS(SwitchStatement)
3087 #undef STATEMENT_WITH_LABELS 3092 #undef STATEMENT_WITH_LABELS
3088 3093
3089 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode, 3094 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode,
3090 ZoneList<const AstRawString*>* labels, 3095 ZoneList<const AstRawString*>* labels,
3091 int pos) { 3096 int pos) {
3092 switch (visit_mode) { 3097 switch (visit_mode) {
3093 case ForEachStatement::ENUMERATE: { 3098 case ForEachStatement::ENUMERATE: {
3094 return new (zone_) ForInStatement(zone_, labels, pos); 3099 return new (local_zone_) ForInStatement(local_zone_, labels, pos);
3095 } 3100 }
3096 case ForEachStatement::ITERATE: { 3101 case ForEachStatement::ITERATE: {
3097 return new (zone_) ForOfStatement(zone_, labels, pos); 3102 return new (local_zone_) ForOfStatement(local_zone_, labels, pos);
3098 } 3103 }
3099 } 3104 }
3100 UNREACHABLE(); 3105 UNREACHABLE();
3101 return NULL; 3106 return NULL;
3102 } 3107 }
3103 3108
3104 ExpressionStatement* NewExpressionStatement(Expression* expression, int pos) { 3109 ExpressionStatement* NewExpressionStatement(Expression* expression, int pos) {
3105 return new (zone_) ExpressionStatement(zone_, expression, pos); 3110 return new (local_zone_) ExpressionStatement(local_zone_, expression, pos);
3106 } 3111 }
3107 3112
3108 ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) { 3113 ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) {
3109 return new (zone_) ContinueStatement(zone_, target, pos); 3114 return new (local_zone_) ContinueStatement(local_zone_, target, pos);
3110 } 3115 }
3111 3116
3112 BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) { 3117 BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) {
3113 return new (zone_) BreakStatement(zone_, target, pos); 3118 return new (local_zone_) BreakStatement(local_zone_, target, pos);
3114 } 3119 }
3115 3120
3116 ReturnStatement* NewReturnStatement(Expression* expression, int pos) { 3121 ReturnStatement* NewReturnStatement(Expression* expression, int pos) {
3117 return new (zone_) ReturnStatement(zone_, expression, pos); 3122 return new (local_zone_) ReturnStatement(local_zone_, expression, pos);
3118 } 3123 }
3119 3124
3120 WithStatement* NewWithStatement(Scope* scope, 3125 WithStatement* NewWithStatement(Scope* scope,
3121 Expression* expression, 3126 Expression* expression,
3122 Statement* statement, 3127 Statement* statement,
3123 int pos) { 3128 int pos) {
3124 return new (zone_) WithStatement(zone_, scope, expression, statement, pos); 3129 return new (local_zone_)
3130 WithStatement(local_zone_, scope, expression, statement, pos);
3125 } 3131 }
3126 3132
3127 IfStatement* NewIfStatement(Expression* condition, 3133 IfStatement* NewIfStatement(Expression* condition,
3128 Statement* then_statement, 3134 Statement* then_statement,
3129 Statement* else_statement, 3135 Statement* else_statement,
3130 int pos) { 3136 int pos) {
3131 return new (zone_) 3137 return new (local_zone_) IfStatement(local_zone_, condition, then_statement,
3132 IfStatement(zone_, condition, then_statement, else_statement, pos); 3138 else_statement, pos);
3133 } 3139 }
3134 3140
3135 TryCatchStatement* NewTryCatchStatement(Block* try_block, Scope* scope, 3141 TryCatchStatement* NewTryCatchStatement(Block* try_block, Scope* scope,
3136 Variable* variable, 3142 Variable* variable,
3137 Block* catch_block, int pos) { 3143 Block* catch_block, int pos) {
3138 return new (zone_) 3144 return new (local_zone_)
3139 TryCatchStatement(zone_, try_block, scope, variable, catch_block, 3145 TryCatchStatement(local_zone_, try_block, scope, variable, catch_block,
3140 HandlerTable::CAUGHT, pos); 3146 HandlerTable::CAUGHT, pos);
3141 } 3147 }
3142 3148
3143 TryCatchStatement* NewTryCatchStatementForReThrow(Block* try_block, 3149 TryCatchStatement* NewTryCatchStatementForReThrow(Block* try_block,
3144 Scope* scope, 3150 Scope* scope,
3145 Variable* variable, 3151 Variable* variable,
3146 Block* catch_block, 3152 Block* catch_block,
3147 int pos) { 3153 int pos) {
3148 return new (zone_) 3154 return new (local_zone_)
3149 TryCatchStatement(zone_, try_block, scope, variable, catch_block, 3155 TryCatchStatement(local_zone_, try_block, scope, variable, catch_block,
3150 HandlerTable::UNCAUGHT, pos); 3156 HandlerTable::UNCAUGHT, pos);
3151 } 3157 }
3152 3158
3153 TryCatchStatement* NewTryCatchStatementForPromiseReject(Block* try_block, 3159 TryCatchStatement* NewTryCatchStatementForPromiseReject(Block* try_block,
3154 Scope* scope, 3160 Scope* scope,
3155 Variable* variable, 3161 Variable* variable,
3156 Block* catch_block, 3162 Block* catch_block,
3157 int pos) { 3163 int pos) {
3158 return new (zone_) 3164 return new (local_zone_)
3159 TryCatchStatement(zone_, try_block, scope, variable, catch_block, 3165 TryCatchStatement(local_zone_, try_block, scope, variable, catch_block,
3160 HandlerTable::PROMISE, pos); 3166 HandlerTable::PROMISE, pos);
3161 } 3167 }
3162 3168
3163 TryFinallyStatement* NewTryFinallyStatement(Block* try_block, 3169 TryFinallyStatement* NewTryFinallyStatement(Block* try_block,
3164 Block* finally_block, int pos) { 3170 Block* finally_block, int pos) {
3165 return new (zone_) 3171 return new (local_zone_)
3166 TryFinallyStatement(zone_, try_block, finally_block, pos); 3172 TryFinallyStatement(local_zone_, try_block, finally_block, pos);
3167 } 3173 }
3168 3174
3169 DebuggerStatement* NewDebuggerStatement(int pos) { 3175 DebuggerStatement* NewDebuggerStatement(int pos) {
3170 return new (zone_) DebuggerStatement(zone_, pos); 3176 return new (local_zone_) DebuggerStatement(local_zone_, pos);
3171 } 3177 }
3172 3178
3173 EmptyStatement* NewEmptyStatement(int pos) { 3179 EmptyStatement* NewEmptyStatement(int pos) {
3174 return new (zone_) EmptyStatement(zone_, pos); 3180 return new (local_zone_) EmptyStatement(local_zone_, pos);
3175 } 3181 }
3176 3182
3177 SloppyBlockFunctionStatement* NewSloppyBlockFunctionStatement( 3183 SloppyBlockFunctionStatement* NewSloppyBlockFunctionStatement(
3178 Statement* statement, Scope* scope) { 3184 Statement* statement, Scope* scope) {
3179 return new (zone_) SloppyBlockFunctionStatement(zone_, statement, scope); 3185 return new (parser_zone_)
3186 SloppyBlockFunctionStatement(parser_zone_, statement, scope);
3180 } 3187 }
3181 3188
3182 CaseClause* NewCaseClause( 3189 CaseClause* NewCaseClause(
3183 Expression* label, ZoneList<Statement*>* statements, int pos) { 3190 Expression* label, ZoneList<Statement*>* statements, int pos) {
3184 return new (zone_) CaseClause(zone_, label, statements, pos); 3191 return new (local_zone_) CaseClause(local_zone_, label, statements, pos);
3185 } 3192 }
3186 3193
3187 Literal* NewStringLiteral(const AstRawString* string, int pos) { 3194 Literal* NewStringLiteral(const AstRawString* string, int pos) {
3188 return new (zone_) 3195 return new (local_zone_)
3189 Literal(zone_, ast_value_factory_->NewString(string), pos); 3196 Literal(local_zone_, ast_value_factory_->NewString(string), pos);
3190 } 3197 }
3191 3198
3192 // A JavaScript symbol (ECMA-262 edition 6). 3199 // A JavaScript symbol (ECMA-262 edition 6).
3193 Literal* NewSymbolLiteral(const char* name, int pos) { 3200 Literal* NewSymbolLiteral(const char* name, int pos) {
3194 return new (zone_) Literal(zone_, ast_value_factory_->NewSymbol(name), pos); 3201 return new (local_zone_)
3202 Literal(local_zone_, ast_value_factory_->NewSymbol(name), pos);
3195 } 3203 }
3196 3204
3197 Literal* NewNumberLiteral(double number, int pos, bool with_dot = false) { 3205 Literal* NewNumberLiteral(double number, int pos, bool with_dot = false) {
3198 return new (zone_) 3206 return new (local_zone_) Literal(
3199 Literal(zone_, ast_value_factory_->NewNumber(number, with_dot), pos); 3207 local_zone_, ast_value_factory_->NewNumber(number, with_dot), pos);
3200 } 3208 }
3201 3209
3202 Literal* NewSmiLiteral(int number, int pos) { 3210 Literal* NewSmiLiteral(int number, int pos) {
3203 return new (zone_) Literal(zone_, ast_value_factory_->NewSmi(number), pos); 3211 return new (local_zone_)
3212 Literal(local_zone_, ast_value_factory_->NewSmi(number), pos);
3204 } 3213 }
3205 3214
3206 Literal* NewBooleanLiteral(bool b, int pos) { 3215 Literal* NewBooleanLiteral(bool b, int pos) {
3207 return new (zone_) Literal(zone_, ast_value_factory_->NewBoolean(b), pos); 3216 return new (local_zone_)
3217 Literal(local_zone_, ast_value_factory_->NewBoolean(b), pos);
3208 } 3218 }
3209 3219
3210 Literal* NewNullLiteral(int pos) { 3220 Literal* NewNullLiteral(int pos) {
3211 return new (zone_) Literal(zone_, ast_value_factory_->NewNull(), pos); 3221 return new (local_zone_)
3222 Literal(local_zone_, ast_value_factory_->NewNull(), pos);
3212 } 3223 }
3213 3224
3214 Literal* NewUndefinedLiteral(int pos) { 3225 Literal* NewUndefinedLiteral(int pos) {
3215 return new (zone_) Literal(zone_, ast_value_factory_->NewUndefined(), pos); 3226 return new (local_zone_)
3227 Literal(local_zone_, ast_value_factory_->NewUndefined(), pos);
3216 } 3228 }
3217 3229
3218 Literal* NewTheHoleLiteral(int pos) { 3230 Literal* NewTheHoleLiteral(int pos) {
3219 return new (zone_) Literal(zone_, ast_value_factory_->NewTheHole(), pos); 3231 return new (local_zone_)
3232 Literal(local_zone_, ast_value_factory_->NewTheHole(), pos);
3220 } 3233 }
3221 3234
3222 ObjectLiteral* NewObjectLiteral( 3235 ObjectLiteral* NewObjectLiteral(
3223 ZoneList<ObjectLiteral::Property*>* properties, int literal_index, 3236 ZoneList<ObjectLiteral::Property*>* properties, int literal_index,
3224 uint32_t boilerplate_properties, int pos) { 3237 uint32_t boilerplate_properties, int pos) {
3225 return new (zone_) ObjectLiteral(zone_, properties, literal_index, 3238 return new (local_zone_) ObjectLiteral(
3226 boilerplate_properties, pos); 3239 local_zone_, properties, literal_index, boilerplate_properties, pos);
3227 } 3240 }
3228 3241
3229 ObjectLiteral::Property* NewObjectLiteralProperty( 3242 ObjectLiteral::Property* NewObjectLiteralProperty(
3230 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind, 3243 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind,
3231 bool is_static, bool is_computed_name) { 3244 bool is_static, bool is_computed_name) {
3232 return new (zone_) 3245 return new (local_zone_)
3233 ObjectLiteral::Property(key, value, kind, is_static, is_computed_name); 3246 ObjectLiteral::Property(key, value, kind, is_static, is_computed_name);
3234 } 3247 }
3235 3248
3236 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key, 3249 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key,
3237 Expression* value, 3250 Expression* value,
3238 bool is_static, 3251 bool is_static,
3239 bool is_computed_name) { 3252 bool is_computed_name) {
3240 return new (zone_) ObjectLiteral::Property(ast_value_factory_, key, value, 3253 return new (local_zone_) ObjectLiteral::Property(
3241 is_static, is_computed_name); 3254 ast_value_factory_, key, value, is_static, is_computed_name);
3242 } 3255 }
3243 3256
3244 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, int flags, 3257 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, int flags,
3245 int literal_index, int pos) { 3258 int literal_index, int pos) {
3246 return new (zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos); 3259 return new (local_zone_)
3260 RegExpLiteral(local_zone_, pattern, flags, literal_index, pos);
3247 } 3261 }
3248 3262
3249 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, 3263 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values,
3250 int literal_index, 3264 int literal_index,
3251 int pos) { 3265 int pos) {
3252 return new (zone_) ArrayLiteral(zone_, values, -1, literal_index, pos); 3266 return new (local_zone_)
3267 ArrayLiteral(local_zone_, values, -1, literal_index, pos);
3253 } 3268 }
3254 3269
3255 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, 3270 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values,
3256 int first_spread_index, int literal_index, 3271 int first_spread_index, int literal_index,
3257 int pos) { 3272 int pos) {
3258 return new (zone_) 3273 return new (local_zone_) ArrayLiteral(
3259 ArrayLiteral(zone_, values, first_spread_index, literal_index, pos); 3274 local_zone_, values, first_spread_index, literal_index, pos);
3260 } 3275 }
3261 3276
3262 VariableProxy* NewVariableProxy(Variable* var, 3277 VariableProxy* NewVariableProxy(Variable* var,
3263 int start_position = kNoSourcePosition, 3278 int start_position = kNoSourcePosition,
3264 int end_position = kNoSourcePosition) { 3279 int end_position = kNoSourcePosition) {
3265 return new (zone_) VariableProxy(zone_, var, start_position, end_position); 3280 return new (parser_zone_)
3281 VariableProxy(parser_zone_, var, start_position, end_position);
3266 } 3282 }
3267 3283
3268 VariableProxy* NewVariableProxy(const AstRawString* name, 3284 VariableProxy* NewVariableProxy(const AstRawString* name,
3269 Variable::Kind variable_kind, 3285 Variable::Kind variable_kind,
3270 int start_position = kNoSourcePosition, 3286 int start_position = kNoSourcePosition,
3271 int end_position = kNoSourcePosition) { 3287 int end_position = kNoSourcePosition) {
3272 DCHECK_NOT_NULL(name); 3288 DCHECK_NOT_NULL(name);
3273 return new (zone_) 3289 return new (parser_zone_) VariableProxy(parser_zone_, name, variable_kind,
3274 VariableProxy(zone_, name, variable_kind, start_position, end_position); 3290 start_position, end_position);
3275 }
3276
3277 // Recreates the VariableProxy in this Zone.
3278 VariableProxy* CopyVariableProxy(VariableProxy* proxy) {
3279 return new (zone_) VariableProxy(zone_, proxy);
3280 } 3291 }
3281 3292
3282 Property* NewProperty(Expression* obj, Expression* key, int pos) { 3293 Property* NewProperty(Expression* obj, Expression* key, int pos) {
3283 return new (zone_) Property(zone_, obj, key, pos); 3294 return new (local_zone_) Property(local_zone_, obj, key, pos);
3284 } 3295 }
3285 3296
3286 Call* NewCall(Expression* expression, 3297 Call* NewCall(Expression* expression,
3287 ZoneList<Expression*>* arguments, 3298 ZoneList<Expression*>* arguments,
3288 int pos) { 3299 int pos) {
3289 return new (zone_) Call(zone_, expression, arguments, pos); 3300 return new (local_zone_) Call(local_zone_, expression, arguments, pos);
3290 } 3301 }
3291 3302
3292 CallNew* NewCallNew(Expression* expression, 3303 CallNew* NewCallNew(Expression* expression,
3293 ZoneList<Expression*>* arguments, 3304 ZoneList<Expression*>* arguments,
3294 int pos) { 3305 int pos) {
3295 return new (zone_) CallNew(zone_, expression, arguments, pos); 3306 return new (local_zone_) CallNew(local_zone_, expression, arguments, pos);
3296 } 3307 }
3297 3308
3298 CallRuntime* NewCallRuntime(Runtime::FunctionId id, 3309 CallRuntime* NewCallRuntime(Runtime::FunctionId id,
3299 ZoneList<Expression*>* arguments, int pos) { 3310 ZoneList<Expression*>* arguments, int pos) {
3300 return new (zone_) 3311 return new (local_zone_)
3301 CallRuntime(zone_, Runtime::FunctionForId(id), arguments, pos); 3312 CallRuntime(local_zone_, Runtime::FunctionForId(id), arguments, pos);
3302 } 3313 }
3303 3314
3304 CallRuntime* NewCallRuntime(const Runtime::Function* function, 3315 CallRuntime* NewCallRuntime(const Runtime::Function* function,
3305 ZoneList<Expression*>* arguments, int pos) { 3316 ZoneList<Expression*>* arguments, int pos) {
3306 return new (zone_) CallRuntime(zone_, function, arguments, pos); 3317 return new (local_zone_) CallRuntime(local_zone_, function, arguments, pos);
3307 } 3318 }
3308 3319
3309 CallRuntime* NewCallRuntime(int context_index, 3320 CallRuntime* NewCallRuntime(int context_index,
3310 ZoneList<Expression*>* arguments, int pos) { 3321 ZoneList<Expression*>* arguments, int pos) {
3311 return new (zone_) CallRuntime(zone_, context_index, arguments, pos); 3322 return new (local_zone_)
3323 CallRuntime(local_zone_, context_index, arguments, pos);
3312 } 3324 }
3313 3325
3314 UnaryOperation* NewUnaryOperation(Token::Value op, 3326 UnaryOperation* NewUnaryOperation(Token::Value op,
3315 Expression* expression, 3327 Expression* expression,
3316 int pos) { 3328 int pos) {
3317 return new (zone_) UnaryOperation(zone_, op, expression, pos); 3329 return new (local_zone_) UnaryOperation(local_zone_, op, expression, pos);
3318 } 3330 }
3319 3331
3320 BinaryOperation* NewBinaryOperation(Token::Value op, 3332 BinaryOperation* NewBinaryOperation(Token::Value op,
3321 Expression* left, 3333 Expression* left,
3322 Expression* right, 3334 Expression* right,
3323 int pos) { 3335 int pos) {
3324 return new (zone_) BinaryOperation(zone_, op, left, right, pos); 3336 return new (local_zone_) BinaryOperation(local_zone_, op, left, right, pos);
3325 } 3337 }
3326 3338
3327 CountOperation* NewCountOperation(Token::Value op, 3339 CountOperation* NewCountOperation(Token::Value op,
3328 bool is_prefix, 3340 bool is_prefix,
3329 Expression* expr, 3341 Expression* expr,
3330 int pos) { 3342 int pos) {
3331 return new (zone_) CountOperation(zone_, op, is_prefix, expr, pos); 3343 return new (local_zone_)
3344 CountOperation(local_zone_, op, is_prefix, expr, pos);
3332 } 3345 }
3333 3346
3334 CompareOperation* NewCompareOperation(Token::Value op, 3347 CompareOperation* NewCompareOperation(Token::Value op,
3335 Expression* left, 3348 Expression* left,
3336 Expression* right, 3349 Expression* right,
3337 int pos) { 3350 int pos) {
3338 return new (zone_) CompareOperation(zone_, op, left, right, pos); 3351 return new (local_zone_)
3352 CompareOperation(local_zone_, op, left, right, pos);
3339 } 3353 }
3340 3354
3341 Spread* NewSpread(Expression* expression, int pos, int expr_pos) { 3355 Spread* NewSpread(Expression* expression, int pos, int expr_pos) {
3342 return new (zone_) Spread(zone_, expression, pos, expr_pos); 3356 return new (local_zone_) Spread(local_zone_, expression, pos, expr_pos);
3343 } 3357 }
3344 3358
3345 Conditional* NewConditional(Expression* condition, 3359 Conditional* NewConditional(Expression* condition,
3346 Expression* then_expression, 3360 Expression* then_expression,
3347 Expression* else_expression, 3361 Expression* else_expression,
3348 int position) { 3362 int position) {
3349 return new (zone_) Conditional(zone_, condition, then_expression, 3363 return new (local_zone_) Conditional(
3350 else_expression, position); 3364 local_zone_, condition, then_expression, else_expression, position);
3351 } 3365 }
3352 3366
3353 RewritableExpression* NewRewritableExpression(Expression* expression) { 3367 RewritableExpression* NewRewritableExpression(Expression* expression) {
3354 DCHECK_NOT_NULL(expression); 3368 DCHECK_NOT_NULL(expression);
3355 return new (zone_) RewritableExpression(zone_, expression); 3369 return new (local_zone_) RewritableExpression(local_zone_, expression);
3356 } 3370 }
3357 3371
3358 Assignment* NewAssignment(Token::Value op, 3372 Assignment* NewAssignment(Token::Value op,
3359 Expression* target, 3373 Expression* target,
3360 Expression* value, 3374 Expression* value,
3361 int pos) { 3375 int pos) {
3362 DCHECK(Token::IsAssignmentOp(op)); 3376 DCHECK(Token::IsAssignmentOp(op));
3363 Assignment* assign = new (zone_) Assignment(zone_, op, target, value, pos); 3377 Assignment* assign =
3378 new (local_zone_) Assignment(local_zone_, op, target, value, pos);
3364 if (assign->is_compound()) { 3379 if (assign->is_compound()) {
3365 DCHECK(Token::IsAssignmentOp(op)); 3380 DCHECK(Token::IsAssignmentOp(op));
3366 assign->binary_operation_ = 3381 assign->binary_operation_ =
3367 NewBinaryOperation(assign->binary_op(), target, value, pos + 1); 3382 NewBinaryOperation(assign->binary_op(), target, value, pos + 1);
3368 } 3383 }
3369 return assign; 3384 return assign;
3370 } 3385 }
3371 3386
3372 Yield* NewYield(Expression* generator_object, Expression* expression, int pos, 3387 Yield* NewYield(Expression* generator_object, Expression* expression, int pos,
3373 Yield::OnException on_exception) { 3388 Yield::OnException on_exception) {
3374 if (!expression) expression = NewUndefinedLiteral(pos); 3389 if (!expression) expression = NewUndefinedLiteral(pos);
3375 return new (zone_) 3390 return new (local_zone_)
3376 Yield(zone_, generator_object, expression, pos, on_exception); 3391 Yield(local_zone_, generator_object, expression, pos, on_exception);
3377 } 3392 }
3378 3393
3379 Throw* NewThrow(Expression* exception, int pos) { 3394 Throw* NewThrow(Expression* exception, int pos) {
3380 return new (zone_) Throw(zone_, exception, pos); 3395 return new (local_zone_) Throw(local_zone_, exception, pos);
3381 } 3396 }
3382 3397
3383 FunctionLiteral* NewFunctionLiteral( 3398 FunctionLiteral* NewFunctionLiteral(
3384 const AstRawString* name, Scope* scope, ZoneList<Statement*>* body, 3399 const AstRawString* name, Scope* scope, ZoneList<Statement*>* body,
3385 int materialized_literal_count, int expected_property_count, 3400 int materialized_literal_count, int expected_property_count,
3386 int parameter_count, 3401 int parameter_count,
3387 FunctionLiteral::ParameterFlag has_duplicate_parameters, 3402 FunctionLiteral::ParameterFlag has_duplicate_parameters,
3388 FunctionLiteral::FunctionType function_type, 3403 FunctionLiteral::FunctionType function_type,
3389 FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind, 3404 FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind,
3390 int position) { 3405 int position) {
3391 return new (zone_) FunctionLiteral( 3406 return new (local_zone_) FunctionLiteral(
3392 zone_, name, ast_value_factory_, scope, body, 3407 local_zone_, name, ast_value_factory_, scope, body,
3393 materialized_literal_count, expected_property_count, parameter_count, 3408 materialized_literal_count, expected_property_count, parameter_count,
3394 function_type, has_duplicate_parameters, eager_compile_hint, kind, 3409 function_type, has_duplicate_parameters, eager_compile_hint, kind,
3395 position, true); 3410 position, true);
3396 } 3411 }
3397 3412
3398 // Creates a FunctionLiteral representing a top-level script, the 3413 // Creates a FunctionLiteral representing a top-level script, the
3399 // result of an eval (top-level or otherwise), or the result of calling 3414 // result of an eval (top-level or otherwise), or the result of calling
3400 // the Function constructor. 3415 // the Function constructor.
3401 FunctionLiteral* NewScriptOrEvalFunctionLiteral( 3416 FunctionLiteral* NewScriptOrEvalFunctionLiteral(
3402 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count, 3417 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count,
3403 int expected_property_count) { 3418 int expected_property_count) {
3404 return new (zone_) FunctionLiteral( 3419 return new (local_zone_) FunctionLiteral(
3405 zone_, ast_value_factory_->empty_string(), ast_value_factory_, scope, 3420 local_zone_, ast_value_factory_->empty_string(), ast_value_factory_,
3406 body, materialized_literal_count, expected_property_count, 0, 3421 scope, body, materialized_literal_count, expected_property_count, 0,
3407 FunctionLiteral::kAnonymousExpression, 3422 FunctionLiteral::kAnonymousExpression,
3408 FunctionLiteral::kNoDuplicateParameters, 3423 FunctionLiteral::kNoDuplicateParameters,
3409 FunctionLiteral::kShouldLazyCompile, FunctionKind::kNormalFunction, 0, 3424 FunctionLiteral::kShouldLazyCompile, FunctionKind::kNormalFunction, 0,
3410 false); 3425 false);
3411 } 3426 }
3412 3427
3413 ClassLiteral* NewClassLiteral(VariableProxy* proxy, Expression* extends, 3428 ClassLiteral* NewClassLiteral(VariableProxy* proxy, Expression* extends,
3414 FunctionLiteral* constructor, 3429 FunctionLiteral* constructor,
3415 ZoneList<ObjectLiteral::Property*>* properties, 3430 ZoneList<ObjectLiteral::Property*>* properties,
3416 int start_position, int end_position) { 3431 int start_position, int end_position) {
3417 return new (zone_) ClassLiteral(zone_, proxy, extends, constructor, 3432 return new (local_zone_)
3418 properties, start_position, end_position); 3433 ClassLiteral(local_zone_, proxy, extends, constructor, properties,
3434 start_position, end_position);
3419 } 3435 }
3420 3436
3421 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, 3437 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name,
3422 v8::Extension* extension, 3438 v8::Extension* extension,
3423 int pos) { 3439 int pos) {
3424 return new (zone_) NativeFunctionLiteral(zone_, name, extension, pos); 3440 return new (local_zone_)
3441 NativeFunctionLiteral(local_zone_, name, extension, pos);
3425 } 3442 }
3426 3443
3427 DoExpression* NewDoExpression(Block* block, Variable* result_var, int pos) { 3444 DoExpression* NewDoExpression(Block* block, Variable* result_var, int pos) {
3428 VariableProxy* result = NewVariableProxy(result_var, pos); 3445 VariableProxy* result = NewVariableProxy(result_var, pos);
3429 return new (zone_) DoExpression(zone_, block, result, pos); 3446 return new (local_zone_) DoExpression(local_zone_, block, result, pos);
3430 } 3447 }
3431 3448
3432 ThisFunction* NewThisFunction(int pos) { 3449 ThisFunction* NewThisFunction(int pos) {
3433 return new (zone_) ThisFunction(zone_, pos); 3450 return new (local_zone_) ThisFunction(local_zone_, pos);
3434 } 3451 }
3435 3452
3436 SuperPropertyReference* NewSuperPropertyReference(VariableProxy* this_var, 3453 SuperPropertyReference* NewSuperPropertyReference(VariableProxy* this_var,
3437 Expression* home_object, 3454 Expression* home_object,
3438 int pos) { 3455 int pos) {
3439 return new (zone_) 3456 return new (local_zone_)
3440 SuperPropertyReference(zone_, this_var, home_object, pos); 3457 SuperPropertyReference(local_zone_, this_var, home_object, pos);
3441 } 3458 }
3442 3459
3443 SuperCallReference* NewSuperCallReference(VariableProxy* this_var, 3460 SuperCallReference* NewSuperCallReference(VariableProxy* this_var,
3444 VariableProxy* new_target_var, 3461 VariableProxy* new_target_var,
3445 VariableProxy* this_function_var, 3462 VariableProxy* this_function_var,
3446 int pos) { 3463 int pos) {
3447 return new (zone_) SuperCallReference(zone_, this_var, new_target_var, 3464 return new (local_zone_) SuperCallReference(
3448 this_function_var, pos); 3465 local_zone_, this_var, new_target_var, this_function_var, pos);
3449 } 3466 }
3450 3467
3451 EmptyParentheses* NewEmptyParentheses(int pos) { 3468 EmptyParentheses* NewEmptyParentheses(int pos) {
3452 return new (zone_) EmptyParentheses(zone_, pos); 3469 return new (local_zone_) EmptyParentheses(local_zone_, pos);
3453 } 3470 }
3454 3471
3455 Zone* zone() const { return zone_; } 3472 Zone* zone() const { return local_zone_; }
3456 void set_zone(Zone* zone) { zone_ = zone; }
3457 3473
3458 // Handles use of temporary zones when parsing inner function bodies. 3474 // Handles use of temporary zones when parsing inner function bodies.
3459 class BodyScope { 3475 class BodyScope {
3460 public: 3476 public:
3461 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone) 3477 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone)
3462 : factory_(factory), prev_zone_(factory->zone_) { 3478 : factory_(factory), prev_zone_(factory->local_zone_) {
3463 if (use_temp_zone) { 3479 if (use_temp_zone) {
3464 factory->zone_ = temp_zone; 3480 factory->local_zone_ = temp_zone;
3465 } 3481 }
3466 } 3482 }
3467 3483
3468 ~BodyScope() { factory_->zone_ = prev_zone_; } 3484 ~BodyScope() { factory_->local_zone_ = prev_zone_; }
3469 3485
3470 private: 3486 private:
3471 AstNodeFactory* factory_; 3487 AstNodeFactory* factory_;
3472 Zone* prev_zone_; 3488 Zone* prev_zone_;
3473 }; 3489 };
3474 3490
3475 private: 3491 private:
3476 // This zone may be deallocated upon returning from parsing a function body 3492 // This zone may be deallocated upon returning from parsing a function body
3477 // which we can guarantee is not going to be compiled or have its AST 3493 // which we can guarantee is not going to be compiled or have its AST
3478 // inspected. 3494 // inspected.
3479 // See ParseFunctionLiteral in parser.cc for preconditions. 3495 // See ParseFunctionLiteral in parser.cc for preconditions.
3480 Zone* zone_; 3496 Zone* local_zone_;
3497 // ZoneObjects which need to persist until scope analysis must be allocated in
3498 // the parser-level zone.
3499 Zone* parser_zone_;
3481 AstValueFactory* ast_value_factory_; 3500 AstValueFactory* ast_value_factory_;
3482 }; 3501 };
3483 3502
3484 3503
3485 // Type testing & conversion functions overridden by concrete subclasses. 3504 // Type testing & conversion functions overridden by concrete subclasses.
3486 // Inline functions for AstNode. 3505 // Inline functions for AstNode.
3487 3506
3488 #define DECLARE_NODE_FUNCTIONS(type) \ 3507 #define DECLARE_NODE_FUNCTIONS(type) \
3489 bool AstNode::Is##type() const { \ 3508 bool AstNode::Is##type() const { \
3490 NodeType mine = node_type(); \ 3509 NodeType mine = node_type(); \
(...skipping 28 matching lines...) Expand all
3519 : NULL; \ 3538 : NULL; \
3520 } 3539 }
3521 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3540 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3522 #undef DECLARE_NODE_FUNCTIONS 3541 #undef DECLARE_NODE_FUNCTIONS
3523 3542
3524 3543
3525 } // namespace internal 3544 } // namespace internal
3526 } // namespace v8 3545 } // namespace v8
3527 3546
3528 #endif // V8_AST_AST_H_ 3547 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698