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

Unified Diff: src/ast/scopes.cc

Issue 2521513004: Preparse inner functions: fix maybe_assigned (Closed)
Patch Set: less pessimistic Created 4 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.cc
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index c150336668545eb1a8bf78b3af3823f70bb476c1..06a11f3eef1bb79fa538db2399da204effcdc8e4 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -1613,26 +1613,15 @@ void Scope::ResolveVariable(ParseInfo* info, VariableProxy* proxy) {
Variable* var = LookupRecursive(proxy, nullptr);
ResolveTo(info, proxy, var);
- if (FLAG_lazy_inner_functions) {
- if (info != nullptr && info->is_native()) return;
- // Pessimistically force context allocation for all variables to which inner
- // scope variables could potentially resolve to.
- Scope* scope = GetClosureScope()->outer_scope_;
- while (scope != nullptr && scope->scope_info_.is_null()) {
- var = scope->LookupLocal(proxy->raw_name());
- if (var != nullptr) {
- // Since we don't lazy parse inner arrow functions, inner functions
- // cannot refer to the outer "this".
- if (!var->is_dynamic() && !var->is_this() &&
- !var->has_forced_context_allocation()) {
- var->ForceContextAllocation();
- var->set_is_used();
- // We don't know what the (potentially lazy parsed) inner function
- // does with the variable; pessimistically assume that it's assigned.
- var->set_maybe_assigned();
- }
- }
- scope = scope->outer_scope_;
+ // Pessimistically set is_used and maybe_assigned for variables which lazy
+ // parsed inner functions refer to.
+ if (FLAG_lazy_inner_functions && is_declaration_scope() &&
+ AsDeclarationScope()->is_lazily_parsed()) {
+ // Since we don't lazy parse inner arrow functions, inner functions
+ // cannot refer to the outer "this".
+ if (!var->is_dynamic() && !var->is_this()) {
+ var->set_is_used();
+ var->set_maybe_assigned();
Toon Verwaest 2016/11/22 13:11:42 I don't think we need to set is_used here, since R
}
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698