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

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

Issue 2666053003: [scopes]: With --print-scopes, print preparsed scopes before destroying them. (Closed)
Patch Set: Created 3 years, 10 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 | no next file » | 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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 // Ensuring that the outer script scope has a scope info avoids having 620 // Ensuring that the outer script scope has a scope info avoids having
621 // special case for native contexts vs other contexts. 621 // special case for native contexts vs other contexts.
622 if (info->script_scope()->scope_info_.is_null()) { 622 if (info->script_scope()->scope_info_.is_null()) {
623 info->script_scope()->scope_info_ = 623 info->script_scope()->scope_info_ =
624 handle(ScopeInfo::Empty(info->isolate())); 624 handle(ScopeInfo::Empty(info->isolate()));
625 } 625 }
626 626
627 #ifdef DEBUG 627 #ifdef DEBUG
628 if (info->script_is_native() ? FLAG_print_builtin_scopes 628 if (info->script_is_native() ? FLAG_print_builtin_scopes
629 : FLAG_print_scopes) { 629 : FLAG_print_scopes) {
630 PrintF("Global scope:\n");
630 scope->Print(); 631 scope->Print();
631 } 632 }
632 scope->CheckScopePositions(); 633 scope->CheckScopePositions();
633 scope->CheckZones(); 634 scope->CheckZones();
634 #endif 635 #endif
635 } 636 }
636 637
637 void DeclarationScope::DeclareThis(AstValueFactory* ast_value_factory) { 638 void DeclarationScope::DeclareThis(AstValueFactory* ast_value_factory) {
638 DCHECK(!already_resolved_); 639 DCHECK(!already_resolved_);
639 DCHECK(is_declaration_scope()); 640 DCHECK(is_declaration_scope());
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 arguments_ = nullptr; 1418 arguments_ = nullptr;
1418 } 1419 }
1419 1420
1420 if (FLAG_preparser_scope_analysis) { 1421 if (FLAG_preparser_scope_analysis) {
1421 // Decide context allocation for the locals and parameters and store the 1422 // Decide context allocation for the locals and parameters and store the
1422 // info away. 1423 // info away.
1423 AllocateVariablesRecursively(); 1424 AllocateVariablesRecursively();
1424 CollectVariableData(preparsed_scope_data); 1425 CollectVariableData(preparsed_scope_data);
1425 } 1426 }
1426 } 1427 }
1428 #ifdef DEBUG
1429 if (FLAG_print_scopes) {
1430 PrintF("Inner function scope:\n");
1431 Print();
1432 }
1433 #endif
1427 1434
1428 ResetAfterPreparsing(ast_node_factory->ast_value_factory(), false); 1435 ResetAfterPreparsing(ast_node_factory->ast_value_factory(), false);
1429 1436
1430 unresolved_ = unresolved; 1437 unresolved_ = unresolved;
1431 } 1438 }
1432 1439
1433 #ifdef DEBUG 1440 #ifdef DEBUG
1434 namespace { 1441 namespace {
1435 1442
1436 const char* Header(ScopeType scope_type, FunctionKind function_kind, 1443 const char* Header(ScopeType scope_type, FunctionKind function_kind,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 } 1509 }
1503 PrintF("\n"); 1510 PrintF("\n");
1504 } 1511 }
1505 1512
1506 void PrintMap(int indent, const char* label, VariableMap* map, bool locals, 1513 void PrintMap(int indent, const char* label, VariableMap* map, bool locals,
1507 Variable* function_var) { 1514 Variable* function_var) {
1508 bool printed_label = false; 1515 bool printed_label = false;
1509 for (VariableMap::Entry* p = map->Start(); p != nullptr; p = map->Next(p)) { 1516 for (VariableMap::Entry* p = map->Start(); p != nullptr; p = map->Next(p)) {
1510 Variable* var = reinterpret_cast<Variable*>(p->value); 1517 Variable* var = reinterpret_cast<Variable*>(p->value);
1511 if (var == function_var) continue; 1518 if (var == function_var) continue;
1519 if (var == kDummyPreParserVariable ||
1520 var == kDummyPreParserLexicalVariable) {
1521 continue;
1522 }
1512 bool local = !IsDynamicVariableMode(var->mode()); 1523 bool local = !IsDynamicVariableMode(var->mode());
1513 if ((locals ? local : !local) && 1524 if ((locals ? local : !local) &&
1514 (var->is_used() || !var->IsUnallocated())) { 1525 (var->is_used() || !var->IsUnallocated())) {
1515 if (!printed_label) { 1526 if (!printed_label) {
1516 Indent(indent, label); 1527 Indent(indent, label);
1517 printed_label = true; 1528 printed_label = true;
1518 } 1529 }
1519 PrintVar(indent, var); 1530 PrintVar(indent, var);
1520 } 1531 }
1521 } 1532 }
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
2207 Variable* function = 2218 Variable* function =
2208 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; 2219 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr;
2209 bool is_function_var_in_context = 2220 bool is_function_var_in_context =
2210 function != nullptr && function->IsContextSlot(); 2221 function != nullptr && function->IsContextSlot();
2211 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 2222 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
2212 (is_function_var_in_context ? 1 : 0); 2223 (is_function_var_in_context ? 1 : 0);
2213 } 2224 }
2214 2225
2215 } // namespace internal 2226 } // namespace internal
2216 } // namespace v8 2227 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698