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

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

Issue 2472063002: Preparse lazy function parameters (Closed)
Patch Set: IsArrowFunction Created 4 years, 1 month 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 | src/ast/variables.h » ('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 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 non_locals = StringSet::Add(non_locals, proxy->name()); 1245 non_locals = StringSet::Add(non_locals, proxy->name());
1246 } 1246 }
1247 return non_locals; 1247 return non_locals;
1248 } 1248 }
1249 1249
1250 void DeclarationScope::ResetAfterPreparsing(AstValueFactory* ast_value_factory, 1250 void DeclarationScope::ResetAfterPreparsing(AstValueFactory* ast_value_factory,
1251 bool aborted) { 1251 bool aborted) {
1252 DCHECK(is_function_scope()); 1252 DCHECK(is_function_scope());
1253 1253
1254 // Reset all non-trivial members. 1254 // Reset all non-trivial members.
1255 params_.Clear();
1255 decls_.Clear(); 1256 decls_.Clear();
1256 locals_.Clear(); 1257 locals_.Clear();
1257 sloppy_block_function_map_.Clear(); 1258 sloppy_block_function_map_.Clear();
1258 variables_.Clear(); 1259 variables_.Clear();
1259 // Make sure we won't walk the scope tree from here on. 1260 // Make sure we won't walk the scope tree from here on.
1260 inner_scope_ = nullptr; 1261 inner_scope_ = nullptr;
1261 unresolved_ = nullptr; 1262 unresolved_ = nullptr;
1262 1263
1263 // TODO(verwaest): We should properly preparse the parameters (no declarations 1264 if (aborted && !IsArrowFunction(function_kind_)) {
1264 // should be created), and reparse on abort. 1265 DeclareDefaultFunctionVariables(ast_value_factory);
1265 if (aborted) {
1266 if (!IsArrowFunction(function_kind_)) {
1267 DeclareDefaultFunctionVariables(ast_value_factory);
1268 }
1269 // Recreate declarations for parameters.
1270 for (int i = 0; i < params_.length(); i++) {
1271 Variable* var = params_[i];
1272 if (var->mode() == TEMPORARY) {
1273 // TODO(verwaest): Remove and unfriend DeclarationScope from Variable.
1274 *var->next() = nullptr;
1275 locals_.Add(var);
1276 } else if (variables_.Lookup(var->raw_name()) == nullptr) {
1277 // TODO(verwaest): Remove and unfriend DeclarationScope from Variable.
1278 *var->next() = nullptr;
1279 variables_.Add(zone(), var);
1280 locals_.Add(var);
1281 }
1282 }
1283 } else {
1284 params_.Rewind(0);
1285 } 1266 }
1286 1267
1287 #ifdef DEBUG 1268 #ifdef DEBUG
1288 needs_migration_ = false; 1269 needs_migration_ = false;
1289 #endif 1270 #endif
1290 1271
1291 is_lazily_parsed_ = !aborted; 1272 is_lazily_parsed_ = !aborted;
1292 } 1273 }
1293 1274
1294 void DeclarationScope::AnalyzePartially(AstNodeFactory* ast_node_factory) { 1275 void DeclarationScope::AnalyzePartially(AstNodeFactory* ast_node_factory) {
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
2036 Variable* function = 2017 Variable* function =
2037 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; 2018 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr;
2038 bool is_function_var_in_context = 2019 bool is_function_var_in_context =
2039 function != nullptr && function->IsContextSlot(); 2020 function != nullptr && function->IsContextSlot();
2040 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 2021 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
2041 (is_function_var_in_context ? 1 : 0); 2022 (is_function_var_in_context ? 1 : 0);
2042 } 2023 }
2043 2024
2044 } // namespace internal 2025 } // namespace internal
2045 } // namespace v8 2026 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/ast/variables.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698