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

Unified Diff: src/scopes.h

Issue 11093074: Get rid of static module allocation, do it in code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed last comments; added other back-ends Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/scopeinfo.cc ('k') | src/scopes.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopes.h
diff --git a/src/scopes.h b/src/scopes.h
index b9d151cba5d69af23793c93e8e54da103fc825c1..c60c2e7d49c2f0587c79120e8e62ba3ea78cef1e 100644
--- a/src/scopes.h
+++ b/src/scopes.h
@@ -186,6 +186,12 @@ class Scope: public ZoneObject {
// such a variable again if it was added; otherwise this is a no-op.
void RemoveUnresolved(VariableProxy* var);
+ // Creates a new internal variable in this scope. The name is only used
+ // for printing and cannot be used to find the variable. In particular,
+ // the only way to get hold of the temporary is by keeping the Variable*
+ // around.
+ Variable* NewInternal(Handle<String> name);
+
// Creates a new temporary variable in this scope. The name is only used
// for printing and cannot be used to find the variable. In particular,
// the only way to get hold of the temporary is by keeping the Variable*
@@ -369,6 +375,12 @@ class Scope: public ZoneObject {
int StackLocalCount() const;
int ContextLocalCount() const;
+ // For global scopes, the number of module literals (including nested ones).
+ int num_modules() const { return num_modules_; }
+
+ // For module scopes, the host scope's internal variable binding this module.
+ Variable* module_var() const { return module_var_; }
+
// Make sure this scope and all outer scopes are eagerly compiled.
void ForceEagerCompilation() { force_eager_compilation_ = true; }
@@ -387,6 +399,9 @@ class Scope: public ZoneObject {
// The number of contexts between this and scope; zero if this == scope.
int ContextChainLength(Scope* scope);
+ // Find the innermost global scope.
+ Scope* GlobalScope();
+
// Find the first function, global, or eval scope. This is the scope
// where var declarations will be hoisted to in the implementation.
Scope* DeclarationScope();
@@ -441,6 +456,8 @@ class Scope: public ZoneObject {
// variables may be implicitly 'declared' by being used (possibly in
// an inner scope) with no intervening with statements or eval calls.
VariableMap variables_;
+ // Compiler-allocated (user-invisible) internals.
+ ZoneList<Variable*> internals_;
// Compiler-allocated (user-invisible) temporaries.
ZoneList<Variable*> temps_;
// Parameter list in source order.
@@ -494,6 +511,12 @@ class Scope: public ZoneObject {
int num_stack_slots_;
int num_heap_slots_;
+ // The number of modules (including nested ones).
+ int num_modules_;
+
+ // For module scopes, the host scope's internal variable binding this module.
+ Variable* module_var_;
+
// Serialized scope info support.
Handle<ScopeInfo> scope_info_;
bool already_resolved() { return already_resolved_; }
@@ -578,6 +601,7 @@ class Scope: public ZoneObject {
void AllocateNonParameterLocal(Variable* var);
void AllocateNonParameterLocals();
void AllocateVariablesRecursively();
+ void AllocateModulesRecursively(Scope* host_scope);
// Resolve and fill in the allocation information for all variables
// in this scopes. Must be called *after* all scopes have been
@@ -591,13 +615,6 @@ class Scope: public ZoneObject {
bool AllocateVariables(CompilationInfo* info,
AstNodeFactory<AstNullVisitor>* factory);
- // Instance objects have to be created ahead of time (before code generation)
- // because of potentially cyclic references between them.
- // Linking also has to be a separate stage, since populating one object may
- // potentially require (forward) references to others.
- void AllocateModules(CompilationInfo* info);
- void LinkModules(CompilationInfo* info);
-
private:
// Construct a scope based on the scope info.
Scope(Scope* inner_scope, ScopeType type, Handle<ScopeInfo> scope_info,
« no previous file with comments | « src/scopeinfo.cc ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698