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

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

Issue 1950803002: Don't treat catch scopes as possibly-shadowing for sloppy eval (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Amend comment Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-608279.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 "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/ast/scopeinfo.h" 8 #include "src/ast/scopeinfo.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 DCHECK(!already_resolved()); 1091 DCHECK(!already_resolved());
1092 // The current scope is a with scope, so the variable binding can not be 1092 // The current scope is a with scope, so the variable binding can not be
1093 // statically resolved. However, note that it was necessary to do a lookup 1093 // statically resolved. However, note that it was necessary to do a lookup
1094 // in the outer scope anyway, because if a binding exists in an outer scope, 1094 // in the outer scope anyway, because if a binding exists in an outer scope,
1095 // the associated variable has to be marked as potentially being accessed 1095 // the associated variable has to be marked as potentially being accessed
1096 // from inside of an inner with scope (the property may not be in the 'with' 1096 // from inside of an inner with scope (the property may not be in the 'with'
1097 // object). 1097 // object).
1098 if (var != NULL && proxy->is_assigned()) var->set_maybe_assigned(); 1098 if (var != NULL && proxy->is_assigned()) var->set_maybe_assigned();
1099 *binding_kind = DYNAMIC_LOOKUP; 1099 *binding_kind = DYNAMIC_LOOKUP;
1100 return NULL; 1100 return NULL;
1101 } else if (calls_sloppy_eval() && !is_script_scope() && 1101 } else if (calls_sloppy_eval() && is_declaration_scope() &&
1102 name_can_be_shadowed) { 1102 !is_script_scope() && name_can_be_shadowed) {
1103 // A variable binding may have been found in an outer scope, but the current 1103 // A variable binding may have been found in an outer scope, but the current
1104 // scope makes a sloppy 'eval' call, so the found variable may not be 1104 // scope makes a sloppy 'eval' call, so the found variable may not be
1105 // the correct one (the 'eval' may introduce a binding with the same name). 1105 // the correct one (the 'eval' may introduce a binding with the same name).
1106 // In that case, change the lookup result to reflect this situation. 1106 // In that case, change the lookup result to reflect this situation.
1107 // Only scopes that can host var bindings (declaration scopes) need be
1108 // considered here (this excludes block and catch scopes), and variable
1109 // lookups at script scope are always dynamic.
1107 if (*binding_kind == BOUND) { 1110 if (*binding_kind == BOUND) {
1108 *binding_kind = BOUND_EVAL_SHADOWED; 1111 *binding_kind = BOUND_EVAL_SHADOWED;
1109 } else if (*binding_kind == UNBOUND) { 1112 } else if (*binding_kind == UNBOUND) {
1110 *binding_kind = UNBOUND_EVAL_SHADOWED; 1113 *binding_kind = UNBOUND_EVAL_SHADOWED;
1111 } 1114 }
1112 } 1115 }
1113 return var; 1116 return var;
1114 } 1117 }
1115 1118
1116 1119
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 function_ != NULL && function_->proxy()->var()->IsContextSlot(); 1517 function_ != NULL && function_->proxy()->var()->IsContextSlot();
1515 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - 1518 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() -
1516 (is_function_var_in_context ? 1 : 0); 1519 (is_function_var_in_context ? 1 : 0);
1517 } 1520 }
1518 1521
1519 1522
1520 int Scope::ContextGlobalCount() const { return num_global_slots(); } 1523 int Scope::ContextGlobalCount() const { return num_global_slots(); }
1521 1524
1522 } // namespace internal 1525 } // namespace internal
1523 } // namespace v8 1526 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-608279.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698