Chromium Code Reviews

Side by Side Diff: src/ast.h

Issue 1304923004: When parsing inner functions, try to allocate in a temporary Zone (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Disable temp allocation of the FunctionExpression object until I can work out FunctionNameInferrer Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « no previous file | src/parser.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_H_ 5 #ifndef V8_AST_H_
6 #define V8_AST_H_ 6 #define V8_AST_H_
7 7
8 #include "src/assembler.h" 8 #include "src/assembler.h"
9 #include "src/ast-value-factory.h" 9 #include "src/ast-value-factory.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 3259 matching lines...)
3270 Zone* zone_; \ 3270 Zone* zone_; \
3271 bool stack_overflow_ 3271 bool stack_overflow_
3272 3272
3273 3273
3274 // ---------------------------------------------------------------------------- 3274 // ----------------------------------------------------------------------------
3275 // AstNode factory 3275 // AstNode factory
3276 3276
3277 class AstNodeFactory final BASE_EMBEDDED { 3277 class AstNodeFactory final BASE_EMBEDDED {
3278 public: 3278 public:
3279 explicit AstNodeFactory(AstValueFactory* ast_value_factory) 3279 explicit AstNodeFactory(AstValueFactory* ast_value_factory)
3280 : zone_(ast_value_factory->zone()), 3280 : zone_(ast_value_factory->zone()),
titzer 2015/09/09 19:48:16 Can we rename this zone to be clearer as well?
conradw 2015/09/10 11:17:28 Done.
3281 parser_zone_(ast_value_factory->zone()),
3281 ast_value_factory_(ast_value_factory) {} 3282 ast_value_factory_(ast_value_factory) {}
3282 3283
3283 VariableDeclaration* NewVariableDeclaration( 3284 VariableDeclaration* NewVariableDeclaration(
3284 VariableProxy* proxy, VariableMode mode, Scope* scope, int pos, 3285 VariableProxy* proxy, VariableMode mode, Scope* scope, int pos,
3285 bool is_class_declaration = false, int declaration_group_start = -1) { 3286 bool is_class_declaration = false, int declaration_group_start = -1) {
3286 return new (zone_) 3287 return new (parser_zone_)
3287 VariableDeclaration(zone_, proxy, mode, scope, pos, 3288 VariableDeclaration(parser_zone_, proxy, mode, scope, pos,
3288 is_class_declaration, declaration_group_start); 3289 is_class_declaration, declaration_group_start);
3289 } 3290 }
3290 3291
3291 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, 3292 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy,
3292 VariableMode mode, 3293 VariableMode mode,
3293 FunctionLiteral* fun, 3294 FunctionLiteral* fun,
3294 Scope* scope, 3295 Scope* scope,
3295 int pos) { 3296 int pos) {
3296 return new (zone_) FunctionDeclaration(zone_, proxy, mode, fun, scope, pos); 3297 return new (parser_zone_)
3298 FunctionDeclaration(parser_zone_, proxy, mode, fun, scope, pos);
3297 } 3299 }
3298 3300
3299 ImportDeclaration* NewImportDeclaration(VariableProxy* proxy, 3301 ImportDeclaration* NewImportDeclaration(VariableProxy* proxy,
3300 const AstRawString* import_name, 3302 const AstRawString* import_name,
3301 const AstRawString* module_specifier, 3303 const AstRawString* module_specifier,
3302 Scope* scope, int pos) { 3304 Scope* scope, int pos) {
3303 return new (zone_) ImportDeclaration(zone_, proxy, import_name, 3305 return new (parser_zone_) ImportDeclaration(
3304 module_specifier, scope, pos); 3306 parser_zone_, proxy, import_name, module_specifier, scope, pos);
3305 } 3307 }
3306 3308
3307 ExportDeclaration* NewExportDeclaration(VariableProxy* proxy, 3309 ExportDeclaration* NewExportDeclaration(VariableProxy* proxy,
3308 Scope* scope, 3310 Scope* scope,
3309 int pos) { 3311 int pos) {
3310 return new (zone_) ExportDeclaration(zone_, proxy, scope, pos); 3312 return new (parser_zone_)
3313 ExportDeclaration(parser_zone_, proxy, scope, pos);
3311 } 3314 }
3312 3315
3313 Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity, 3316 Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity,
3314 bool ignore_completion_value, int pos) { 3317 bool ignore_completion_value, int pos) {
3315 return new (zone_) 3318 return new (zone_)
3316 Block(zone_, labels, capacity, ignore_completion_value, pos); 3319 Block(zone_, labels, capacity, ignore_completion_value, pos);
3317 } 3320 }
3318 3321
3319 #define STATEMENT_WITH_LABELS(NodeType) \ 3322 #define STATEMENT_WITH_LABELS(NodeType) \
3320 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \ 3323 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \
(...skipping 137 matching lines...)
3458 bool is_computed_name) { 3461 bool is_computed_name) {
3459 return new (zone_) ObjectLiteral::Property(ast_value_factory_, key, value, 3462 return new (zone_) ObjectLiteral::Property(ast_value_factory_, key, value,
3460 is_static, is_computed_name); 3463 is_static, is_computed_name);
3461 } 3464 }
3462 3465
3463 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, 3466 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern,
3464 const AstRawString* flags, 3467 const AstRawString* flags,
3465 int literal_index, 3468 int literal_index,
3466 bool is_strong, 3469 bool is_strong,
3467 int pos) { 3470 int pos) {
3468 return new (zone_) RegExpLiteral(zone_, pattern, flags, literal_index, 3471 return new (zone_)
3469 is_strong, pos); 3472 RegExpLiteral(zone_, pattern, flags, literal_index, is_strong, pos);
3470 } 3473 }
3471 3474
3472 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, 3475 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values,
3473 int literal_index, 3476 int literal_index,
3474 bool is_strong, 3477 bool is_strong,
3475 int pos) { 3478 int pos) {
3476 return new (zone_) 3479 return new (zone_)
3477 ArrayLiteral(zone_, values, -1, literal_index, is_strong, pos); 3480 ArrayLiteral(zone_, values, -1, literal_index, is_strong, pos);
3478 } 3481 }
3479 3482
3480 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, 3483 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values,
3481 int first_spread_index, int literal_index, 3484 int first_spread_index, int literal_index,
3482 bool is_strong, int pos) { 3485 bool is_strong, int pos) {
3483 return new (zone_) ArrayLiteral(zone_, values, first_spread_index, 3486 return new (zone_) ArrayLiteral(zone_, values, first_spread_index,
3484 literal_index, is_strong, pos); 3487 literal_index, is_strong, pos);
3485 } 3488 }
3486 3489
3487 VariableProxy* NewVariableProxy(Variable* var, 3490 VariableProxy* NewVariableProxy(Variable* var,
3488 int start_position = RelocInfo::kNoPosition, 3491 int start_position = RelocInfo::kNoPosition,
3489 int end_position = RelocInfo::kNoPosition) { 3492 int end_position = RelocInfo::kNoPosition) {
3490 return new (zone_) VariableProxy(zone_, var, start_position, end_position); 3493 return new (parser_zone_)
3494 VariableProxy(parser_zone_, var, start_position, end_position);
3491 } 3495 }
3492 3496
3493 VariableProxy* NewVariableProxy(const AstRawString* name, 3497 VariableProxy* NewVariableProxy(const AstRawString* name,
3494 Variable::Kind variable_kind, 3498 Variable::Kind variable_kind,
3495 int start_position = RelocInfo::kNoPosition, 3499 int start_position = RelocInfo::kNoPosition,
3496 int end_position = RelocInfo::kNoPosition) { 3500 int end_position = RelocInfo::kNoPosition) {
3497 DCHECK_NOT_NULL(name); 3501 DCHECK_NOT_NULL(name);
3498 return new (zone_) 3502 return new (parser_zone_) VariableProxy(parser_zone_, name, variable_kind,
3499 VariableProxy(zone_, name, variable_kind, start_position, end_position); 3503 start_position, end_position);
3500 } 3504 }
3501 3505
3502 Property* NewProperty(Expression* obj, Expression* key, int pos) { 3506 Property* NewProperty(Expression* obj, Expression* key, int pos) {
3503 return new (zone_) Property(zone_, obj, key, pos); 3507 return new (zone_) Property(zone_, obj, key, pos);
3504 } 3508 }
3505 3509
3506 Call* NewCall(Expression* expression, 3510 Call* NewCall(Expression* expression,
3507 ZoneList<Expression*>* arguments, 3511 ZoneList<Expression*>* arguments,
3508 int pos) { 3512 int pos) {
3509 return new (zone_) Call(zone_, expression, arguments, pos); 3513 return new (zone_) Call(zone_, expression, arguments, pos);
(...skipping 89 matching lines...)
3599 3603
3600 FunctionLiteral* NewFunctionLiteral( 3604 FunctionLiteral* NewFunctionLiteral(
3601 const AstRawString* name, AstValueFactory* ast_value_factory, 3605 const AstRawString* name, AstValueFactory* ast_value_factory,
3602 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count, 3606 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count,
3603 int expected_property_count, int parameter_count, 3607 int expected_property_count, int parameter_count,
3604 FunctionLiteral::ParameterFlag has_duplicate_parameters, 3608 FunctionLiteral::ParameterFlag has_duplicate_parameters,
3605 FunctionLiteral::FunctionType function_type, 3609 FunctionLiteral::FunctionType function_type,
3606 FunctionLiteral::IsFunctionFlag is_function, 3610 FunctionLiteral::IsFunctionFlag is_function,
3607 FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind, 3611 FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind,
3608 int position) { 3612 int position) {
3609 return new (zone_) FunctionLiteral( 3613 return new (parser_zone_) FunctionLiteral(
3610 zone_, name, ast_value_factory, scope, body, materialized_literal_count, 3614 parser_zone_, name, ast_value_factory, scope, body,
3611 expected_property_count, parameter_count, function_type, 3615 materialized_literal_count, expected_property_count, parameter_count,
3612 has_duplicate_parameters, is_function, eager_compile_hint, kind, 3616 function_type, has_duplicate_parameters, is_function,
3613 position); 3617 eager_compile_hint, kind, position);
3614 } 3618 }
3615 3619
3616 ClassLiteral* NewClassLiteral(const AstRawString* name, Scope* scope, 3620 ClassLiteral* NewClassLiteral(const AstRawString* name, Scope* scope,
3617 VariableProxy* proxy, Expression* extends, 3621 VariableProxy* proxy, Expression* extends,
3618 FunctionLiteral* constructor, 3622 FunctionLiteral* constructor,
3619 ZoneList<ObjectLiteral::Property*>* properties, 3623 ZoneList<ObjectLiteral::Property*>* properties,
3620 int start_position, int end_position) { 3624 int start_position, int end_position) {
3621 return new (zone_) 3625 return new (parser_zone_)
3622 ClassLiteral(zone_, name, scope, proxy, extends, constructor, 3626 ClassLiteral(parser_zone_, name, scope, proxy, extends, constructor,
3623 properties, start_position, end_position); 3627 properties, start_position, end_position);
3624 } 3628 }
3625 3629
3626 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, 3630 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name,
3627 v8::Extension* extension, 3631 v8::Extension* extension,
3628 int pos) { 3632 int pos) {
3629 return new (zone_) NativeFunctionLiteral(zone_, name, extension, pos); 3633 return new (parser_zone_)
3634 NativeFunctionLiteral(parser_zone_, name, extension, pos);
3630 } 3635 }
3631 3636
3632 ThisFunction* NewThisFunction(int pos) { 3637 ThisFunction* NewThisFunction(int pos) {
3633 return new (zone_) ThisFunction(zone_, pos); 3638 return new (zone_) ThisFunction(zone_, pos);
3634 } 3639 }
3635 3640
3636 SuperPropertyReference* NewSuperPropertyReference(VariableProxy* this_var, 3641 SuperPropertyReference* NewSuperPropertyReference(VariableProxy* this_var,
3637 Expression* home_object, 3642 Expression* home_object,
3638 int pos) { 3643 int pos) {
3639 return new (zone_) 3644 return new (parser_zone_)
3640 SuperPropertyReference(zone_, this_var, home_object, pos); 3645 SuperPropertyReference(parser_zone_, this_var, home_object, pos);
3641 } 3646 }
3642 3647
3643 SuperCallReference* NewSuperCallReference(VariableProxy* this_var, 3648 SuperCallReference* NewSuperCallReference(VariableProxy* this_var,
3644 VariableProxy* new_target_var, 3649 VariableProxy* new_target_var,
3645 VariableProxy* this_function_var, 3650 VariableProxy* this_function_var,
3646 int pos) { 3651 int pos) {
3647 return new (zone_) SuperCallReference(zone_, this_var, new_target_var, 3652 return new (parser_zone_) SuperCallReference(
3648 this_function_var, pos); 3653 parser_zone_, this_var, new_target_var, this_function_var, pos);
3649 } 3654 }
3650 3655
3651 EmptyParentheses* NewEmptyParentheses(int pos) { 3656 EmptyParentheses* NewEmptyParentheses(int pos) {
3652 return new (zone_) EmptyParentheses(zone_, pos); 3657 return new (zone_) EmptyParentheses(zone_, pos);
3653 } 3658 }
3654 3659
3660 Zone* zone() const { return zone_; }
3661
3662 void set_zone(Zone* temp_zone) { zone_ = temp_zone; }
3663
3655 private: 3664 private:
3656 Zone* zone_; 3665 Zone* zone_;
3666 // HeapObjects which need to persist until scope analysis must be allocated in
3667 // the parser-level zone.
3668 Zone* parser_zone_;
3657 AstValueFactory* ast_value_factory_; 3669 AstValueFactory* ast_value_factory_;
3658 }; 3670 };
3659 3671
3660 3672
3661 } } // namespace v8::internal 3673 } } // namespace v8::internal
3662 3674
3663 #endif // V8_AST_H_ 3675 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine