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_SCOPES_H_ | 5 #ifndef V8_SCOPES_H_ |
6 #define V8_SCOPES_H_ | 6 #define V8_SCOPES_H_ |
7 | 7 |
8 #include "src/ast.h" | 8 #include "src/ast.h" |
9 #include "src/pending-compilation-error-handler.h" | 9 #include "src/pending-compilation-error-handler.h" |
10 #include "src/zone.h" | 10 #include "src/zone.h" |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 } | 435 } |
436 | 436 |
437 // --------------------------------------------------------------------------- | 437 // --------------------------------------------------------------------------- |
438 // Variable allocation. | 438 // Variable allocation. |
439 | 439 |
440 // Collect stack and context allocated local variables in this scope. Note | 440 // Collect stack and context allocated local variables in this scope. Note |
441 // that the function variable - if present - is not collected and should be | 441 // that the function variable - if present - is not collected and should be |
442 // handled separately. | 442 // handled separately. |
443 void CollectStackAndContextLocals( | 443 void CollectStackAndContextLocals( |
444 ZoneList<Variable*>* stack_locals, ZoneList<Variable*>* context_locals, | 444 ZoneList<Variable*>* stack_locals, ZoneList<Variable*>* context_locals, |
| 445 ZoneList<Variable*>* context_globals, |
445 ZoneList<Variable*>* strong_mode_free_variables = nullptr); | 446 ZoneList<Variable*>* strong_mode_free_variables = nullptr); |
446 | 447 |
447 // Current number of var or const locals. | 448 // Current number of var or const locals. |
448 int num_var_or_const() { return num_var_or_const_; } | 449 int num_var_or_const() { return num_var_or_const_; } |
449 | 450 |
450 // Result of variable allocation. | 451 // Result of variable allocation. |
451 int num_stack_slots() const { return num_stack_slots_; } | 452 int num_stack_slots() const { return num_stack_slots_; } |
452 int num_heap_slots() const { return num_heap_slots_; } | 453 int num_heap_slots() const { return num_heap_slots_; } |
| 454 int num_global_slots() const { return num_global_slots_; } |
453 | 455 |
454 int StackLocalCount() const; | 456 int StackLocalCount() const; |
455 int ContextLocalCount() const; | 457 int ContextLocalCount() const; |
| 458 int ContextGlobalCount() const; |
456 | 459 |
457 // For script scopes, the number of module literals (including nested ones). | 460 // For script scopes, the number of module literals (including nested ones). |
458 int num_modules() const { return num_modules_; } | 461 int num_modules() const { return num_modules_; } |
459 | 462 |
460 // For module scopes, the host scope's internal variable binding this module. | 463 // For module scopes, the host scope's internal variable binding this module. |
461 Variable* module_var() const { return module_var_; } | 464 Variable* module_var() const { return module_var_; } |
462 | 465 |
463 // Make sure this scope and all outer scopes are eagerly compiled. | 466 // Make sure this scope and all outer scopes are eagerly compiled. |
464 void ForceEagerCompilation() { force_eager_compilation_ = true; } | 467 void ForceEagerCompilation() { force_eager_compilation_ = true; } |
465 | 468 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 // True if it doesn't need scope resolution (e.g., if the scope was | 613 // True if it doesn't need scope resolution (e.g., if the scope was |
611 // constructed based on a serialized scope info or a catch context). | 614 // constructed based on a serialized scope info or a catch context). |
612 bool already_resolved_; | 615 bool already_resolved_; |
613 | 616 |
614 // Computed as variables are declared. | 617 // Computed as variables are declared. |
615 int num_var_or_const_; | 618 int num_var_or_const_; |
616 | 619 |
617 // Computed via AllocateVariables; function, block and catch scopes only. | 620 // Computed via AllocateVariables; function, block and catch scopes only. |
618 int num_stack_slots_; | 621 int num_stack_slots_; |
619 int num_heap_slots_; | 622 int num_heap_slots_; |
| 623 int num_global_slots_; |
620 | 624 |
621 // The number of modules (including nested ones). | 625 // The number of modules (including nested ones). |
622 int num_modules_; | 626 int num_modules_; |
623 | 627 |
624 // For module scopes, the host scope's internal variable binding this module. | 628 // For module scopes, the host scope's internal variable binding this module. |
625 Variable* module_var_; | 629 Variable* module_var_; |
626 | 630 |
627 // Rest parameter | 631 // Rest parameter |
628 Variable* rest_parameter_; | 632 Variable* rest_parameter_; |
629 int rest_index_; | 633 int rest_index_; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 // Predicates. | 710 // Predicates. |
707 bool MustAllocate(Variable* var); | 711 bool MustAllocate(Variable* var); |
708 bool MustAllocateInContext(Variable* var); | 712 bool MustAllocateInContext(Variable* var); |
709 bool HasArgumentsParameter(Isolate* isolate); | 713 bool HasArgumentsParameter(Isolate* isolate); |
710 | 714 |
711 // Variable allocation. | 715 // Variable allocation. |
712 void AllocateStackSlot(Variable* var); | 716 void AllocateStackSlot(Variable* var); |
713 void AllocateHeapSlot(Variable* var); | 717 void AllocateHeapSlot(Variable* var); |
714 void AllocateParameterLocals(Isolate* isolate); | 718 void AllocateParameterLocals(Isolate* isolate); |
715 void AllocateNonParameterLocal(Isolate* isolate, Variable* var); | 719 void AllocateNonParameterLocal(Isolate* isolate, Variable* var); |
716 void AllocateNonParameterLocals(Isolate* isolate); | 720 void AllocateDeclaredGlobal(Isolate* isolate, Variable* var); |
| 721 void AllocateNonParameterLocalsAndDeclaredGlobals(Isolate* isolate); |
717 void AllocateVariablesRecursively(Isolate* isolate); | 722 void AllocateVariablesRecursively(Isolate* isolate); |
718 void AllocateParameter(Variable* var, int index); | 723 void AllocateParameter(Variable* var, int index); |
719 void AllocateReceiver(); | 724 void AllocateReceiver(); |
720 void AllocateModules(); | 725 void AllocateModules(); |
721 | 726 |
722 // Resolve and fill in the allocation information for all variables | 727 // Resolve and fill in the allocation information for all variables |
723 // in this scopes. Must be called *after* all scopes have been | 728 // in this scopes. Must be called *after* all scopes have been |
724 // processed (parsed) to ensure that unresolved variables can be | 729 // processed (parsed) to ensure that unresolved variables can be |
725 // resolved properly. | 730 // resolved properly. |
726 // | 731 // |
(...skipping 29 matching lines...) Expand all Loading... |
756 PendingCompilationErrorHandler pending_error_handler_; | 761 PendingCompilationErrorHandler pending_error_handler_; |
757 | 762 |
758 // For tracking which classes are declared consecutively. Needed for strong | 763 // For tracking which classes are declared consecutively. Needed for strong |
759 // mode. | 764 // mode. |
760 int class_declaration_group_start_; | 765 int class_declaration_group_start_; |
761 }; | 766 }; |
762 | 767 |
763 } } // namespace v8::internal | 768 } } // namespace v8::internal |
764 | 769 |
765 #endif // V8_SCOPES_H_ | 770 #endif // V8_SCOPES_H_ |
OLD | NEW |