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

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

Issue 2353623002: Filter out synthetic variables from with scopes (Closed)
Patch Set: Fix whitespace Created 4 years, 3 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
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 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 1441
1442 // The variable could not be resolved statically. 1442 // The variable could not be resolved statically.
1443 if (var == nullptr) return var; 1443 if (var == nullptr) return var;
1444 1444
1445 if (is_function_scope() && !var->is_dynamic()) { 1445 if (is_function_scope() && !var->is_dynamic()) {
1446 var->ForceContextAllocation(); 1446 var->ForceContextAllocation();
1447 } 1447 }
1448 // "this" can't be shadowed by "eval"-introduced bindings or by "with" 1448 // "this" can't be shadowed by "eval"-introduced bindings or by "with"
1449 // scopes. 1449 // scopes.
1450 // TODO(wingo): There are other variables in this category; add them. 1450 // TODO(wingo): There are other variables in this category; add them.
1451 if (var->is_this()) return var; 1451 if (Scope::VariableIsSynthetic(var->raw_name())) return var;
Toon Verwaest 2016/09/19 20:01:50 I'd be much in favor of having specialized scope r
Dan Ehrenberg 2016/09/20 17:22:13 I looked into some ways to mitigate the performanc
1452 1452
1453 if (is_with_scope()) { 1453 if (is_with_scope()) {
1454 // The current scope is a with scope, so the variable binding can not be 1454 // The current scope is a with scope, so the variable binding can not be
1455 // statically resolved. However, note that it was necessary to do a lookup 1455 // statically resolved. However, note that it was necessary to do a lookup
1456 // in the outer scope anyway, because if a binding exists in an outer 1456 // in the outer scope anyway, because if a binding exists in an outer
1457 // scope, the associated variable has to be marked as potentially being 1457 // scope, the associated variable has to be marked as potentially being
1458 // accessed from inside of an inner with scope (the property may not be in 1458 // accessed from inside of an inner with scope (the property may not be in
1459 // the 'with' object). 1459 // the 'with' object).
1460 if (!var->is_dynamic() && var->IsUnallocated()) { 1460 if (!var->is_dynamic() && var->IsUnallocated()) {
1461 DCHECK(!already_resolved_); 1461 DCHECK(!already_resolved_);
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 Variable* function = 1812 Variable* function =
1813 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; 1813 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr;
1814 bool is_function_var_in_context = 1814 bool is_function_var_in_context =
1815 function != nullptr && function->IsContextSlot(); 1815 function != nullptr && function->IsContextSlot();
1816 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1816 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1817 (is_function_var_in_context ? 1 : 0); 1817 (is_function_var_in_context ? 1 : 0);
1818 } 1818 }
1819 1819
1820 } // namespace internal 1820 } // namespace internal
1821 } // namespace v8 1821 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698