 Chromium Code Reviews
 Chromium Code Reviews Issue 2424693003:
  Take the scope info of the direct outer scope as outer scope info  (Closed)
    
  
    Issue 2424693003:
  Take the scope info of the direct outer scope as outer scope info  (Closed) 
  | OLD | NEW | 
|---|---|
| 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 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1080 } | 1080 } | 
| 1081 } | 1081 } | 
| 1082 return nullptr; | 1082 return nullptr; | 
| 1083 } | 1083 } | 
| 1084 | 1084 | 
| 1085 void DeclarationScope::AllocateVariables(ParseInfo* info, AnalyzeMode mode) { | 1085 void DeclarationScope::AllocateVariables(ParseInfo* info, AnalyzeMode mode) { | 
| 1086 ResolveVariablesRecursively(info); | 1086 ResolveVariablesRecursively(info); | 
| 1087 AllocateVariablesRecursively(); | 1087 AllocateVariablesRecursively(); | 
| 1088 | 1088 | 
| 1089 MaybeHandle<ScopeInfo> outer_scope; | 1089 MaybeHandle<ScopeInfo> outer_scope; | 
| 1090 for (const Scope* s = outer_scope_; s != nullptr; s = s->outer_scope_) { | 1090 if (outer_scope_ != nullptr) outer_scope = outer_scope_->scope_info_; | 
| 
jochen (gone - plz use gerrit)
2016/10/17 09:55:51
DCHECK that scope_info_ is not null?
 
Toon Verwaest
2016/10/17 10:34:37
That scope info isn't guaranteed to be non-null. W
 | |
| 1091 if (s->scope_info_.is_null()) continue; | 1091 | 
| 1092 outer_scope = s->scope_info_; | |
| 1093 break; | |
| 1094 } | |
| 1095 AllocateScopeInfosRecursively(info->isolate(), outer_scope); | 1092 AllocateScopeInfosRecursively(info->isolate(), outer_scope); | 
| 1096 if (mode == AnalyzeMode::kDebugger) { | 1093 if (mode == AnalyzeMode::kDebugger) { | 
| 1097 AllocateDebuggerScopeInfos(info->isolate(), outer_scope); | 1094 AllocateDebuggerScopeInfos(info->isolate(), outer_scope); | 
| 1098 } | 1095 } | 
| 1099 // The debugger expects all shared function infos to contain a scope info. | 1096 // The debugger expects all shared function infos to contain a scope info. | 
| 1100 // Since the top-most scope will end up in a shared function info, make sure | 1097 // Since the top-most scope will end up in a shared function info, make sure | 
| 1101 // it has one, even if it doesn't need a scope info. | 1098 // it has one, even if it doesn't need a scope info. | 
| 1102 // TODO(jochen|yangguo): Remove this requirement. | 1099 // TODO(jochen|yangguo): Remove this requirement. | 
| 1103 if (scope_info_.is_null()) { | 1100 if (scope_info_.is_null()) { | 
| 1104 scope_info_ = ScopeInfo::Create(info->isolate(), zone(), this, outer_scope); | 1101 scope_info_ = ScopeInfo::Create(info->isolate(), zone(), this, outer_scope); | 
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1976 Variable* function = | 1973 Variable* function = | 
| 1977 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 1974 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 
| 1978 bool is_function_var_in_context = | 1975 bool is_function_var_in_context = | 
| 1979 function != nullptr && function->IsContextSlot(); | 1976 function != nullptr && function->IsContextSlot(); | 
| 1980 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1977 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 
| 1981 (is_function_var_in_context ? 1 : 0); | 1978 (is_function_var_in_context ? 1 : 0); | 
| 1982 } | 1979 } | 
| 1983 | 1980 | 
| 1984 } // namespace internal | 1981 } // namespace internal | 
| 1985 } // namespace v8 | 1982 } // namespace v8 | 
| OLD | NEW |