Chromium Code Reviews| Index: src/scopes.h |
| diff --git a/src/scopes.h b/src/scopes.h |
| index be6705b3243af9bab028861e5229444ced7cf593..9a93974482c4097ce613dc793821e84311cdb68b 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); |
|
danno
2012/06/05 13:42:35
Seems weird that you have to pass this into the co
sanjoy
2012/06/05 14:21:39
I figured not adding a member will save some space
danno
2012/06/06 10:59:53
This is probably cleaner still if the zone is stor
|
| virtual ~VariableMap(); |
| @@ -50,6 +50,7 @@ class VariableMap: public ZoneHashMap { |
| bool is_valid_lhs, |
| Variable::Kind kind, |
| InitializationFlag initialization_flag, |
| + Zone* zone, |
| Interface* interface = Interface::NewValue()); |
| Variable* Lookup(Handle<String> name); |
| @@ -62,14 +63,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); |
| + } |
| + |
| 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 +98,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 +118,8 @@ class Scope: public ZoneObject { |
| // tree and its children are reparented. |
| Scope* FinalizeBlockScope(); |
| + Zone* zone() const { return zone_; } |
| + |
| // --------------------------------------------------------------------------- |
| // Declarations |
| @@ -161,7 +175,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 +595,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 +611,8 @@ class Scope: public ZoneObject { |
| void SetDefaults(ScopeType type, |
| Scope* outer_scope, |
| Handle<ScopeInfo> scope_info); |
| + |
| + Zone* zone_; |
| }; |
| } } // namespace v8::internal |