OLD | NEW |
---|---|
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_SCOPES_H_ | 5 #ifndef V8_AST_SCOPES_H_ |
6 #define V8_AST_SCOPES_H_ | 6 #define V8_AST_SCOPES_H_ |
7 | 7 |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/base/hashmap.h" | 9 #include "src/base/hashmap.h" |
10 #include "src/globals.h" | 10 #include "src/globals.h" |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
595 AstNodeFactory* factory); | 595 AstNodeFactory* factory); |
596 void ResolveVariablesRecursively(ParseInfo* info, AstNodeFactory* factory); | 596 void ResolveVariablesRecursively(ParseInfo* info, AstNodeFactory* factory); |
597 | 597 |
598 // Finds free variables of this scope. This mutates the unresolved variables | 598 // Finds free variables of this scope. This mutates the unresolved variables |
599 // list along the way, so full resolution cannot be done afterwards. | 599 // list along the way, so full resolution cannot be done afterwards. |
600 // If a ParseInfo* is passed, non-free variables will be resolved. | 600 // If a ParseInfo* is passed, non-free variables will be resolved. |
601 VariableProxy* FetchFreeVariables(DeclarationScope* max_outer_scope, | 601 VariableProxy* FetchFreeVariables(DeclarationScope* max_outer_scope, |
602 ParseInfo* info = nullptr, | 602 ParseInfo* info = nullptr, |
603 VariableProxy* stack = nullptr); | 603 VariableProxy* stack = nullptr); |
604 | 604 |
605 // Scope analysis. | |
606 void PropagateScopeInfo(); | |
607 | |
608 // Predicates. | 605 // Predicates. |
609 bool MustAllocate(Variable* var); | 606 bool MustAllocate(Variable* var); |
610 bool MustAllocateInContext(Variable* var); | 607 bool MustAllocateInContext(Variable* var); |
611 | 608 |
612 // Variable allocation. | 609 // Variable allocation. |
613 void AllocateStackSlot(Variable* var); | 610 void AllocateStackSlot(Variable* var); |
614 void AllocateHeapSlot(Variable* var); | 611 void AllocateHeapSlot(Variable* var); |
615 void AllocateNonParameterLocal(Variable* var); | 612 void AllocateNonParameterLocal(Variable* var); |
616 void AllocateDeclaredGlobal(Variable* var); | 613 void AllocateDeclaredGlobal(Variable* var); |
617 void AllocateNonParameterLocalsAndDeclaredGlobals(); | 614 void AllocateNonParameterLocalsAndDeclaredGlobals(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
677 } | 674 } |
678 | 675 |
679 bool NeedsHomeObject() const { | 676 bool NeedsHomeObject() const { |
680 return scope_uses_super_property_ || | 677 return scope_uses_super_property_ || |
681 (inner_scope_calls_eval_ && (IsConciseMethod(function_kind()) || | 678 (inner_scope_calls_eval_ && (IsConciseMethod(function_kind()) || |
682 IsAccessorFunction(function_kind()) || | 679 IsAccessorFunction(function_kind()) || |
683 IsClassConstructor(function_kind()))); | 680 IsClassConstructor(function_kind()))); |
684 } | 681 } |
685 | 682 |
686 bool asm_module() const { return asm_module_; } | 683 bool asm_module() const { return asm_module_; } |
687 void set_asm_module() { asm_module_ = true; } | 684 void set_asm_module() { |
titzer
2016/08/23 13:08:59
Move to cc file? Not performance sensitive, I gues
| |
685 asm_module_ = true; | |
686 // Mark any existing inner function scopes as asm function scopes. | |
687 for (Scope* inner = inner_scope_; inner != nullptr; | |
titzer
2016/08/23 13:08:59
You could, e.g. recurse through block scopes as we
Toon Verwaest
2016/08/23 13:17:51
The block scopes I'm talking about aren't in this
| |
688 inner = inner->sibling_) { | |
689 if (inner->is_function_scope()) { | |
690 inner->AsDeclarationScope()->set_asm_function(); | |
691 } | |
692 } | |
693 } | |
688 bool asm_function() const { return asm_function_; } | 694 bool asm_function() const { return asm_function_; } |
689 void set_asm_function() { asm_module_ = true; } | 695 void set_asm_function() { asm_module_ = true; } |
690 | 696 |
691 void DeclareThis(AstValueFactory* ast_value_factory); | 697 void DeclareThis(AstValueFactory* ast_value_factory); |
692 void DeclareDefaultFunctionVariables(AstValueFactory* ast_value_factory); | 698 void DeclareDefaultFunctionVariables(AstValueFactory* ast_value_factory); |
693 | 699 |
694 // This lookup corresponds to a lookup in the "intermediate" scope sitting | 700 // This lookup corresponds to a lookup in the "intermediate" scope sitting |
695 // between this scope and the outer scope. (ECMA-262, 3rd., requires that | 701 // between this scope and the outer scope. (ECMA-262, 3rd., requires that |
696 // the name of named function literal is kept in an intermediate scope | 702 // the name of named function literal is kept in an intermediate scope |
697 // in between this scope and the next outer scope.) | 703 // in between this scope and the next outer scope.) |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
924 void AllocateModuleVariables(); | 930 void AllocateModuleVariables(); |
925 | 931 |
926 private: | 932 private: |
927 ModuleDescriptor* module_descriptor_; | 933 ModuleDescriptor* module_descriptor_; |
928 }; | 934 }; |
929 | 935 |
930 } // namespace internal | 936 } // namespace internal |
931 } // namespace v8 | 937 } // namespace v8 |
932 | 938 |
933 #endif // V8_AST_SCOPES_H_ | 939 #endif // V8_AST_SCOPES_H_ |
OLD | NEW |