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

Side by Side Diff: src/ast/scopes.cc

Issue 1485053002: [cleanup] Remove modules-related cruft from Scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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 | « src/ast/scopes.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
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 #include "src/ast/scopes.h" 5 #include "src/ast/scopes.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/ast/scopeinfo.h" 8 #include "src/ast/scopeinfo.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 outer_scope_calls_sloppy_eval_ = false; 195 outer_scope_calls_sloppy_eval_ = false;
196 inner_scope_calls_eval_ = false; 196 inner_scope_calls_eval_ = false;
197 scope_nonlinear_ = false; 197 scope_nonlinear_ = false;
198 force_eager_compilation_ = false; 198 force_eager_compilation_ = false;
199 force_context_allocation_ = (outer_scope != NULL && !is_function_scope()) 199 force_context_allocation_ = (outer_scope != NULL && !is_function_scope())
200 ? outer_scope->has_forced_context_allocation() : false; 200 ? outer_scope->has_forced_context_allocation() : false;
201 num_var_or_const_ = 0; 201 num_var_or_const_ = 0;
202 num_stack_slots_ = 0; 202 num_stack_slots_ = 0;
203 num_heap_slots_ = 0; 203 num_heap_slots_ = 0;
204 num_global_slots_ = 0; 204 num_global_slots_ = 0;
205 num_modules_ = 0;
206 module_var_ = NULL;
207 arity_ = 0; 205 arity_ = 0;
208 has_simple_parameters_ = true; 206 has_simple_parameters_ = true;
209 rest_parameter_ = NULL; 207 rest_parameter_ = NULL;
210 rest_index_ = -1; 208 rest_index_ = -1;
211 scope_info_ = scope_info; 209 scope_info_ = scope_info;
212 start_position_ = RelocInfo::kNoPosition; 210 start_position_ = RelocInfo::kNoPosition;
213 end_position_ = RelocInfo::kNoPosition; 211 end_position_ = RelocInfo::kNoPosition;
214 if (!scope_info.is_null()) { 212 if (!scope_info.is_null()) {
215 scope_calls_eval_ = scope_info->CallsEval(); 213 scope_calls_eval_ = scope_info->CallsEval();
216 language_mode_ = scope_info->language_mode(); 214 language_mode_ = scope_info->language_mode();
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 bool Scope::AllocateVariables(ParseInfo* info, AstNodeFactory* factory) { 709 bool Scope::AllocateVariables(ParseInfo* info, AstNodeFactory* factory) {
712 // 1) Propagate scope information. 710 // 1) Propagate scope information.
713 bool outer_scope_calls_sloppy_eval = false; 711 bool outer_scope_calls_sloppy_eval = false;
714 if (outer_scope_ != NULL) { 712 if (outer_scope_ != NULL) {
715 outer_scope_calls_sloppy_eval = 713 outer_scope_calls_sloppy_eval =
716 outer_scope_->outer_scope_calls_sloppy_eval() | 714 outer_scope_->outer_scope_calls_sloppy_eval() |
717 outer_scope_->calls_sloppy_eval(); 715 outer_scope_->calls_sloppy_eval();
718 } 716 }
719 PropagateScopeInfo(outer_scope_calls_sloppy_eval); 717 PropagateScopeInfo(outer_scope_calls_sloppy_eval);
720 718
721 // 2) Allocate module instances. 719 // 2) Resolve variables.
722 if (FLAG_harmony_modules && is_script_scope()) {
723 DCHECK(num_modules_ == 0);
724 AllocateModules();
725 }
726
727 // 3) Resolve variables.
728 if (!ResolveVariablesRecursively(info, factory)) return false; 720 if (!ResolveVariablesRecursively(info, factory)) return false;
729 721
730 // 4) Allocate variables. 722 // 3) Allocate variables.
731 AllocateVariablesRecursively(info->isolate()); 723 AllocateVariablesRecursively(info->isolate());
732 724
733 return true; 725 return true;
734 } 726 }
735 727
736 728
737 bool Scope::HasTrivialContext() const { 729 bool Scope::HasTrivialContext() const {
738 // A function scope has a trivial context if it always is the global 730 // A function scope has a trivial context if it always is the global
739 // context. We iteratively scan out the context chain to see if 731 // context. We iteratively scan out the context chain to see if
740 // there is anything that makes this scope non-trivial; otherwise we 732 // there is anything that makes this scope non-trivial; otherwise we
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 // need the minimal number of slots if we must have a context. 1621 // need the minimal number of slots if we must have a context.
1630 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && !must_have_context) { 1622 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && !must_have_context) {
1631 num_heap_slots_ = 0; 1623 num_heap_slots_ = 0;
1632 } 1624 }
1633 1625
1634 // Allocation done. 1626 // Allocation done.
1635 DCHECK(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); 1627 DCHECK(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS);
1636 } 1628 }
1637 1629
1638 1630
1639 void Scope::AllocateModules() {
1640 DCHECK(is_script_scope());
1641 DCHECK(!already_resolved());
1642 for (int i = 0; i < inner_scopes_.length(); i++) {
1643 Scope* scope = inner_scopes_.at(i);
1644 if (scope->is_module_scope()) {
1645 DCHECK(!scope->already_resolved());
1646 DCHECK(scope->module_descriptor_->IsFrozen());
1647 DCHECK_NULL(scope->module_var_);
1648 scope->module_var_ =
1649 NewTemporary(ast_value_factory_->dot_module_string());
1650 ++num_modules_;
1651 }
1652 }
1653 }
1654
1655
1656 int Scope::StackLocalCount() const { 1631 int Scope::StackLocalCount() const {
1657 return num_stack_slots() - 1632 return num_stack_slots() -
1658 (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0); 1633 (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0);
1659 } 1634 }
1660 1635
1661 1636
1662 int Scope::ContextLocalCount() const { 1637 int Scope::ContextLocalCount() const {
1663 if (num_heap_slots() == 0) return 0; 1638 if (num_heap_slots() == 0) return 0;
1664 bool is_function_var_in_context = 1639 bool is_function_var_in_context =
1665 function_ != NULL && function_->proxy()->var()->IsContextSlot(); 1640 function_ != NULL && function_->proxy()->var()->IsContextSlot();
1666 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - 1641 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() -
1667 (is_function_var_in_context ? 1 : 0); 1642 (is_function_var_in_context ? 1 : 0);
1668 } 1643 }
1669 1644
1670 1645
1671 int Scope::ContextGlobalCount() const { return num_global_slots(); } 1646 int Scope::ContextGlobalCount() const { return num_global_slots(); }
1672 1647
1673 } // namespace internal 1648 } // namespace internal
1674 } // namespace v8 1649 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/scopes.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698