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

Unified Diff: src/ast/scopes.h

Issue 2281073002: Create ScopeInfos while analyzing the Scope chain (Closed)
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ast/ast-numbering.cc ('k') | src/ast/scopes.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.h
diff --git a/src/ast/scopes.h b/src/ast/scopes.h
index 1c1d5ff4e683041de2713a89442449158cb3ee11..51b3e41f9e0606c395d8ba3f44db9ffb8af5f170 100644
--- a/src/ast/scopes.h
+++ b/src/ast/scopes.h
@@ -90,11 +90,6 @@ class Scope: public ZoneObject {
int top_decl_;
};
- // Compute top scope and allocate variables. For lazy compilation the top
- // scope only contains the single lazily compiled function, so this
- // doesn't re-allocate variables repeatedly.
- static void Analyze(ParseInfo* info);
-
enum class DeserializationMode { kDeserializeOffHeap, kKeepScopeInfo };
static Scope* DeserializeScopeChain(Isolate* isolate, Zone* zone,
@@ -379,10 +374,7 @@ class Scope: public ZoneObject {
// 'this' is bound, and what determines the function kind.
DeclarationScope* GetReceiverScope();
- // Creates a scope info if it doesn't already exist.
- Handle<ScopeInfo> GetScopeInfo(Isolate* isolate);
-
- // GetScopeInfo() must have been called once to create the ScopeInfo.
+ // Analyze() must have been called once to create the ScopeInfo.
Handle<ScopeInfo> scope_info() {
DCHECK(!scope_info_.is_null());
return scope_info_;
@@ -437,6 +429,17 @@ class Scope: public ZoneObject {
if (added) locals_.Add(var, zone);
return var;
}
+
+ // This method should only be invoked on scopes created during parsing (i.e.,
+ // not deserialized from a context). Also, since NeedsContext() is only
+ // returning a valid result after variables are resolved, NeedsScopeInfo()
+ // should also be invoked after resolution.
+ bool NeedsScopeInfo() const {
+ DCHECK(!already_resolved_);
+ return NeedsContext() || is_script_scope() || is_function_scope() ||
+ is_eval_scope() || is_module_scope();
+ }
+
Zone* zone_;
// Scope tree.
@@ -542,6 +545,8 @@ class Scope: public ZoneObject {
void AllocateNonParameterLocalsAndDeclaredGlobals();
void AllocateVariablesRecursively();
+ void AllocateScopeInfosRecursively(Isolate* isolate, bool for_debugger);
+
// Construct a scope based on the scope info.
Scope(Zone* zone, ScopeType type, Handle<ScopeInfo> scope_info);
@@ -744,15 +749,13 @@ class DeclarationScope : public Scope {
return &sloppy_block_function_map_;
}
- // Resolve and fill in the allocation information for all variables
- // in this scopes. Must be called *after* all scopes have been
- // processed (parsed) to ensure that unresolved variables can be
- // resolved properly.
- //
- // In the case of code compiled and run using 'eval', the context
- // parameter is the context in which eval was called. In all other
- // cases the context parameter is an empty handle.
- void AllocateVariables(ParseInfo* info);
+ // Compute top scope and allocate variables. For lazy compilation the top
+ // scope only contains the single lazily compiled function, so this
+ // doesn't re-allocate variables repeatedly.
+ static void Analyze(ParseInfo* info);
+
+ // Version used by the debugger that creates extra ScopeInfos.
+ static void AnalyzeForDebugger(ParseInfo* info);
// To be called during parsing. Do just enough scope analysis that we can
// discard the Scope for lazily compiled functions. In particular, this
@@ -791,6 +794,16 @@ class DeclarationScope : public Scope {
private:
void AllocateParameter(Variable* var, int index);
+ // Resolve and fill in the allocation information for all variables
+ // in this scopes. Must be called *after* all scopes have been
+ // processed (parsed) to ensure that unresolved variables can be
+ // resolved properly.
+ //
+ // In the case of code compiled and run using 'eval', the context
+ // parameter is the context in which eval was called. In all other
+ // cases the context parameter is an empty handle.
+ void AllocateVariables(ParseInfo* info, bool for_debugger);
+
void SetDefaults();
// If the scope is a function scope, this is the function kind.
« no previous file with comments | « src/ast/ast-numbering.cc ('k') | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698