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

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

Issue 2521513004: Preparse inner functions: fix maybe_assigned (Closed)
Patch Set: even better 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/parsing/preparser.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 <set> 7 #include <set>
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/ast/ast.h" 10 #include "src/ast/ast.h"
(...skipping 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 } 1605 }
1606 1606
1607 return var; 1607 return var;
1608 } 1608 }
1609 1609
1610 void Scope::ResolveVariable(ParseInfo* info, VariableProxy* proxy) { 1610 void Scope::ResolveVariable(ParseInfo* info, VariableProxy* proxy) {
1611 DCHECK(info->script_scope()->is_script_scope()); 1611 DCHECK(info->script_scope()->is_script_scope());
1612 DCHECK(!proxy->is_resolved()); 1612 DCHECK(!proxy->is_resolved());
1613 Variable* var = LookupRecursive(proxy, nullptr); 1613 Variable* var = LookupRecursive(proxy, nullptr);
1614 ResolveTo(info, proxy, var); 1614 ResolveTo(info, proxy, var);
1615
1616 if (FLAG_lazy_inner_functions) {
1617 if (info != nullptr && info->is_native()) return;
1618 // Pessimistically force context allocation for all variables to which inner
1619 // scope variables could potentially resolve to.
1620 Scope* scope = GetClosureScope()->outer_scope_;
1621 while (scope != nullptr && scope->scope_info_.is_null()) {
1622 var = scope->LookupLocal(proxy->raw_name());
1623 if (var != nullptr) {
1624 // Since we don't lazy parse inner arrow functions, inner functions
1625 // cannot refer to the outer "this".
1626 if (!var->is_dynamic() && !var->is_this() &&
1627 !var->has_forced_context_allocation()) {
1628 var->ForceContextAllocation();
1629 var->set_is_used();
1630 // We don't know what the (potentially lazy parsed) inner function
1631 // does with the variable; pessimistically assume that it's assigned.
1632 var->set_maybe_assigned();
1633 }
1634 }
1635 scope = scope->outer_scope_;
1636 }
1637 }
1638 } 1615 }
1639 1616
1640 namespace { 1617 namespace {
1641 1618
1642 bool AccessNeedsHoleCheck(Variable* var, VariableProxy* proxy, Scope* scope) { 1619 bool AccessNeedsHoleCheck(Variable* var, VariableProxy* proxy, Scope* scope) {
1643 if (!var->binding_needs_init()) { 1620 if (!var->binding_needs_init()) {
1644 return false; 1621 return false;
1645 } 1622 }
1646 1623
1647 // It's impossible to eliminate module import hole checks here, because it's 1624 // It's impossible to eliminate module import hole checks here, because it's
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
2027 Variable* function = 2004 Variable* function =
2028 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; 2005 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr;
2029 bool is_function_var_in_context = 2006 bool is_function_var_in_context =
2030 function != nullptr && function->IsContextSlot(); 2007 function != nullptr && function->IsContextSlot();
2031 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 2008 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
2032 (is_function_var_in_context ? 1 : 0); 2009 (is_function_var_in_context ? 1 : 0);
2033 } 2010 }
2034 2011
2035 } // namespace internal 2012 } // namespace internal
2036 } // namespace v8 2013 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/parsing/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698