Chromium Code Reviews| Index: src/scopes.h | 
| diff --git a/src/scopes.h b/src/scopes.h | 
| index be6705b3243af9bab028861e5229444ced7cf593..009f687b852b2251dc00f8e9682ba38668c05636 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,24 @@ 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 VariableMap(zone); | 
| 
 
danno
2012/06/11 12:11:45
Where does this allocation come from? It looks lik
 
sanjoy
2012/06/11 12:37:56
Changed to allocate from the zone.  VariableMap is
 
 | 
| + } | 
| + | 
| VariableMap* GetMap(VariableMode mode) { | 
| int index = mode - DYNAMIC; | 
| ASSERT(index >= 0 && index < 3); | 
| - return &maps_[index]; | 
| + return maps_[index]; | 
| + } | 
| + | 
| + ~DynamicScopePart() { | 
| + for (int i = 0; i < 3; i++) | 
| + delete maps_[i]; | 
| } | 
| private: | 
| - VariableMap maps_[3]; | 
| + VariableMap *maps_[3]; | 
| }; | 
| @@ -87,14 +102,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 +122,8 @@ class Scope: public ZoneObject { | 
| // tree and its children are reparented. | 
| Scope* FinalizeBlockScope(); | 
| + Zone* zone() const { return zone_; } | 
| + | 
| // --------------------------------------------------------------------------- | 
| // Declarations | 
| @@ -161,7 +179,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 +599,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 +615,8 @@ class Scope: public ZoneObject { | 
| void SetDefaults(ScopeType type, | 
| Scope* outer_scope, | 
| Handle<ScopeInfo> scope_info); | 
| + | 
| + Zone* zone_; | 
| }; | 
| } } // namespace v8::internal |