Chromium Code Reviews

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

Issue 2656753003: [ast/parsing] Pessimistically assume all top-level variables will be assigned. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 1801 matching lines...)
1812 } 1812 }
1813 VariableLocation location = var->location(); 1813 VariableLocation location = var->location();
1814 CHECK(location == VariableLocation::LOCAL || 1814 CHECK(location == VariableLocation::LOCAL ||
1815 location == VariableLocation::CONTEXT || 1815 location == VariableLocation::CONTEXT ||
1816 location == VariableLocation::PARAMETER || 1816 location == VariableLocation::PARAMETER ||
1817 location == VariableLocation::UNALLOCATED); 1817 location == VariableLocation::UNALLOCATED);
1818 } 1818 }
1819 #endif 1819 #endif
1820 1820
1821 DCHECK_NOT_NULL(var); 1821 DCHECK_NOT_NULL(var);
1822 if (proxy->is_assigned()) var->set_maybe_assigned();
1823 if (AccessNeedsHoleCheck(var, proxy, this)) proxy->set_needs_hole_check(); 1822 if (AccessNeedsHoleCheck(var, proxy, this)) proxy->set_needs_hole_check();
1824 proxy->BindTo(var); 1823 proxy->BindTo(var);
1825 } 1824 }
1826 1825
1827 void Scope::ResolveVariablesRecursively(ParseInfo* info) { 1826 void Scope::ResolveVariablesRecursively(ParseInfo* info) {
1828 DCHECK(info->script_scope()->is_script_scope()); 1827 DCHECK(info->script_scope()->is_script_scope());
1829 // Lazy parsed declaration scopes are already partially analyzed. If there are 1828 // Lazy parsed declaration scopes are already partially analyzed. If there are
1830 // unresolved references remaining, they just need to be resolved in outer 1829 // unresolved references remaining, they just need to be resolved in outer
1831 // scopes. 1830 // scopes.
1832 if (is_declaration_scope() && AsDeclarationScope()->was_lazily_parsed()) { 1831 if (is_declaration_scope() && AsDeclarationScope()->was_lazily_parsed()) {
(...skipping 331 matching lines...)
2164 Variable* function = 2163 Variable* function =
2165 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; 2164 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr;
2166 bool is_function_var_in_context = 2165 bool is_function_var_in_context =
2167 function != nullptr && function->IsContextSlot(); 2166 function != nullptr && function->IsContextSlot();
2168 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 2167 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
2169 (is_function_var_in_context ? 1 : 0); 2168 (is_function_var_in_context ? 1 : 0);
2170 } 2169 }
2171 2170
2172 } // namespace internal 2171 } // namespace internal
2173 } // namespace v8 2172 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast.cc ('k') | src/parsing/parser.h » ('j') | src/parsing/parser.h » ('J')

Powered by Google App Engine