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

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

Issue 2551943003: Fix crash in --print-scopes when Scope::variables_ is empty (Closed)
Patch Set: Simplify 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 | 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 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 Indent(n1, "// "); 1501 Indent(n1, "// ");
1502 PrintF("%d heap slots\n", num_heap_slots_); 1502 PrintF("%d heap slots\n", num_heap_slots_);
1503 } 1503 }
1504 1504
1505 // Print locals. 1505 // Print locals.
1506 if (function != nullptr) { 1506 if (function != nullptr) {
1507 Indent(n1, "// function var:\n"); 1507 Indent(n1, "// function var:\n");
1508 PrintVar(n1, function); 1508 PrintVar(n1, function);
1509 } 1509 }
1510 1510
1511 PrintMap(n1, "// local vars:\n", &variables_, true, function); 1511 if (variables_.occupancy() > 0) {
1512 PrintMap(n1, "// dynamic vars:\n", &variables_, false, function); 1512 PrintMap(n1, "// local vars:\n", &variables_, true, function);
1513 PrintMap(n1, "// dynamic vars:\n", &variables_, false, function);
1514 }
1513 1515
1514 // Print inner scopes (disable by providing negative n). 1516 // Print inner scopes (disable by providing negative n).
1515 if (n >= 0) { 1517 if (n >= 0) {
1516 for (Scope* scope = inner_scope_; scope != nullptr; 1518 for (Scope* scope = inner_scope_; scope != nullptr;
1517 scope = scope->sibling_) { 1519 scope = scope->sibling_) {
1518 PrintF("\n"); 1520 PrintF("\n");
1519 scope->Print(n1); 1521 scope->Print(n1);
1520 } 1522 }
1521 } 1523 }
1522 1524
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 Variable* function = 2066 Variable* function =
2065 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; 2067 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr;
2066 bool is_function_var_in_context = 2068 bool is_function_var_in_context =
2067 function != nullptr && function->IsContextSlot(); 2069 function != nullptr && function->IsContextSlot();
2068 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 2070 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
2069 (is_function_var_in_context ? 1 : 0); 2071 (is_function_var_in_context ? 1 : 0);
2070 } 2072 }
2071 2073
2072 } // namespace internal 2074 } // namespace internal
2073 } // namespace v8 2075 } // 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