| Index: src/scopes.cc
 | 
| diff --git a/src/scopes.cc b/src/scopes.cc
 | 
| index 2c61a7523a6dc33402a346681dc5775eb86c2a41..25c88df3f9c86cce664d612fa22433ab75d2996f 100644
 | 
| --- a/src/scopes.cc
 | 
| +++ b/src/scopes.cc
 | 
| @@ -57,7 +57,8 @@ static bool Match(void* key1, void* key2) {
 | 
|  }
 | 
|  
 | 
|  
 | 
| -VariableMap::VariableMap() : ZoneHashMap(Match, 8) {}
 | 
| +VariableMap::VariableMap(Zone* zone)
 | 
| +    : ZoneHashMap(Match, 8, ZoneAllocationPolicy(zone)) {}
 | 
|  VariableMap::~VariableMap() {}
 | 
|  
 | 
|  
 | 
| @@ -68,25 +69,28 @@ Variable* VariableMap::Declare(
 | 
|      bool is_valid_lhs,
 | 
|      Variable::Kind kind,
 | 
|      InitializationFlag initialization_flag,
 | 
| +    Zone* zone,
 | 
|      Interface* interface) {
 | 
| -  Entry* p = ZoneHashMap::Lookup(name.location(), name->Hash(), true);
 | 
| +  Entry* p = ZoneHashMap::Lookup(name.location(), name->Hash(), true,
 | 
| +                                 ZoneAllocationPolicy(zone));
 | 
|    if (p->value == NULL) {
 | 
|      // The variable has not been declared yet -> insert it.
 | 
|      ASSERT(p->key == name.location());
 | 
| -    p->value = new Variable(scope,
 | 
| -                            name,
 | 
| -                            mode,
 | 
| -                            is_valid_lhs,
 | 
| -                            kind,
 | 
| -                            initialization_flag,
 | 
| -                            interface);
 | 
| +    p->value = new(zone) Variable(scope,
 | 
| +                                  name,
 | 
| +                                  mode,
 | 
| +                                  is_valid_lhs,
 | 
| +                                  kind,
 | 
| +                                  initialization_flag,
 | 
| +                                  interface);
 | 
|    }
 | 
|    return reinterpret_cast<Variable*>(p->value);
 | 
|  }
 | 
|  
 | 
|  
 | 
