Index: src/scopes.h |
diff --git a/src/scopes.h b/src/scopes.h |
index be6705b3243af9bab028861e5229444ced7cf593..decd74d23275fdbaed92c6b35b94e1de9ae2e968 100644 |
--- a/src/scopes.h |
+++ b/src/scopes.h |
@@ -40,7 +40,7 @@ class CompilationInfo; |
// A hash map to support fast variable declaration and lookup. |
class VariableMap: public ZoneHashMap { |
public: |
- VariableMap(); |
+ explicit VariableMap(Zone* zone); |
virtual ~VariableMap(); |
@@ -53,6 +53,11 @@ class VariableMap: public ZoneHashMap { |
Interface* interface = Interface::NewValue()); |
Variable* Lookup(Handle<String> name); |
+ |
+ Zone* zone() const { return zone_; } |
+ |
+ private: |
+ Zone* zone_; |
}; |
@@ -62,14 +67,19 @@ class VariableMap: public ZoneHashMap { |
// and setup time for scopes that don't need them. |
class DynamicScopePart : public ZoneObject { |
public: |
+ explicit DynamicScopePart(Zone* zone) { |
+ for (int i = 0; i < 3; i++) |
+ maps_[i] = new(zone->New(sizeof(VariableMap))) VariableMap(zone); |
+ } |
+ |
VariableMap* GetMap(VariableMode mode) { |
int index = mode - DYNAMIC; |
ASSERT(index >= 0 && index < 3); |
- return &maps_[index]; |
+ return maps_[index]; |
} |
private: |
- VariableMap maps_[3]; |
+ VariableMap *maps_[3]; |
}; |
@@ -87,14 +97,15 @@ class Scope: public ZoneObject { |
// --------------------------------------------------------------------------- |
// Construction |
- Scope(Scope* outer_scope, ScopeType type); |
+ Scope(Scope* outer_scope, ScopeType type, Zone* zone); |
// 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 bool Analyze(CompilationInfo* info); |
- static Scope* DeserializeScopeChain(Context* context, Scope* global_scope); |
+ static Scope* DeserializeScopeChain(Context* context, Scope* global_scope, |
+ Zone* zone); |
// The scope name is only used for printing/debugging. |
void SetScopeName(Handle<String> scope_name) { scope_name_ = scope_name; } |
@@ -106,6 +117,8 @@ class Scope: public ZoneObject { |
// tree and its children are reparented. |
Scope* FinalizeBlockScope(); |
+ Zone* zone() const { return zone_; } |
+ |
// --------------------------------------------------------------------------- |
// Declarations |
@@ -161,7 +174,7 @@ class Scope: public ZoneObject { |
ASSERT(!already_resolved()); |
VariableProxy* proxy = |
factory->NewVariableProxy(name, false, position, interface); |
- unresolved_.Add(proxy); |
+ unresolved_.Add(proxy, zone_); |
return proxy; |
} |
@@ -581,14 +594,15 @@ class Scope: public ZoneObject { |
private: |
// Construct a scope based on the scope info. |
- Scope(Scope* inner_scope, ScopeType type, Handle<ScopeInfo> scope_info); |
+ Scope(Scope* inner_scope, ScopeType type, Handle<ScopeInfo> scope_info, |
+ Zone* zone); |
// Construct a catch scope with a binding for the name. |
- Scope(Scope* inner_scope, Handle<String> catch_variable_name); |
+ Scope(Scope* inner_scope, Handle<String> catch_variable_name, Zone* zone); |
void AddInnerScope(Scope* inner_scope) { |
if (inner_scope != NULL) { |
- inner_scopes_.Add(inner_scope); |
+ inner_scopes_.Add(inner_scope, zone_); |
inner_scope->outer_scope_ = this; |
} |
} |
@@ -596,6 +610,8 @@ class Scope: public ZoneObject { |
void SetDefaults(ScopeType type, |
Scope* outer_scope, |
Handle<ScopeInfo> scope_info); |
+ |
+ Zone* zone_; |
}; |
} } // namespace v8::internal |