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

Unified Diff: src/scopes.cc

Issue 999893003: Modules: simplify logic around allocation of module internal variables (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/scopes.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopes.cc
diff --git a/src/scopes.cc b/src/scopes.cc
index b8c357c47ec3ef30ea547493b60949aa93d9aaed..c744dd418bbaaca2b74567048f30ecf208274da3 100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -656,9 +656,9 @@ bool Scope::AllocateVariables(ParseInfo* info, AstNodeFactory* factory) {
PropagateScopeInfo(outer_scope_calls_sloppy_eval);
// 2) Allocate module instances.
- if (FLAG_harmony_modules && (is_script_scope() || is_module_scope())) {
+ if (FLAG_harmony_modules && is_script_scope()) {
DCHECK(num_modules_ == 0);
- AllocateModulesRecursively(this);
+ AllocateModules();
}
// 3) Resolve variables.
@@ -1437,19 +1437,18 @@ void Scope::AllocateVariablesRecursively(Isolate* isolate) {
}
-void Scope::AllocateModulesRecursively(Scope* host_scope) {
- if (already_resolved()) return;
- if (is_module_scope()) {
- DCHECK(module_descriptor_->IsFrozen());
- DCHECK(module_var_ == NULL);
- module_var_ =
- host_scope->NewInternal(ast_value_factory_->dot_module_string());
- ++host_scope->num_modules_;
- }
-
+void Scope::AllocateModules() {
+ DCHECK(is_script_scope());
+ DCHECK(!already_resolved());
for (int i = 0; i < inner_scopes_.length(); i++) {
- Scope* inner_scope = inner_scopes_.at(i);
- inner_scope->AllocateModulesRecursively(host_scope);
+ Scope* scope = inner_scopes_.at(i);
+ if (scope->is_module_scope()) {
+ DCHECK(!scope->already_resolved());
+ DCHECK(scope->module_descriptor_->IsFrozen());
+ DCHECK_NULL(scope->module_var_);
+ scope->module_var_ = NewInternal(ast_value_factory_->dot_module_string());
+ ++num_modules_;
+ }
}
}
« no previous file with comments | « src/scopes.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698