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

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

Issue 2481163002: Assign unique IDs to FunctionLiterals (Closed)
Patch Set: updates Created 4 years, 1 month 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/compiler.cc » ('j') | src/factory.cc » ('J')
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-types.h" 8 #include "src/ast/ast-types.h"
9 #include "src/ast/ast-value-factory.h" 9 #include "src/ast/ast-value-factory.h"
10 #include "src/ast/modules.h" 10 #include "src/ast/modules.h"
(...skipping 2693 matching lines...) Expand 10 before | Expand all | Expand 10 after
2704 } 2704 }
2705 void set_is_class_field_initializer(bool is_class_field_initializer) { 2705 void set_is_class_field_initializer(bool is_class_field_initializer) {
2706 bit_field_ = 2706 bit_field_ =
2707 IsClassFieldInitializer::update(bit_field_, is_class_field_initializer); 2707 IsClassFieldInitializer::update(bit_field_, is_class_field_initializer);
2708 } 2708 }
2709 2709
2710 int return_position() { 2710 int return_position() {
2711 return std::max(start_position(), end_position() - (has_braces_ ? 1 : 0)); 2711 return std::max(start_position(), end_position() - (has_braces_ ? 1 : 0));
2712 } 2712 }
2713 2713
2714 int function_literal_num() const { return function_literal_num_; }
2715
2714 private: 2716 private:
2715 friend class AstNodeFactory; 2717 friend class AstNodeFactory;
2716 2718
2717 FunctionLiteral(Zone* zone, const AstString* name, 2719 FunctionLiteral(Zone* zone, const AstString* name,
2718 AstValueFactory* ast_value_factory, DeclarationScope* scope, 2720 AstValueFactory* ast_value_factory, DeclarationScope* scope,
2719 ZoneList<Statement*>* body, int materialized_literal_count, 2721 ZoneList<Statement*>* body, int materialized_literal_count,
2720 int expected_property_count, int parameter_count, 2722 int expected_property_count, int parameter_count,
2721 int function_length, FunctionType function_type, 2723 int function_length, FunctionType function_type,
2722 ParameterFlag has_duplicate_parameters, 2724 ParameterFlag has_duplicate_parameters,
2723 EagerCompileHint eager_compile_hint, int position, 2725 EagerCompileHint eager_compile_hint, int position,
2724 bool is_function, bool has_braces) 2726 bool is_function, bool has_braces, int function_literal_num)
2725 : Expression(position, kFunctionLiteral), 2727 : Expression(position, kFunctionLiteral),
2726 materialized_literal_count_(materialized_literal_count), 2728 materialized_literal_count_(materialized_literal_count),
2727 expected_property_count_(expected_property_count), 2729 expected_property_count_(expected_property_count),
2728 parameter_count_(parameter_count), 2730 parameter_count_(parameter_count),
2729 function_length_(function_length), 2731 function_length_(function_length),
2730 function_token_position_(kNoSourcePosition), 2732 function_token_position_(kNoSourcePosition),
2731 yield_count_(0), 2733 yield_count_(0),
2732 has_braces_(has_braces), 2734 has_braces_(has_braces),
2733 raw_name_(name), 2735 raw_name_(name),
2734 scope_(scope), 2736 scope_(scope),
2735 body_(body), 2737 body_(body),
2736 raw_inferred_name_(ast_value_factory->empty_string()), 2738 raw_inferred_name_(ast_value_factory->empty_string()),
2737 ast_properties_(zone) { 2739 ast_properties_(zone),
2740 function_literal_num_(function_literal_num) {
2738 bit_field_ |= 2741 bit_field_ |=
2739 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | 2742 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) |
2740 HasDuplicateParameters::encode(has_duplicate_parameters == 2743 HasDuplicateParameters::encode(has_duplicate_parameters ==
2741 kHasDuplicateParameters) | 2744 kHasDuplicateParameters) |
2742 IsFunction::encode(is_function) | 2745 IsFunction::encode(is_function) |
2743 RequiresClassFieldInit::encode(false) | 2746 RequiresClassFieldInit::encode(false) |
2744 ShouldNotBeUsedOnceHintField::encode(false) | 2747 ShouldNotBeUsedOnceHintField::encode(false) |
2745 DontOptimizeReasonField::encode(kNoReason) | 2748 DontOptimizeReasonField::encode(kNoReason) |
2746 IsClassFieldInitializer::encode(false); 2749 IsClassFieldInitializer::encode(false);
2747 if (eager_compile_hint == kShouldEagerCompile) SetShouldEagerCompile(); 2750 if (eager_compile_hint == kShouldEagerCompile) SetShouldEagerCompile();
(...skipping 20 matching lines...) Expand all
2768 int function_token_position_; 2771 int function_token_position_;
2769 int yield_count_; 2772 int yield_count_;
2770 bool has_braces_; 2773 bool has_braces_;
2771 2774
2772 const AstString* raw_name_; 2775 const AstString* raw_name_;
2773 DeclarationScope* scope_; 2776 DeclarationScope* scope_;
2774 ZoneList<Statement*>* body_; 2777 ZoneList<Statement*>* body_;
2775 const AstString* raw_inferred_name_; 2778 const AstString* raw_inferred_name_;
2776 Handle<String> inferred_name_; 2779 Handle<String> inferred_name_;
2777 AstProperties ast_properties_; 2780 AstProperties ast_properties_;
2781 int function_literal_num_;
2778 }; 2782 };
2779 2783
2780 // Property is used for passing information 2784 // Property is used for passing information
2781 // about a class literal's properties from the parser to the code generator. 2785 // about a class literal's properties from the parser to the code generator.
2782 class ClassLiteralProperty final : public LiteralProperty { 2786 class ClassLiteralProperty final : public LiteralProperty {
2783 public: 2787 public:
2784 enum Kind : uint8_t { METHOD, GETTER, SETTER, FIELD }; 2788 enum Kind : uint8_t { METHOD, GETTER, SETTER, FIELD };
2785 2789
2786 Kind kind() const { return kind_; } 2790 Kind kind() const { return kind_; }
2787 2791
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
3457 return new (zone_) Throw(exception, pos); 3461 return new (zone_) Throw(exception, pos);
3458 } 3462 }
3459 3463
3460 FunctionLiteral* NewFunctionLiteral( 3464 FunctionLiteral* NewFunctionLiteral(
3461 const AstRawString* name, DeclarationScope* scope, 3465 const AstRawString* name, DeclarationScope* scope,
3462 ZoneList<Statement*>* body, int materialized_literal_count, 3466 ZoneList<Statement*>* body, int materialized_literal_count,
3463 int expected_property_count, int parameter_count, int function_length, 3467 int expected_property_count, int parameter_count, int function_length,
3464 FunctionLiteral::ParameterFlag has_duplicate_parameters, 3468 FunctionLiteral::ParameterFlag has_duplicate_parameters,
3465 FunctionLiteral::FunctionType function_type, 3469 FunctionLiteral::FunctionType function_type,
3466 FunctionLiteral::EagerCompileHint eager_compile_hint, int position, 3470 FunctionLiteral::EagerCompileHint eager_compile_hint, int position,
3467 bool has_braces) { 3471 bool has_braces, int function_literal_num) {
3468 return new (zone_) FunctionLiteral( 3472 return new (zone_) FunctionLiteral(
3469 zone_, name, ast_value_factory_, scope, body, 3473 zone_, name, ast_value_factory_, scope, body,
3470 materialized_literal_count, expected_property_count, parameter_count, 3474 materialized_literal_count, expected_property_count, parameter_count,
3471 function_length, function_type, has_duplicate_parameters, 3475 function_length, function_type, has_duplicate_parameters,
3472 eager_compile_hint, position, true, has_braces); 3476 eager_compile_hint, position, true, has_braces, function_literal_num);
3473 } 3477 }
3474 3478
3475 // Creates a FunctionLiteral representing a top-level script, the 3479 // Creates a FunctionLiteral representing a top-level script, the
3476 // result of an eval (top-level or otherwise), or the result of calling 3480 // result of an eval (top-level or otherwise), or the result of calling
3477 // the Function constructor. 3481 // the Function constructor.
3478 FunctionLiteral* NewScriptOrEvalFunctionLiteral( 3482 FunctionLiteral* NewScriptOrEvalFunctionLiteral(
3479 DeclarationScope* scope, ZoneList<Statement*>* body, 3483 DeclarationScope* scope, ZoneList<Statement*>* body,
3480 int materialized_literal_count, int expected_property_count, 3484 int materialized_literal_count, int expected_property_count,
3481 int parameter_count) { 3485 int parameter_count) {
3482 return new (zone_) FunctionLiteral( 3486 return new (zone_) FunctionLiteral(
3483 zone_, ast_value_factory_->empty_string(), ast_value_factory_, scope, 3487 zone_, ast_value_factory_->empty_string(), ast_value_factory_, scope,
3484 body, materialized_literal_count, expected_property_count, 3488 body, materialized_literal_count, expected_property_count,
3485 parameter_count, parameter_count, FunctionLiteral::kAnonymousExpression, 3489 parameter_count, parameter_count, FunctionLiteral::kAnonymousExpression,
3486 FunctionLiteral::kNoDuplicateParameters, 3490 FunctionLiteral::kNoDuplicateParameters,
3487 FunctionLiteral::kShouldLazyCompile, 0, false, true); 3491 FunctionLiteral::kShouldLazyCompile, 0, false, true, 0);
marja 2016/11/18 10:48:04 What does 0 mean here? Invalid? Or just some defau
jochen (gone - plz use gerrit) 2016/11/21 08:03:47 -1 means invalid, zero means top-level function. a
3488 } 3492 }
3489 3493
3490 ClassLiteral::Property* NewClassLiteralProperty( 3494 ClassLiteral::Property* NewClassLiteralProperty(
3491 Expression* key, Expression* value, ClassLiteralProperty::Kind kind, 3495 Expression* key, Expression* value, ClassLiteralProperty::Kind kind,
3492 bool is_static, bool is_computed_name) { 3496 bool is_static, bool is_computed_name) {
3493 return new (zone_) 3497 return new (zone_)
3494 ClassLiteral::Property(key, value, kind, is_static, is_computed_name); 3498 ClassLiteral::Property(key, value, kind, is_static, is_computed_name);
3495 } 3499 }
3496 3500
3497 ClassLiteral* NewClassLiteral(VariableProxy* proxy, Expression* extends, 3501 ClassLiteral* NewClassLiteral(VariableProxy* proxy, Expression* extends,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3603 : NULL; \ 3607 : NULL; \
3604 } 3608 }
3605 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3609 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3606 #undef DECLARE_NODE_FUNCTIONS 3610 #undef DECLARE_NODE_FUNCTIONS
3607 3611
3608 3612
3609 } // namespace internal 3613 } // namespace internal
3610 } // namespace v8 3614 } // namespace v8
3611 3615
3612 #endif // V8_AST_AST_H_ 3616 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | src/factory.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698