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 #include "src/ast/scopes.h" | 5 #include "src/ast/scopes.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // use. Because a Variable holding a handle with the same location exists | 23 // use. Because a Variable holding a handle with the same location exists |
24 // this is ensured. | 24 // this is ensured. |
25 | 25 |
26 VariableMap::VariableMap(Zone* zone) | 26 VariableMap::VariableMap(Zone* zone) |
27 : ZoneHashMap(ZoneHashMap::PointersMatch, 8, ZoneAllocationPolicy(zone)) {} | 27 : ZoneHashMap(ZoneHashMap::PointersMatch, 8, ZoneAllocationPolicy(zone)) {} |
28 | 28 |
29 Variable* VariableMap::Declare(Zone* zone, Scope* scope, | 29 Variable* VariableMap::Declare(Zone* zone, Scope* scope, |
30 const AstRawString* name, VariableMode mode, | 30 const AstRawString* name, VariableMode mode, |
31 Variable::Kind kind, | 31 Variable::Kind kind, |
32 InitializationFlag initialization_flag, | 32 InitializationFlag initialization_flag, |
33 MaybeAssignedFlag maybe_assigned_flag) { | 33 MaybeAssignedFlag maybe_assigned_flag, |
| 34 bool* added) { |
34 // AstRawStrings are unambiguous, i.e., the same string is always represented | 35 // AstRawStrings are unambiguous, i.e., the same string is always represented |
35 // by the same AstRawString*. | 36 // by the same AstRawString*. |
36 // FIXME(marja): fix the type of Lookup. | 37 // FIXME(marja): fix the type of Lookup. |
37 Entry* p = | 38 Entry* p = |
38 ZoneHashMap::LookupOrInsert(const_cast<AstRawString*>(name), name->hash(), | 39 ZoneHashMap::LookupOrInsert(const_cast<AstRawString*>(name), name->hash(), |
39 ZoneAllocationPolicy(zone)); | 40 ZoneAllocationPolicy(zone)); |
40 if (p->value == NULL) { | 41 if (added) *added = p->value == nullptr; |
| 42 if (p->value == nullptr) { |
41 // The variable has not been declared yet -> insert it. | 43 // The variable has not been declared yet -> insert it. |
42 DCHECK(p->key == name); | 44 DCHECK(p->key == name); |
43 p->value = new (zone) Variable(scope, name, mode, kind, initialization_flag, | 45 p->value = new (zone) Variable(scope, name, mode, kind, initialization_flag, |
44 maybe_assigned_flag); | 46 maybe_assigned_flag); |
45 } | 47 } |
46 return reinterpret_cast<Variable*>(p->value); | 48 return reinterpret_cast<Variable*>(p->value); |
47 } | 49 } |
48 | 50 |
49 | 51 |
50 Variable* VariableMap::Lookup(const AstRawString* name) { | 52 Variable* VariableMap::Lookup(const AstRawString* name) { |
(...skipping 21 matching lines...) Expand all Loading... |
72 } | 74 } |
73 | 75 |
74 | 76 |
75 // ---------------------------------------------------------------------------- | 77 // ---------------------------------------------------------------------------- |
76 // Implementation of Scope | 78 // Implementation of Scope |
77 | 79 |
78 Scope::Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type) | 80 Scope::Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type) |
79 : zone_(zone), | 81 : zone_(zone), |
80 outer_scope_(outer_scope), | 82 outer_scope_(outer_scope), |
81 variables_(zone), | 83 variables_(zone), |
| 84 ordered_variables_(4, zone), |
82 decls_(4, zone), | 85 decls_(4, zone), |
83 scope_type_(scope_type) { | 86 scope_type_(scope_type) { |
84 SetDefaults(); | 87 SetDefaults(); |
85 if (outer_scope == nullptr) { | 88 if (outer_scope == nullptr) { |
86 // If the outer scope is null, this cannot be a with scope. The outermost | 89 // If the outer scope is null, this cannot be a with scope. The outermost |
87 // scope must be a script scope. | 90 // scope must be a script scope. |
88 DCHECK_EQ(SCRIPT_SCOPE, scope_type); | 91 DCHECK_EQ(SCRIPT_SCOPE, scope_type); |
89 } else { | 92 } else { |
90 set_language_mode(outer_scope->language_mode()); | 93 set_language_mode(outer_scope->language_mode()); |
91 force_context_allocation_ = | 94 force_context_allocation_ = |
(...skipping 26 matching lines...) Expand all Loading... |
118 module_descriptor_ = new (zone) ModuleDescriptor(zone); | 121 module_descriptor_ = new (zone) ModuleDescriptor(zone); |
119 set_language_mode(STRICT); | 122 set_language_mode(STRICT); |
120 DeclareThis(ast_value_factory); | 123 DeclareThis(ast_value_factory); |
121 } | 124 } |
122 | 125 |
123 Scope::Scope(Zone* zone, Scope* inner_scope, ScopeType scope_type, | 126 Scope::Scope(Zone* zone, Scope* inner_scope, ScopeType scope_type, |
124 Handle<ScopeInfo> scope_info) | 127 Handle<ScopeInfo> scope_info) |
125 : zone_(zone), | 128 : zone_(zone), |
126 outer_scope_(nullptr), | 129 outer_scope_(nullptr), |
127 variables_(zone), | 130 variables_(zone), |
| 131 ordered_variables_(0, zone), |
128 decls_(0, zone), | 132 decls_(0, zone), |
129 scope_info_(scope_info), | 133 scope_info_(scope_info), |
130 scope_type_(scope_type) { | 134 scope_type_(scope_type) { |
131 SetDefaults(); | 135 SetDefaults(); |
132 #ifdef DEBUG | 136 #ifdef DEBUG |
133 already_resolved_ = true; | 137 already_resolved_ = true; |
134 #endif | 138 #endif |
135 if (scope_type == WITH_SCOPE) { | 139 if (scope_type == WITH_SCOPE) { |
136 DCHECK(scope_info.is_null()); | 140 DCHECK(scope_info.is_null()); |
137 } else { | 141 } else { |
(...skipping 15 matching lines...) Expand all Loading... |
153 params_(0, zone), | 157 params_(0, zone), |
154 sloppy_block_function_map_(zone) { | 158 sloppy_block_function_map_(zone) { |
155 SetDefaults(); | 159 SetDefaults(); |
156 } | 160 } |
157 | 161 |
158 Scope::Scope(Zone* zone, Scope* inner_scope, | 162 Scope::Scope(Zone* zone, Scope* inner_scope, |
159 const AstRawString* catch_variable_name) | 163 const AstRawString* catch_variable_name) |
160 : zone_(zone), | 164 : zone_(zone), |
161 outer_scope_(nullptr), | 165 outer_scope_(nullptr), |
162 variables_(zone), | 166 variables_(zone), |
| 167 ordered_variables_(0, zone), |
163 decls_(0, zone), | 168 decls_(0, zone), |
164 scope_type_(CATCH_SCOPE) { | 169 scope_type_(CATCH_SCOPE) { |
165 SetDefaults(); | 170 SetDefaults(); |
166 #ifdef DEBUG | 171 #ifdef DEBUG |
167 already_resolved_ = true; | 172 already_resolved_ = true; |
168 #endif | 173 #endif |
169 if (inner_scope != nullptr) AddInnerScope(inner_scope); | 174 if (inner_scope != nullptr) AddInnerScope(inner_scope); |
170 Variable* variable = | 175 Variable* variable = |
171 variables_.Declare(zone, this, catch_variable_name, VAR, Variable::NORMAL, | 176 variables_.Declare(zone, this, catch_variable_name, VAR, Variable::NORMAL, |
172 kCreatedInitialized); | 177 kCreatedInitialized); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 scope->CheckZones(); | 424 scope->CheckZones(); |
420 #endif | 425 #endif |
421 } | 426 } |
422 | 427 |
423 void DeclarationScope::DeclareThis(AstValueFactory* ast_value_factory) { | 428 void DeclarationScope::DeclareThis(AstValueFactory* ast_value_factory) { |
424 DCHECK(!already_resolved_); | 429 DCHECK(!already_resolved_); |
425 DCHECK(is_declaration_scope()); | 430 DCHECK(is_declaration_scope()); |
426 DCHECK(has_this_declaration()); | 431 DCHECK(has_this_declaration()); |
427 | 432 |
428 bool subclass_constructor = IsSubclassConstructor(function_kind_); | 433 bool subclass_constructor = IsSubclassConstructor(function_kind_); |
429 Variable* var = variables_.Declare( | 434 Variable* var = Declare( |
430 zone(), this, ast_value_factory->this_string(), | 435 zone(), this, ast_value_factory->this_string(), |
431 subclass_constructor ? CONST : VAR, Variable::THIS, | 436 subclass_constructor ? CONST : VAR, Variable::THIS, |
432 subclass_constructor ? kNeedsInitialization : kCreatedInitialized); | 437 subclass_constructor ? kNeedsInitialization : kCreatedInitialized); |
433 receiver_ = var; | 438 receiver_ = var; |
434 } | 439 } |
435 | 440 |
436 void DeclarationScope::DeclareDefaultFunctionVariables( | 441 void DeclarationScope::DeclareDefaultFunctionVariables( |
437 AstValueFactory* ast_value_factory) { | 442 AstValueFactory* ast_value_factory) { |
438 DCHECK(is_function_scope()); | 443 DCHECK(is_function_scope()); |
439 DCHECK(!is_arrow_scope()); | 444 DCHECK(!is_arrow_scope()); |
440 // Declare 'arguments' variable which exists in all non arrow functions. | 445 // Declare 'arguments' variable which exists in all non arrow functions. |
441 // Note that it might never be accessed, in which case it won't be | 446 // Note that it might never be accessed, in which case it won't be |
442 // allocated during variable allocation. | 447 // allocated during variable allocation. |
443 arguments_ = | 448 arguments_ = Declare(zone(), this, ast_value_factory->arguments_string(), VAR, |
444 variables_.Declare(zone(), this, ast_value_factory->arguments_string(), | 449 Variable::ARGUMENTS, kCreatedInitialized); |
445 VAR, Variable::ARGUMENTS, kCreatedInitialized); | |
446 | 450 |
447 new_target_ = | 451 new_target_ = Declare(zone(), this, ast_value_factory->new_target_string(), |
448 variables_.Declare(zone(), this, ast_value_factory->new_target_string(), | 452 CONST, Variable::NORMAL, kCreatedInitialized); |
449 CONST, Variable::NORMAL, kCreatedInitialized); | |
450 | 453 |
451 if (IsConciseMethod(function_kind_) || IsClassConstructor(function_kind_) || | 454 if (IsConciseMethod(function_kind_) || IsClassConstructor(function_kind_) || |
452 IsAccessorFunction(function_kind_)) { | 455 IsAccessorFunction(function_kind_)) { |
453 this_function_ = variables_.Declare( | 456 this_function_ = |
454 zone(), this, ast_value_factory->this_function_string(), CONST, | 457 Declare(zone(), this, ast_value_factory->this_function_string(), CONST, |
455 Variable::NORMAL, kCreatedInitialized); | 458 Variable::NORMAL, kCreatedInitialized); |
456 } | 459 } |
457 } | 460 } |
458 | 461 |
459 Variable* DeclarationScope::DeclareFunctionVar(const AstRawString* name) { | 462 Variable* DeclarationScope::DeclareFunctionVar(const AstRawString* name) { |
460 DCHECK(is_function_scope()); | 463 DCHECK(is_function_scope()); |
461 DCHECK_NULL(function_); | 464 DCHECK_NULL(function_); |
462 VariableMode mode = is_strict(language_mode()) ? CONST : CONST_LEGACY; | 465 VariableMode mode = is_strict(language_mode()) ? CONST : CONST_LEGACY; |
463 function_ = new (zone()) | 466 function_ = new (zone()) |
464 Variable(this, name, mode, Variable::NORMAL, kCreatedInitialized); | 467 Variable(this, name, mode, Variable::NORMAL, kCreatedInitialized); |
465 return function_; | 468 return function_; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 Variable* DeclarationScope::DeclareParameter( | 666 Variable* DeclarationScope::DeclareParameter( |
664 const AstRawString* name, VariableMode mode, bool is_optional, bool is_rest, | 667 const AstRawString* name, VariableMode mode, bool is_optional, bool is_rest, |
665 bool* is_duplicate, AstValueFactory* ast_value_factory) { | 668 bool* is_duplicate, AstValueFactory* ast_value_factory) { |
666 DCHECK(!already_resolved_); | 669 DCHECK(!already_resolved_); |
667 DCHECK(is_function_scope()); | 670 DCHECK(is_function_scope()); |
668 DCHECK(!is_optional || !is_rest); | 671 DCHECK(!is_optional || !is_rest); |
669 Variable* var; | 672 Variable* var; |
670 if (mode == TEMPORARY) { | 673 if (mode == TEMPORARY) { |
671 var = NewTemporary(name); | 674 var = NewTemporary(name); |
672 } else { | 675 } else { |
673 var = variables_.Declare(zone(), this, name, mode, Variable::NORMAL, | 676 var = Declare(zone(), this, name, mode, Variable::NORMAL, |
674 kCreatedInitialized); | 677 kCreatedInitialized); |
675 // TODO(wingo): Avoid O(n^2) check. | 678 // TODO(wingo): Avoid O(n^2) check. |
676 *is_duplicate = IsDeclaredParameter(name); | 679 *is_duplicate = IsDeclaredParameter(name); |
677 } | 680 } |
678 if (!is_optional && !is_rest && arity_ == params_.length()) { | 681 if (!is_optional && !is_rest && arity_ == params_.length()) { |
679 ++arity_; | 682 ++arity_; |
680 } | 683 } |
681 if (is_rest) { | 684 if (is_rest) { |
682 DCHECK_NULL(rest_parameter_); | 685 DCHECK_NULL(rest_parameter_); |
683 rest_parameter_ = var; | 686 rest_parameter_ = var; |
684 rest_index_ = num_parameters(); | 687 rest_index_ = num_parameters(); |
685 } | 688 } |
686 params_.Add(var, zone()); | 689 params_.Add(var, zone()); |
687 if (name == ast_value_factory->arguments_string()) { | 690 if (name == ast_value_factory->arguments_string()) { |
688 has_arguments_parameter_ = true; | 691 has_arguments_parameter_ = true; |
689 } | 692 } |
690 return var; | 693 return var; |
691 } | 694 } |
692 | 695 |
693 Variable* Scope::DeclareLocal(const AstRawString* name, VariableMode mode, | 696 Variable* Scope::DeclareLocal(const AstRawString* name, VariableMode mode, |
694 InitializationFlag init_flag, Variable::Kind kind, | 697 InitializationFlag init_flag, Variable::Kind kind, |
695 MaybeAssignedFlag maybe_assigned_flag) { | 698 MaybeAssignedFlag maybe_assigned_flag) { |
696 DCHECK(!already_resolved_); | 699 DCHECK(!already_resolved_); |
697 // This function handles VAR, LET, and CONST modes. DYNAMIC variables are | 700 // This function handles VAR, LET, and CONST modes. DYNAMIC variables are |
698 // introduced during variable allocation, and TEMPORARY variables are | 701 // introduced during variable allocation, and TEMPORARY variables are |
699 // allocated via NewTemporary(). | 702 // allocated via NewTemporary(). |
700 DCHECK(IsDeclaredVariableMode(mode)); | 703 DCHECK(IsDeclaredVariableMode(mode)); |
701 return variables_.Declare(zone(), this, name, mode, kind, init_flag, | 704 return Declare(zone(), this, name, mode, kind, init_flag, |
702 maybe_assigned_flag); | 705 maybe_assigned_flag); |
703 } | 706 } |
704 | 707 |
705 Variable* DeclarationScope::DeclareDynamicGlobal(const AstRawString* name, | 708 Variable* DeclarationScope::DeclareDynamicGlobal(const AstRawString* name, |
706 Variable::Kind kind) { | 709 Variable::Kind kind) { |
707 DCHECK(is_script_scope()); | 710 DCHECK(is_script_scope()); |
708 return variables_.Declare(zone(), this, name, DYNAMIC_GLOBAL, kind, | 711 return Declare(zone(), this, name, DYNAMIC_GLOBAL, kind, kCreatedInitialized); |
709 kCreatedInitialized); | |
710 } | 712 } |
711 | 713 |
712 | 714 |
713 bool Scope::RemoveUnresolved(VariableProxy* var) { | 715 bool Scope::RemoveUnresolved(VariableProxy* var) { |
714 if (unresolved_ == var) { | 716 if (unresolved_ == var) { |
715 unresolved_ = var->next_unresolved(); | 717 unresolved_ = var->next_unresolved(); |
716 var->set_next_unresolved(nullptr); | 718 var->set_next_unresolved(nullptr); |
717 return true; | 719 return true; |
718 } | 720 } |
719 VariableProxy* current = unresolved_; | 721 VariableProxy* current = unresolved_; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 if (decls_[j]->proxy()->raw_name() == name) { | 791 if (decls_[j]->proxy()->raw_name() == name) { |
790 return decls_[j]; | 792 return decls_[j]; |
791 } | 793 } |
792 } | 794 } |
793 DCHECK(false); | 795 DCHECK(false); |
794 } | 796 } |
795 } | 797 } |
796 return nullptr; | 798 return nullptr; |
797 } | 799 } |
798 | 800 |
799 class VarAndOrder { | |
800 public: | |
801 VarAndOrder(Variable* var, int order) : var_(var), order_(order) { } | |
802 Variable* var() const { return var_; } | |
803 int order() const { return order_; } | |
804 static int Compare(const VarAndOrder* a, const VarAndOrder* b) { | |
805 return a->order_ - b->order_; | |
806 } | |
807 | |
808 private: | |
809 Variable* var_; | |
810 int order_; | |
811 }; | |
812 | |
813 void Scope::CollectStackAndContextLocals(ZoneList<Variable*>* stack_locals, | 801 void Scope::CollectStackAndContextLocals(ZoneList<Variable*>* stack_locals, |
814 ZoneList<Variable*>* context_locals, | 802 ZoneList<Variable*>* context_locals, |
815 ZoneList<Variable*>* context_globals) { | 803 ZoneList<Variable*>* context_globals) { |
816 DCHECK(stack_locals != NULL); | 804 DCHECK(stack_locals != NULL); |
817 DCHECK(context_locals != NULL); | 805 DCHECK(context_locals != NULL); |
818 DCHECK(context_globals != NULL); | 806 DCHECK(context_globals != NULL); |
819 | 807 |
820 // Collect temporaries which are always allocated on the stack, unless the | 808 // Collect temporaries which are always allocated on the stack, unless the |
821 // context as a whole has forced context allocation. | 809 // context as a whole has forced context allocation. |
822 if (is_declaration_scope()) { | 810 if (is_declaration_scope()) { |
823 ZoneList<Variable*>* temps = AsDeclarationScope()->temps(); | 811 ZoneList<Variable*>* temps = AsDeclarationScope()->temps(); |
824 for (int i = 0; i < temps->length(); i++) { | 812 for (int i = 0; i < temps->length(); i++) { |
825 Variable* var = (*temps)[i]; | 813 Variable* var = (*temps)[i]; |
826 if (var->is_used()) { | 814 if (var->is_used()) { |
827 if (var->IsContextSlot()) { | 815 if (var->IsContextSlot()) { |
828 DCHECK(has_forced_context_allocation()); | 816 DCHECK(has_forced_context_allocation()); |
829 context_locals->Add(var, zone()); | 817 context_locals->Add(var, zone()); |
830 } else if (var->IsStackLocal()) { | 818 } else if (var->IsStackLocal()) { |
831 stack_locals->Add(var, zone()); | 819 stack_locals->Add(var, zone()); |
832 } else { | 820 } else { |
833 DCHECK(var->IsParameter()); | 821 DCHECK(var->IsParameter()); |
834 } | 822 } |
835 } | 823 } |
836 } | 824 } |
837 } | 825 } |
838 | 826 |
839 // Collect declared local variables. | 827 for (int i = 0; i < ordered_variables_.length(); i++) { |
840 ZoneList<VarAndOrder> vars(variables_.occupancy(), zone()); | 828 Variable* var = ordered_variables_[i]; |
841 for (VariableMap::Entry* p = variables_.Start(); | |
842 p != NULL; | |
843 p = variables_.Next(p)) { | |
844 Variable* var = reinterpret_cast<Variable*>(p->value); | |
845 if (var->is_used()) { | |
846 vars.Add(VarAndOrder(var, p->order), zone()); | |
847 } | |
848 } | |
849 vars.Sort(VarAndOrder::Compare); | |
850 int var_count = vars.length(); | |
851 for (int i = 0; i < var_count; i++) { | |
852 Variable* var = vars[i].var(); | |
853 if (var->IsStackLocal()) { | 829 if (var->IsStackLocal()) { |
854 stack_locals->Add(var, zone()); | 830 stack_locals->Add(var, zone()); |
855 } else if (var->IsContextSlot()) { | 831 } else if (var->IsContextSlot()) { |
856 context_locals->Add(var, zone()); | 832 context_locals->Add(var, zone()); |
857 } else if (var->IsGlobalSlot()) { | 833 } else if (var->IsGlobalSlot()) { |
858 context_globals->Add(var, zone()); | 834 context_globals->Add(var, zone()); |
859 } | 835 } |
860 } | 836 } |
861 } | 837 } |
862 | 838 |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1627 | 1603 |
1628 void Scope::AllocateNonParameterLocalsAndDeclaredGlobals() { | 1604 void Scope::AllocateNonParameterLocalsAndDeclaredGlobals() { |
1629 // All variables that have no rewrite yet are non-parameter locals. | 1605 // All variables that have no rewrite yet are non-parameter locals. |
1630 if (is_declaration_scope()) { | 1606 if (is_declaration_scope()) { |
1631 ZoneList<Variable*>* temps = AsDeclarationScope()->temps(); | 1607 ZoneList<Variable*>* temps = AsDeclarationScope()->temps(); |
1632 for (int i = 0; i < temps->length(); i++) { | 1608 for (int i = 0; i < temps->length(); i++) { |
1633 AllocateNonParameterLocal((*temps)[i]); | 1609 AllocateNonParameterLocal((*temps)[i]); |
1634 } | 1610 } |
1635 } | 1611 } |
1636 | 1612 |
1637 ZoneList<VarAndOrder> vars(variables_.occupancy(), zone()); | 1613 for (int i = 0; i < ordered_variables_.length(); i++) { |
1638 for (VariableMap::Entry* p = variables_.Start(); | 1614 AllocateNonParameterLocal(ordered_variables_[i]); |
1639 p != NULL; | |
1640 p = variables_.Next(p)) { | |
1641 Variable* var = reinterpret_cast<Variable*>(p->value); | |
1642 vars.Add(VarAndOrder(var, p->order), zone()); | |
1643 } | |
1644 vars.Sort(VarAndOrder::Compare); | |
1645 int var_count = vars.length(); | |
1646 for (int i = 0; i < var_count; i++) { | |
1647 AllocateNonParameterLocal(vars[i].var()); | |
1648 } | 1615 } |
1649 | 1616 |
1650 if (FLAG_global_var_shortcuts) { | 1617 if (FLAG_global_var_shortcuts) { |
1651 for (int i = 0; i < var_count; i++) { | 1618 for (int i = 0; i < ordered_variables_.length(); i++) { |
1652 AllocateDeclaredGlobal(vars[i].var()); | 1619 AllocateDeclaredGlobal(ordered_variables_[i]); |
1653 } | 1620 } |
1654 } | 1621 } |
1655 | 1622 |
1656 if (is_declaration_scope()) { | 1623 if (is_declaration_scope()) { |
1657 AsDeclarationScope()->AllocateLocals(); | 1624 AsDeclarationScope()->AllocateLocals(); |
1658 } | 1625 } |
1659 } | 1626 } |
1660 | 1627 |
1661 void DeclarationScope::AllocateLocals() { | 1628 void DeclarationScope::AllocateLocals() { |
1662 // For now, function_ must be allocated at the very end. If it gets | 1629 // For now, function_ must be allocated at the very end. If it gets |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1753 function != nullptr && function->IsContextSlot(); | 1720 function != nullptr && function->IsContextSlot(); |
1754 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - | 1721 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - |
1755 (is_function_var_in_context ? 1 : 0); | 1722 (is_function_var_in_context ? 1 : 0); |
1756 } | 1723 } |
1757 | 1724 |
1758 | 1725 |
1759 int Scope::ContextGlobalCount() const { return num_global_slots(); } | 1726 int Scope::ContextGlobalCount() const { return num_global_slots(); } |
1760 | 1727 |
1761 } // namespace internal | 1728 } // namespace internal |
1762 } // namespace v8 | 1729 } // namespace v8 |
OLD | NEW |