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

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

Issue 2574753002: Disable lazy parsing inside eval (see bug). (Closed)
Patch Set: code review (adamk@) 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/bugs/bug-2728.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 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 1172
1173 bool Scope::AllowsLazyParsingWithoutUnresolvedVariables( 1173 bool Scope::AllowsLazyParsingWithoutUnresolvedVariables(
1174 const Scope* outer) const { 1174 const Scope* outer) const {
1175 // If none of the outer scopes need to decide whether to context allocate 1175 // If none of the outer scopes need to decide whether to context allocate
1176 // specific variables, we can preparse inner functions without unresolved 1176 // specific variables, we can preparse inner functions without unresolved
1177 // variables. Otherwise we need to find unresolved variables to force context 1177 // variables. Otherwise we need to find unresolved variables to force context
1178 // allocation of the matching declarations. We can stop at the outer scope for 1178 // allocation of the matching declarations. We can stop at the outer scope for
1179 // the parse, since context allocation of those variables is already 1179 // the parse, since context allocation of those variables is already
1180 // guaranteed to be correct. 1180 // guaranteed to be correct.
1181 for (const Scope* s = this; s != outer; s = s->outer_scope_) { 1181 for (const Scope* s = this; s != outer; s = s->outer_scope_) {
1182 // Eval forces context allocation on all outer scopes, so we don't need to 1182 if (s->is_eval_scope()) return false;
1183 // look at those scopes. Sloppy eval makes all top-level variables dynamic,
1184 // whereas strict-mode requires context allocation.
1185 if (s->is_eval_scope()) return !is_strict(s->language_mode());
1186 // Catch scopes force context allocation of all variables. 1183 // Catch scopes force context allocation of all variables.
1187 if (s->is_catch_scope()) continue; 1184 if (s->is_catch_scope()) continue;
1188 // With scopes do not introduce variables that need allocation. 1185 // With scopes do not introduce variables that need allocation.
1189 if (s->is_with_scope()) continue; 1186 if (s->is_with_scope()) continue;
1190 // If everything is guaranteed to be context allocated we can ignore the 1187 // If everything is guaranteed to be context allocated we can ignore the
1191 // scope. 1188 // scope.
1192 if (s->has_forced_context_allocation()) continue; 1189 if (s->has_forced_context_allocation()) continue;
1193 // Only block scopes and function scopes should disallow preparsing. 1190 // Only block scopes and function scopes should disallow preparsing.
1194 DCHECK(s->is_block_scope() || s->is_function_scope()); 1191 DCHECK(s->is_block_scope() || s->is_function_scope());
1195 return false; 1192 return false;
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
2103 Variable* function = 2100 Variable* function =
2104 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; 2101 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr;
2105 bool is_function_var_in_context = 2102 bool is_function_var_in_context =
2106 function != nullptr && function->IsContextSlot(); 2103 function != nullptr && function->IsContextSlot();
2107 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 2104 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
2108 (is_function_var_in_context ? 1 : 0); 2105 (is_function_var_in_context ? 1 : 0);
2109 } 2106 }
2110 2107
2111 } // namespace internal 2108 } // namespace internal
2112 } // namespace v8 2109 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/bugs/bug-2728.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698