|  Variable* VariableMap::Lookup(Handle<String> name) {
 | 
| -  Entry* p = ZoneHashMap::Lookup(name.location(), name->Hash(), false);
 | 
| +  Entry* p = ZoneHashMap::Lookup(name.location(), name->Hash(), false,
 | 
| +                                 ZoneAllocationPolicy(NULL));
 | 
|    if (p != NULL) {
 | 
|      ASSERT(*reinterpret_cast<String**>(p->key) == *name);
 | 
|      ASSERT(p->value != NULL);
 | 
| @@ -99,18 +103,19 @@ Variable* VariableMap::Lookup(Handle<String> name) {
 | 
|  // ----------------------------------------------------------------------------
 | 
|  // Implementation of Scope
 | 
|  
 | 
| -Scope::Scope(Scope* outer_scope, ScopeType type)
 | 
| +Scope::Scope(Scope* outer_scope, ScopeType type, Zone* zone)
 | 
|      : isolate_(Isolate::Current()),
 | 
| -      inner_scopes_(4),
 | 
| -      variables_(),
 | 
| -      temps_(4),
 | 
| -      params_(4),
 | 
| -      unresolved_(16),
 | 
| -      decls_(4),
 | 
| +      inner_scopes_(4, zone),
 | 
| +      variables_(zone),
 | 
| +      temps_(4, zone),
 | 
| +      params_(4, zone),
 | 
| +      unresolved_(16, zone),
 | 
| +      decls_(4, zone),
 | 
|        interface_(FLAG_harmony_modules &&
 | 
|                   (type == MODULE_SCOPE || type == GLOBAL_SCOPE)
 | 
| -                     ? Interface::NewModule() : NULL),
 | 
| -      already_resolved_(false) {
 | 
| +                     ? Interface::NewModule(zone) : NULL),
 | 
| +      already_resolved_(false),
 | 
| +      zone_(zone) {
 | 
|    SetDefaults(type, outer_scope, Handle<ScopeInfo>::null());
 | 
|    // At some point we might want to provide outer scopes to
 | 
|    // eval scopes (by walking the stack and reading the scope info).
 | 
| @@ -122,16 +127,18 @@ Scope::Scope(Scope* outer_scope, ScopeType type)
 | 
|  
 | 
|  Scope::Scope(Scope* inner_scope,
 | 
|               ScopeType type,
 | 
| -             Handle<ScopeInfo> scope_info)
 | 
| +             Handle<ScopeInfo> scope_info,
 | 
| +             Zone* zone)
 | 
|      : isolate_(Isolate::Current()),
 | 
| -      inner_scopes_(4),
 | 
| -      variables_(),
 | 
| -      temps_(4),
 | 
| -      params_(4),
 | 
| -      unresolved_(16),
 | 
| -      decls_(4),
 | 
| +      inner_scopes_(4, zone),
 | 
| +      variables_(zone),
 | 
| +      temps_(4, zone),
 | 
| +      params_(4, zone),
 | 
| +      unresolved_(16, zone),
 | 
| +      decls_(4, zone),
 | 
|        interface_(NULL),
 | 
| -      already_resolved_(true) {
 | 
| +      already_resolved_(true),
 | 
| +      zone_(zone) {
 | 
|    SetDefaults(type, NULL, scope_info);
 | 
|    if (!scope_info.is_null()) {
 | 
|      num_heap_slots_ = scope_info_->ContextLength();
 | 
| @@ -143,16 +150,17 @@ Scope::Scope(Scope* inner_scope,
 | 
|  }
 | 
|  
 | 
|  
 | 
| -Scope::Scope(Scope* inner_scope, Handle<String> catch_variable_name)
 | 
| +Scope::Scope(Scope* inner_scope, Handle<String> catch_variable_name, Zone* zone)
 | 
|      : isolate_(Isolate::Current()),
 | 
| -      inner_scopes_(1),
 | 
| -      variables_(),
 | 
| -      temps_(0),
 | 
| -      params_(0),
 | 
| -      unresolved_(0),
 | 
| -      decls_(0),
 | 
| +      inner_scopes_(1, zone),
 | 
| +      variables_(zone),
 | 
| +      temps_(0, zone),
 | 
| +      params_(0, zone),
 | 
| +      unresolved_(0, zone),
 | 
| +      decls_(0, zone),
 | 
|        interface_(NULL),
 | 
| -      already_resolved_(true) {
 | 
| +      already_resolved_(true),
 | 
| +      zone_(zone) {
 | 
|    SetDefaults(CATCH_SCOPE, NULL, Handle<ScopeInfo>::null());
 | 
|    AddInnerScope(inner_scope);
 | 
|    ++num_var_or_const_;
 | 
| @@ -162,7 +170,8 @@ Scope::Scope(Scope* inner_scope, Handle<String> catch_variable_name)
 | 
|                                            VAR,
 | 
|                                            true,  // Valid left-hand side.
 | 
|                                            Variable::NORMAL,
 | 
| -                                          kCreatedInitialized);
 | 
| +                                          kCreatedInitialized,
 | 
| +                                          zone);
 | 
|    AllocateHeapSlot(variable);
 | 
|  }
 | 
|  
 | 
| @@ -200,16 +209,18 @@ void Scope::SetDefaults(ScopeType type,
 | 
|  }
 | 
|  
 | 
|  
 | 
| -Scope* Scope::DeserializeScopeChain(Context* context, Scope* global_scope) {
 | 
| +Scope* Scope::DeserializeScopeChain(Context* context, Scope* global_scope,
 | 
| +                                    Zone* zone) {
 | 
|    // Reconstruct the outer scope chain from a closure's context chain.
 | 
|    Scope* current_scope = NULL;
 | 
|    Scope* innermost_scope = NULL;
 | 
|    bool contains_with = false;
 | 
|    while (!context->IsGlobalContext()) {
 | 
|      if (context->IsWithContext()) {
 | 
| -      Scope* with_scope = new Scope(current_scope,
 | 
| -                                    WITH_SCOPE,
 | 
| -                                    Handle<ScopeInfo>::null());
 | 
| +      Scope* with_scope = new(zone) Scope(current_scope,
 | 
| +                                          WITH_SCOPE,
 | 
| +                                          Handle<ScopeInfo>::null(),
 | 
| +                                          zone);
 | 
|        current_scope = with_scope;
 | 
|        // All the inner scopes are inside a with.
 | 
|        contains_with = true;
 | 
| @@ -218,18 +229,21 @@ Scope* Scope::DeserializeScopeChain(Context* context, Scope* global_scope) {
 | 
|        }
 | 
|      } else if (context->IsFunctionContext()) {
 | 
|        ScopeInfo* scope_info = context->closure()->shared()->scope_info();
 | 
| -      current_scope = new Scope(current_scope,
 | 
| -                                FUNCTION_SCOPE,
 | 
| -                                Handle<ScopeInfo>(scope_info));
 | 
| +      current_scope = new(zone) Scope(current_scope,
 | 
| +                                      FUNCTION_SCOPE,
 | 
| +                                      Handle<ScopeInfo>(scope_info),
 | 
| +                                      zone);
 | 
|      } else if (context->IsBlockContext()) {
 | 
|        ScopeInfo* scope_info = ScopeInfo::cast(context->extension());
 | 
| -      current_scope = new Scope(current_scope,
 | 
| -                                BLOCK_SCOPE,
 | 
| -                                Handle<ScopeInfo>(scope_info));
 | 
| +      current_scope = new(zone) Scope(current_scope,
 | 
| +                                      BLOCK_SCOPE,
 | 
| +                                      Handle<ScopeInfo>(scope_info),
 | 
| +                                      zone);
 | 
|      } else {
 | 
|        ASSERT(context->IsCatchContext());
 | 
|        String* name = String::cast(context->extension());
 | 
| -      current_scope = new Scope(current_scope, Handle<String>(name));
 | 
| +      current_scope = new(zone) Scope(
 | 
| +          current_scope, Handle<String>(name), zone);
 | 
|      }
 | 
|      if (contains_with) current_scope->RecordWithStatement();
 | 
|      if (innermost_scope == NULL) innermost_scope = current_scope;
 | 
| @@ -305,7 +319,7 @@ void Scope::Initialize() {
 | 
|  
 | 
|    // Add this scope as a new inner scope of the outer scope.
 | 
|    if (outer_scope_ != NULL) {
 | 
| -    outer_scope_->inner_scopes_.Add(this);
 | 
| +    outer_scope_->inner_scopes_.Add(this, zone());
 | 
|      scope_inside_with_ = outer_scope_->scope_inside_with_ || is_with_scope();
 | 
|    } else {
 | 
|      scope_inside_with_ = is_with_scope();
 | 
| @@ -326,7 +340,8 @@ void Scope::Initialize() {
 | 
|                             VAR,
 | 
|                             false,
 | 
|                             Variable::THIS,
 | 
| -                           kCreatedInitialized);
 | 
| +                           kCreatedInitialized,
 | 
| +                           zone());
 | 
|      var->AllocateTo(Variable::PARAMETER, -1);
 | 
|      receiver_ = var;
 | 
|    } else {
 | 
| @@ -343,7 +358,8 @@ void Scope::Initialize() {
 | 
|                         VAR,
 | 
|                         true,
 | 
|                         Variable::ARGUMENTS,
 | 
| -                       kCreatedInitialized);
 | 
| +                       kCreatedInitialized,
 | 
| +                       zone());
 | 
|    }
 | 
|  }
 | 
|  
 | 
| @@ -370,7 +386,7 @@ Scope* Scope::FinalizeBlockScope() {
 | 
|  
 | 
|    // Move unresolved variables
 | 
|    for (int i = 0; i < unresolved_.length(); i++) {
 | 
| -    outer_scope()->unresolved_.Add(unresolved_[i]);
 | 
| +    outer_scope()->unresolved_.Add(unresolved_[i], zone());
 | 
|    }
 | 
|  
 | 
|    return NULL;
 | 
| @@ -407,7 +423,8 @@ Variable* Scope::LocalLookup(Handle<String> name) {
 | 
|                           mode,
 | 
|                           true,
 | 
|                           Variable::NORMAL,
 | 
| -                         init_flag);
 | 
| +                         init_flag,
 | 
| +                         zone());
 | 
|    var->AllocateTo(location, index);
 | 
|    return var;
 | 
|  }
 | 
| @@ -422,7 +439,7 @@ Variable* Scope::LookupFunctionVar(Handle<String> name,
 | 
|      VariableMode mode;
 | 
|      int index = scope_info_->FunctionContextSlotIndex(*name, &mode);
 | 
|      if (index < 0) return NULL;
 | 
| -    Variable* var = new Variable(
 | 
| +    Variable* var = new(zone()) Variable(
 | 
|          this, name, mode, true /* is valid LHS */,
 | 
|          Variable::NORMAL, kCreatedInitialized);
 | 
|      VariableProxy* proxy = factory->NewVariableProxy(var);
 | 
| @@ -452,8 +469,8 @@ void Scope::DeclareParameter(Handle<String> name, VariableMode mode) {
 | 
|    ASSERT(!already_resolved());
 | 
|    ASSERT(is_function_scope());
 | 
|    Variable* var = variables_.Declare(
 | 
| -      this, name, mode, true, Variable::NORMAL, kCreatedInitialized);
 | 
| -  params_.Add(var);
 | 
| +      this, name, mode, true, Variable::NORMAL, kCreatedInitialized, zone());
 | 
| +  params_.Add(var, zone());
 | 
|  }
 | 
|  
 | 
|  
 | 
| @@ -471,7 +488,7 @@ Variable* Scope::DeclareLocal(Handle<String> name,
 | 
|           mode == LET);
 | 
|    ++num_var_or_const_;
 | 
|    return variables_.Declare(
 | 
| -      this, name, mode, true, Variable::NORMAL, init_flag, interface);
 | 
| +      this, name, mode, true, Variable::NORMAL, init_flag, zone(), interface);
 | 
|  }
 | 
|  
 | 
|  
 | 
| @@ -482,7 +499,8 @@ Variable* Scope::DeclareGlobal(Handle<String> name) {
 | 
|                              DYNAMIC_GLOBAL,
 | 
|                              true,
 | 
|                              Variable::NORMAL,
 | 
| -                            kCreatedInitialized);
 | 
| +                            kCreatedInitialized,
 | 
| +                            zone());
 | 
|  }
 | 
|  
 | 
|  
 | 
| @@ -500,19 +518,19 @@ void Scope::RemoveUnresolved(VariableProxy* var) {
 | 
|  
 | 
|  Variable* Scope::NewTemporary(Handle<String> name) {
 | 
|    ASSERT(!already_resolved());
 | 
| -  Variable* var = new Variable(this,
 | 
| -                               name,
 | 
| -                               TEMPORARY,
 | 
| -                               true,
 | 
| -                               Variable::NORMAL,
 | 
| -                               kCreatedInitialized);
 | 
| -  temps_.Add(var);
 | 
| +  Variable* var = new(zone()) Variable(this,
 | 
| +                                       name,
 | 
| +                                       TEMPORARY,
 | 
| +                                       true,
 | 
| +                                       Variable::NORMAL,
 | 
| +                                       kCreatedInitialized);
 | 
| +  temps_.Add(var, zone());
 | 
|    return var;
 | 
|  }
 | 
|  
 | 
|  
 | 
|  void Scope::AddDeclaration(Declaration* declaration) {
 | 
| -  decls_.Add(declaration);
 | 
| +  decls_.Add(declaration, zone());
 | 
|  }
 | 
|  
 | 
|  
 | 
| @@ -588,7 +606,7 @@ void Scope::CollectStackAndContextLocals(ZoneList<Variable*>* stack_locals,
 | 
|      Variable* var = temps_[i];
 | 
|      if (var->is_used()) {
 | 
|        ASSERT(var->IsStackLocal());
 | 
| -      stack_locals->Add(var);
 | 
| +      stack_locals->Add(var, zone());
 | 
|      }
 | 
|    }
 | 
|  
 | 
| @@ -599,9 +617,9 @@ void Scope::CollectStackAndContextLocals(ZoneList<Variable*>* stack_locals,
 | 
|      Variable* var = reinterpret_cast<Variable*>(p->value);
 | 
|      if (var->is_used()) {
 | 
|        if (var->IsStackLocal()) {
 | 
| -        stack_locals->Add(var);
 | 
| +        stack_locals->Add(var, zone());
 | 
|        } else if (var->IsContextSlot()) {
 | 
| -        context_locals->Add(var);
 | 
| +        context_locals->Add(var, zone());
 | 
|        }
 | 
|      }
 | 
|    }
 | 
| @@ -699,7 +717,7 @@ Scope* Scope::DeclarationScope() {
 | 
|  
 | 
|  Handle<ScopeInfo> Scope::GetScopeInfo() {
 | 
|    if (scope_info_.is_null()) {
 | 
| -    scope_info_ = ScopeInfo::Create(this);
 | 
| +    scope_info_ = ScopeInfo::Create(this, zone());
 | 
|    }
 | 
|    return scope_info_;
 | 
|  }
 | 
| @@ -885,7 +903,7 @@ void Scope::Print(int n) {
 | 
|  
 | 
|  
 | 
|  Variable* Scope::NonLocal(Handle<String> name, VariableMode mode) {
 | 
| -  if (dynamics_ == NULL) dynamics_ = new DynamicScopePart();
 | 
| +  if (dynamics_ == NULL) dynamics_ = new(zone()) DynamicScopePart(zone());
 | 
|    VariableMap* map = dynamics_->GetMap(mode);
 | 
|    Variable* var = map->Lookup(name);
 | 
|    if (var == NULL) {
 | 
| @@ -897,7 +915,8 @@ Variable* Scope::NonLocal(Handle<String> name, VariableMode mode) {
 | 
|                         mode,
 | 
|                         true,
 | 
|                         Variable::NORMAL,
 | 
| -                       init_flag);
 | 
| +                       init_flag,
 | 
| +                       zone());
 | 
|      // Allocate it by giving it a dynamic lookup.
 | 
|      var->AllocateTo(Variable::LOOKUP, -1);
 | 
|    }
 | 
| @@ -1019,7 +1038,7 @@ bool Scope::ResolveVariable(CompilationInfo* info,
 | 
|      if (FLAG_print_interface_details)
 | 
|        PrintF("# Resolve %s:\n", var->name()->ToAsciiArray());
 | 
|  #endif
 | 
| -    proxy->interface()->Unify(var->interface(), &ok);
 | 
| +    proxy->interface()->Unify(var->interface(), &ok, zone());
 | 
|      if (!ok) {
 | 
|  #ifdef DEBUG
 | 
|        if (FLAG_print_interfaces) {
 | 
| 
 |