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

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

Issue 2551023004: [ignition] Fix hole check for dynamic local variables (Closed)
Patch Set: Add a DCHECK and a comment Created 4 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 | « no previous file | test/mjsunit/regress/regress-crbug-669540.js » ('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 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 void Scope::ResolveVariable(ParseInfo* info, VariableProxy* proxy) { 1700 void Scope::ResolveVariable(ParseInfo* info, VariableProxy* proxy) {
1701 DCHECK(info->script_scope()->is_script_scope()); 1701 DCHECK(info->script_scope()->is_script_scope());
1702 DCHECK(!proxy->is_resolved()); 1702 DCHECK(!proxy->is_resolved());
1703 Variable* var = LookupRecursive(proxy, nullptr); 1703 Variable* var = LookupRecursive(proxy, nullptr);
1704 ResolveTo(info, proxy, var); 1704 ResolveTo(info, proxy, var);
1705 } 1705 }
1706 1706
1707 namespace { 1707 namespace {
1708 1708
1709 bool AccessNeedsHoleCheck(Variable* var, VariableProxy* proxy, Scope* scope) { 1709 bool AccessNeedsHoleCheck(Variable* var, VariableProxy* proxy, Scope* scope) {
1710 if (var->mode() == DYNAMIC_LOCAL) {
1711 // Dynamically introduced variables never need a hole check (since they're
1712 // VAR bindings, either from var or function declarations), but the variable
1713 // they shadow might need a hole check, which we want to do if we decide
1714 // that no shadowing variable was dynamically introoduced.
1715 DCHECK(!var->binding_needs_init());
1716 return AccessNeedsHoleCheck(var->local_if_not_shadowed(), proxy, scope);
1717 }
1718
1710 if (!var->binding_needs_init()) { 1719 if (!var->binding_needs_init()) {
1711 return false; 1720 return false;
1712 } 1721 }
1713 1722
1714 // It's impossible to eliminate module import hole checks here, because it's 1723 // It's impossible to eliminate module import hole checks here, because it's
1715 // unknown at compilation time whether the binding referred to in the 1724 // unknown at compilation time whether the binding referred to in the
1716 // exporting module itself requires hole checks. 1725 // exporting module itself requires hole checks.
1717 if (var->location() == VariableLocation::MODULE && !var->IsExport()) { 1726 if (var->location() == VariableLocation::MODULE && !var->IsExport()) {
1718 return true; 1727 return true;
1719 } 1728 }
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
2120 Variable* function = 2129 Variable* function =
2121 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; 2130 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr;
2122 bool is_function_var_in_context = 2131 bool is_function_var_in_context =
2123 function != nullptr && function->IsContextSlot(); 2132 function != nullptr && function->IsContextSlot();
2124 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 2133 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
2125 (is_function_var_in_context ? 1 : 0); 2134 (is_function_var_in_context ? 1 : 0);
2126 } 2135 }
2127 2136
2128 } // namespace internal 2137 } // namespace internal
2129 } // namespace v8 2138 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-669540.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698