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

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

Issue 2368313002: Don't use different function scopes when parsing with temp zones (Closed)
Patch Set: Created 4 years, 2 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
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 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 } 946 }
947 947
948 VariableProxy* Scope::NewUnresolved(AstNodeFactory* factory, 948 VariableProxy* Scope::NewUnresolved(AstNodeFactory* factory,
949 const AstRawString* name, 949 const AstRawString* name,
950 int start_position, int end_position, 950 int start_position, int end_position,
951 VariableKind kind) { 951 VariableKind kind) {
952 // Note that we must not share the unresolved variables with 952 // Note that we must not share the unresolved variables with
953 // the same name because they may be removed selectively via 953 // the same name because they may be removed selectively via
954 // RemoveUnresolved(). 954 // RemoveUnresolved().
955 DCHECK(!already_resolved_); 955 DCHECK(!already_resolved_);
956 DCHECK_EQ(factory->zone(), zone()); 956 // DCHECK_EQ(factory->zone(), zone());
Toon Verwaest 2016/09/26 14:24:30 We should probably just drop this?
marja 2016/09/27 07:14:03 Hmmmm... I think this was a nice DCHECK for guardi
marja 2016/09/27 11:17:34 Suggestion: flag scopes w/ needs_migration, here w
957 VariableProxy* proxy = 957 VariableProxy* proxy =
958 factory->NewVariableProxy(name, kind, start_position, end_position); 958 factory->NewVariableProxy(name, kind, start_position, end_position);
959 proxy->set_next_unresolved(unresolved_); 959 proxy->set_next_unresolved(unresolved_);
960 unresolved_ = proxy; 960 unresolved_ = proxy;
961 return proxy; 961 return proxy;
962 } 962 }
963 963
964 void Scope::AddUnresolved(VariableProxy* proxy) { 964 void Scope::AddUnresolved(VariableProxy* proxy) {
965 DCHECK(!already_resolved_); 965 DCHECK(!already_resolved_);
966 DCHECK(!proxy->is_resolved()); 966 DCHECK(!proxy->is_resolved());
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 Handle<StringSet> DeclarationScope::CollectNonLocals( 1181 Handle<StringSet> DeclarationScope::CollectNonLocals(
1182 ParseInfo* info, Handle<StringSet> non_locals) { 1182 ParseInfo* info, Handle<StringSet> non_locals) {
1183 VariableProxy* free_variables = FetchFreeVariables(this, true, info); 1183 VariableProxy* free_variables = FetchFreeVariables(this, true, info);
1184 for (VariableProxy* proxy = free_variables; proxy != nullptr; 1184 for (VariableProxy* proxy = free_variables; proxy != nullptr;
1185 proxy = proxy->next_unresolved()) { 1185 proxy = proxy->next_unresolved()) {
1186 non_locals = StringSet::Add(non_locals, proxy->name()); 1186 non_locals = StringSet::Add(non_locals, proxy->name());
1187 } 1187 }
1188 return non_locals; 1188 return non_locals;
1189 } 1189 }
1190 1190
1191 void DeclarationScope::AnalyzePartially(DeclarationScope* migrate_to, 1191 void DeclarationScope::AnalyzePartially(AstNodeFactory* ast_node_factory) {
1192 AstNodeFactory* ast_node_factory) { 1192 DCHECK(!force_eager_compilation_);
1193 // Try to resolve unresolved variables for this Scope and migrate those which 1193 VariableProxy* unresolved = nullptr;
1194 // cannot be resolved inside. It doesn't make sense to try to resolve them in 1194
1195 // the outer Scopes here, because they are incomplete. 1195 if (!outer_scope_->is_script_scope()) {
1196 for (VariableProxy* proxy = 1196 // Try to resolve unresolved variables for this Scope and migrate those
1197 FetchFreeVariables(this, !FLAG_lazy_inner_functions); 1197 // which
1198 proxy != nullptr; proxy = proxy->next_unresolved()) { 1198 // cannot be resolved inside. It doesn't make sense to try to resolve them
1199 DCHECK(!proxy->is_resolved()); 1199 // in
1200 VariableProxy* copy = ast_node_factory->CopyVariableProxy(proxy); 1200 // the outer Scopes here, because they are incomplete.
1201 migrate_to->AddUnresolved(copy); 1201 for (VariableProxy* proxy =
1202 FetchFreeVariables(this, !FLAG_lazy_inner_functions);
1203 proxy != nullptr; proxy = proxy->next_unresolved()) {
1204 DCHECK(!proxy->is_resolved());
1205 VariableProxy* copy = ast_node_factory->CopyVariableProxy(proxy);
1206 copy->set_next_unresolved(unresolved);
1207 unresolved = copy;
1208 }
1202 } 1209 }
1203 1210
1204 // Push scope data up to migrate_to. Note that migrate_to and this Scope 1211 ResetAfterPreparsing();
marja 2016/09/27 07:14:03 This is somewhat surprising now since we haven't n
1205 // describe the same Scope, just in different Zones. 1212
1206 PropagateUsageFlagsToScope(migrate_to); 1213 unresolved_ = unresolved;
1207 if (scope_uses_super_property_) migrate_to->scope_uses_super_property_ = true;
1208 if (inner_scope_calls_eval_) migrate_to->inner_scope_calls_eval_ = true;
1209 if (is_lazily_parsed_) migrate_to->is_lazily_parsed_ = true;
1210 DCHECK(!force_eager_compilation_);
1211 migrate_to->set_start_position(start_position_);
1212 migrate_to->set_end_position(end_position_);
1213 migrate_to->set_language_mode(language_mode());
1214 migrate_to->arity_ = arity_;
1215 migrate_to->force_context_allocation_ = force_context_allocation_;
1216 outer_scope_->RemoveInnerScope(this);
1217 DCHECK_EQ(outer_scope_, migrate_to->outer_scope_);
1218 DCHECK_EQ(outer_scope_->zone(), migrate_to->zone());
1219 DCHECK_EQ(NeedsHomeObject(), migrate_to->NeedsHomeObject());
1220 DCHECK_EQ(asm_function_, migrate_to->asm_function_);
1221 } 1214 }
1222 1215
1223 #ifdef DEBUG 1216 #ifdef DEBUG
1224 static const char* Header(ScopeType scope_type, FunctionKind function_kind, 1217 static const char* Header(ScopeType scope_type, FunctionKind function_kind,
1225 bool is_declaration_scope) { 1218 bool is_declaration_scope) {
1226 switch (scope_type) { 1219 switch (scope_type) {
1227 case EVAL_SCOPE: return "eval"; 1220 case EVAL_SCOPE: return "eval";
1228 // TODO(adamk): Should we print concise method scopes specially? 1221 // TODO(adamk): Should we print concise method scopes specially?
1229 case FUNCTION_SCOPE: 1222 case FUNCTION_SCOPE:
1230 if (IsGeneratorFunction(function_kind)) return "function*"; 1223 if (IsGeneratorFunction(function_kind)) return "function*";
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 Variable* function = 1851 Variable* function =
1859 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; 1852 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr;
1860 bool is_function_var_in_context = 1853 bool is_function_var_in_context =
1861 function != nullptr && function->IsContextSlot(); 1854 function != nullptr && function->IsContextSlot();
1862 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1855 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1863 (is_function_var_in_context ? 1 : 0); 1856 (is_function_var_in_context ? 1 : 0);
1864 } 1857 }
1865 1858
1866 } // namespace internal 1859 } // namespace internal
1867 } // namespace v8 1860 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/parser.cc » ('j') | src/parsing/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698