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

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

Issue 2435023002: Use a different map to distinguish eval contexts (Closed)
Patch Set: relax dchecks 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
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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 } 347 }
348 } else if (scope_info->scope_type() == SCRIPT_SCOPE) { 348 } else if (scope_info->scope_type() == SCRIPT_SCOPE) {
349 // If we reach a script scope, it's the outermost scope. Install the 349 // If we reach a script scope, it's the outermost scope. Install the
350 // scope info of this script context onto the existing script scope to 350 // scope info of this script context onto the existing script scope to
351 // avoid nesting script scopes. 351 // avoid nesting script scopes.
352 if (deserialization_mode == DeserializationMode::kIncludingVariables) { 352 if (deserialization_mode == DeserializationMode::kIncludingVariables) {
353 script_scope->SetScriptScopeInfo(handle(scope_info)); 353 script_scope->SetScriptScopeInfo(handle(scope_info));
354 } 354 }
355 DCHECK(!scope_info->HasOuterScopeInfo()); 355 DCHECK(!scope_info->HasOuterScopeInfo());
356 break; 356 break;
357 } else if (scope_info->scope_type() == FUNCTION_SCOPE || 357 } else if (scope_info->scope_type() == FUNCTION_SCOPE) {
358 scope_info->scope_type() == EVAL_SCOPE) {
359 // TODO(neis): For an eval scope, we currently create an ordinary function
360 // context. This is wrong and needs to be fixed.
361 // https://bugs.chromium.org/p/v8/issues/detail?id=5295
362 outer_scope = 358 outer_scope =
363 new (zone) DeclarationScope(zone, FUNCTION_SCOPE, handle(scope_info)); 359 new (zone) DeclarationScope(zone, FUNCTION_SCOPE, handle(scope_info));
364 if (scope_info->IsAsmFunction()) 360 if (scope_info->IsAsmFunction())
365 outer_scope->AsDeclarationScope()->set_asm_function(); 361 outer_scope->AsDeclarationScope()->set_asm_function();
366 if (scope_info->IsAsmModule()) 362 if (scope_info->IsAsmModule())
367 outer_scope->AsDeclarationScope()->set_asm_module(); 363 outer_scope->AsDeclarationScope()->set_asm_module();
364 } else if (scope_info->scope_type() == EVAL_SCOPE) {
365 if (scope_info->is_declaration_scope()) {
366 outer_scope =
adamk 2016/11/12 00:26:05 Can you add a DCHECK here that scope_info->languag
Dan Ehrenberg 2016/12/07 05:41:26 Actually, deleted this code, as it wasn't doing an
367 new (zone) DeclarationScope(zone, EVAL_SCOPE, handle(scope_info));
368 } else {
369 outer_scope = new (zone) Scope(zone, EVAL_SCOPE, handle(scope_info));
370 }
368 } else if (scope_info->scope_type() == BLOCK_SCOPE) { 371 } else if (scope_info->scope_type() == BLOCK_SCOPE) {
369 if (scope_info->is_declaration_scope()) { 372 if (scope_info->is_declaration_scope()) {
370 outer_scope = 373 outer_scope =
371 new (zone) DeclarationScope(zone, BLOCK_SCOPE, handle(scope_info)); 374 new (zone) DeclarationScope(zone, BLOCK_SCOPE, handle(scope_info));
372 } else { 375 } else {
373 outer_scope = new (zone) Scope(zone, BLOCK_SCOPE, handle(scope_info)); 376 outer_scope = new (zone) Scope(zone, BLOCK_SCOPE, handle(scope_info));
374 } 377 }
375 } else if (scope_info->scope_type() == MODULE_SCOPE) { 378 } else if (scope_info->scope_type() == MODULE_SCOPE) {
376 outer_scope = new (zone) 379 outer_scope = new (zone)
377 ModuleScope(isolate, handle(scope_info), ast_value_factory); 380 ModuleScope(isolate, handle(scope_info), ast_value_factory);
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after
2024 Variable* function = 2027 Variable* function =
2025 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; 2028 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr;
2026 bool is_function_var_in_context = 2029 bool is_function_var_in_context =
2027 function != nullptr && function->IsContextSlot(); 2030 function != nullptr && function->IsContextSlot();
2028 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 2031 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
2029 (is_function_var_in_context ? 1 : 0); 2032 (is_function_var_in_context ? 1 : 0);
2030 } 2033 }
2031 2034
2032 } // namespace internal 2035 } // namespace internal
2033 } // namespace v8 2036 } // namespace v8
OLDNEW
« no previous file with comments | « src/arm64/interface-descriptors-arm64.cc ('k') | src/code-factory.h » ('j') | src/contexts.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698