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

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

Issue 2263523002: Add some scope-related DCHECKs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Disable test262 module tests. Created 4 years, 4 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 | 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/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 if (context->IsDebugEvaluateContext()) { 255 if (context->IsDebugEvaluateContext()) {
256 with_scope->set_is_debug_evaluate_scope(); 256 with_scope->set_is_debug_evaluate_scope();
257 } 257 }
258 current_scope = with_scope; 258 current_scope = with_scope;
259 // All the inner scopes are inside a with. 259 // All the inner scopes are inside a with.
260 for (Scope* s = innermost_scope; s != nullptr; s = s->outer_scope()) { 260 for (Scope* s = innermost_scope; s != nullptr; s = s->outer_scope()) {
261 s->scope_inside_with_ = true; 261 s->scope_inside_with_ = true;
262 } 262 }
263 } else if (context->IsScriptContext()) { 263 } else if (context->IsScriptContext()) {
264 Handle<ScopeInfo> scope_info(context->scope_info(), isolate); 264 Handle<ScopeInfo> scope_info(context->scope_info(), isolate);
265 DCHECK_EQ(scope_info->scope_type(), SCRIPT_SCOPE);
265 current_scope = new (zone) 266 current_scope = new (zone)
266 DeclarationScope(zone, current_scope, SCRIPT_SCOPE, scope_info); 267 DeclarationScope(zone, current_scope, SCRIPT_SCOPE, scope_info);
267 } else if (context->IsFunctionContext()) { 268 } else if (context->IsFunctionContext()) {
268 Handle<ScopeInfo> scope_info(context->closure()->shared()->scope_info(), 269 Handle<ScopeInfo> scope_info(context->closure()->shared()->scope_info(),
269 isolate); 270 isolate);
271 // TODO(neis): For an eval scope, we currently create an ordinary function
272 // context. This is wrong and needs to be fixed.
273 // https://bugs.chromium.org/p/v8/issues/detail?id=5295
274 DCHECK(scope_info->scope_type() == FUNCTION_SCOPE ||
275 scope_info->scope_type() == EVAL_SCOPE);
270 DeclarationScope* function_scope = new (zone) 276 DeclarationScope* function_scope = new (zone)
271 DeclarationScope(zone, current_scope, FUNCTION_SCOPE, scope_info); 277 DeclarationScope(zone, current_scope, FUNCTION_SCOPE, scope_info);
272 if (scope_info->IsAsmFunction()) function_scope->set_asm_function(); 278 if (scope_info->IsAsmFunction()) function_scope->set_asm_function();
273 if (scope_info->IsAsmModule()) function_scope->set_asm_module(); 279 if (scope_info->IsAsmModule()) function_scope->set_asm_module();
274 current_scope = function_scope; 280 current_scope = function_scope;
275 } else if (context->IsBlockContext()) { 281 } else if (context->IsBlockContext()) {
276 Handle<ScopeInfo> scope_info(context->scope_info(), isolate); 282 Handle<ScopeInfo> scope_info(context->scope_info(), isolate);
283 DCHECK_EQ(scope_info->scope_type(), BLOCK_SCOPE);
277 if (scope_info->is_declaration_scope()) { 284 if (scope_info->is_declaration_scope()) {
278 current_scope = new (zone) 285 current_scope = new (zone)
279 DeclarationScope(zone, current_scope, BLOCK_SCOPE, scope_info); 286 DeclarationScope(zone, current_scope, BLOCK_SCOPE, scope_info);
280 } else { 287 } else {
281 current_scope = 288 current_scope =
282 new (zone) Scope(zone, current_scope, BLOCK_SCOPE, scope_info); 289 new (zone) Scope(zone, current_scope, BLOCK_SCOPE, scope_info);
283 } 290 }
284 } else { 291 } else {
285 DCHECK(context->IsCatchContext()); 292 DCHECK(context->IsCatchContext());
286 String* name = context->catch_name(); 293 String* name = context->catch_name();
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 function != nullptr && function->IsContextSlot(); 1794 function != nullptr && function->IsContextSlot();
1788 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - 1795 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() -
1789 (is_function_var_in_context ? 1 : 0); 1796 (is_function_var_in_context ? 1 : 0);
1790 } 1797 }
1791 1798
1792 1799
1793 int Scope::ContextGlobalCount() const { return num_global_slots(); } 1800 int Scope::ContextGlobalCount() const { return num_global_slots(); }
1794 1801
1795 } // namespace internal 1802 } // namespace internal
1796 } // namespace v8 1803 } // 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