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

Side by Side Diff: src/scopes.h

Issue 1218783005: Support for global var shortcuts in script contexts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 months 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
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_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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 } 442 }
443 443
444 // --------------------------------------------------------------------------- 444 // ---------------------------------------------------------------------------
445 // Variable allocation. 445 // Variable allocation.
446 446
447 // Collect stack and context allocated local variables in this scope. Note 447 // Collect stack and context allocated local variables in this scope. Note
448 // that the function variable - if present - is not collected and should be 448 // that the function variable - if present - is not collected and should be
449 // handled separately. 449 // handled separately.
450 void CollectStackAndContextLocals( 450 void CollectStackAndContextLocals(
451 ZoneList<Variable*>* stack_locals, ZoneList<Variable*>* context_locals, 451 ZoneList<Variable*>* stack_locals, ZoneList<Variable*>* context_locals,
452 ZoneList<Variable*>* context_globals,
452 ZoneList<Variable*>* strong_mode_free_variables = nullptr); 453 ZoneList<Variable*>* strong_mode_free_variables = nullptr);
453 454
454 // Current number of var or const locals. 455 // Current number of var or const locals.
455 int num_var_or_const() { return num_var_or_const_; } 456 int num_var_or_const() { return num_var_or_const_; }
456 457
457 // Result of variable allocation. 458 // Result of variable allocation.
458 int num_stack_slots() const { return num_stack_slots_; } 459 int num_stack_slots() const { return num_stack_slots_; }
459 int num_heap_slots() const { return num_heap_slots_; } 460 int num_heap_slots() const { return num_heap_slots_; }
461 int num_global_slots() const { return num_global_slots_; }
460 462
461 int StackLocalCount() const; 463 int StackLocalCount() const;
462 int ContextLocalCount() const; 464 int ContextLocalCount() const;
465 int ContextGlobalCount() const;
463 466
464 // For script scopes, the number of module literals (including nested ones). 467 // For script scopes, the number of module literals (including nested ones).
465 int num_modules() const { return num_modules_; } 468 int num_modules() const { return num_modules_; }
466 469
467 // For module scopes, the host scope's internal variable binding this module. 470 // For module scopes, the host scope's internal variable binding this module.
468 Variable* module_var() const { return module_var_; } 471 Variable* module_var() const { return module_var_; }
469 472
470 // Make sure this scope and all outer scopes are eagerly compiled. 473 // Make sure this scope and all outer scopes are eagerly compiled.
471 void ForceEagerCompilation() { force_eager_compilation_ = true; } 474 void ForceEagerCompilation() { force_eager_compilation_ = true; }
472 475
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 // True if it doesn't need scope resolution (e.g., if the scope was 622 // True if it doesn't need scope resolution (e.g., if the scope was
620 // constructed based on a serialized scope info or a catch context). 623 // constructed based on a serialized scope info or a catch context).
621 bool already_resolved_; 624 bool already_resolved_;
622 625
623 // Computed as variables are declared. 626 // Computed as variables are declared.
624 int num_var_or_const_; 627 int num_var_or_const_;
625 628
626 // Computed via AllocateVariables; function, block and catch scopes only. 629 // Computed via AllocateVariables; function, block and catch scopes only.
627 int num_stack_slots_; 630 int num_stack_slots_;
628 int num_heap_slots_; 631 int num_heap_slots_;
632 int num_global_slots_;
629 633
630 // The number of modules (including nested ones). 634 // The number of modules (including nested ones).
631 int num_modules_; 635 int num_modules_;
632 636
633 // For module scopes, the host scope's internal variable binding this module. 637 // For module scopes, the host scope's internal variable binding this module.
634 Variable* module_var_; 638 Variable* module_var_;
635 639
636 // Rest parameter 640 // Rest parameter
637 Variable* rest_parameter_; 641 Variable* rest_parameter_;
638 int rest_index_; 642 int rest_index_;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 // Predicates. 719 // Predicates.
716 bool MustAllocate(Variable* var); 720 bool MustAllocate(Variable* var);
717 bool MustAllocateInContext(Variable* var); 721 bool MustAllocateInContext(Variable* var);
718 bool HasArgumentsParameter(Isolate* isolate); 722 bool HasArgumentsParameter(Isolate* isolate);
719 723
720 // Variable allocation. 724 // Variable allocation.
721 void AllocateStackSlot(Variable* var); 725 void AllocateStackSlot(Variable* var);
722 void AllocateHeapSlot(Variable* var); 726 void AllocateHeapSlot(Variable* var);
723 void AllocateParameterLocals(Isolate* isolate); 727 void AllocateParameterLocals(Isolate* isolate);
724 void AllocateNonParameterLocal(Isolate* isolate, Variable* var); 728 void AllocateNonParameterLocal(Isolate* isolate, Variable* var);
725 void AllocateNonParameterLocals(Isolate* isolate); 729 void AllocateDeclaredGlobal(Isolate* isolate, Variable* var);
730 void AllocateNonParameterLocalsAndDeclaredGlobals(Isolate* isolate);
726 void AllocateVariablesRecursively(Isolate* isolate); 731 void AllocateVariablesRecursively(Isolate* isolate);
727 void AllocateParameter(Variable* var, int index); 732 void AllocateParameter(Variable* var, int index);
728 void AllocateReceiver(); 733 void AllocateReceiver();
729 void AllocateModules(); 734 void AllocateModules();
730 735
731 // Resolve and fill in the allocation information for all variables 736 // Resolve and fill in the allocation information for all variables
732 // in this scopes. Must be called *after* all scopes have been 737 // in this scopes. Must be called *after* all scopes have been
733 // processed (parsed) to ensure that unresolved variables can be 738 // processed (parsed) to ensure that unresolved variables can be
734 // resolved properly. 739 // resolved properly.
735 // 740 //
(...skipping 29 matching lines...) Expand all
765 PendingCompilationErrorHandler pending_error_handler_; 770 PendingCompilationErrorHandler pending_error_handler_;
766 771
767 // For tracking which classes are declared consecutively. Needed for strong 772 // For tracking which classes are declared consecutively. Needed for strong
768 // mode. 773 // mode.
769 int class_declaration_group_start_; 774 int class_declaration_group_start_;
770 }; 775 };
771 776
772 } } // namespace v8::internal 777 } } // namespace v8::internal
773 778
774 #endif // V8_SCOPES_H_ 779 #endif // V8_SCOPES_H_
OLDNEW
« src/runtime/runtime-scopes.cc ('K') | « src/scopeinfo.cc ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698