Chromium Code Reviews| Index: src/interface.cc |
| diff --git a/src/interface.cc b/src/interface.cc |
| index 7836110e5f01e49e430db917ae650d38ce4dfe65..fea55066af15e7c55abe8ebc7ba8b7cebab611ac 100644 |
| --- a/src/interface.cc |
| +++ b/src/interface.cc |
| @@ -41,11 +41,13 @@ static bool Match(void* key1, void* key2) { |
| } |
| -Interface* Interface::Lookup(Handle<String> name) { |
| +Interface* Interface::Lookup(Handle<String> name, Zone* zone) { |
| ASSERT(IsModule()); |
| ZoneHashMap* map = Chase()->exports_; |
| if (map == NULL) return NULL; |
| - ZoneHashMap::Entry* p = map->Lookup(name.location(), name->Hash(), false); |
| + ZoneAllocationPolicy allocator(zone); |
| + ZoneHashMap::Entry* p = map->Lookup(name.location(), name->Hash(), false, |
| + allocator); |
| if (p == NULL) return NULL; |
| ASSERT(*static_cast<String**>(p->key) == *name); |
| ASSERT(p->value != NULL); |
| @@ -69,7 +71,7 @@ int Nesting::current_ = 0; |
| void Interface::DoAdd( |
| - void* name, uint32_t hash, Interface* interface, bool* ok) { |
| + void* name, uint32_t hash, Interface* interface, bool* ok, Zone* zone) { |
| MakeModule(ok); |
| if (!*ok) return; |
| @@ -85,9 +87,12 @@ void Interface::DoAdd( |
| #endif |
| ZoneHashMap** map = &Chase()->exports_; |
| - if (*map == NULL) *map = new ZoneHashMap(Match, 8); |
| + ZoneAllocationPolicy allocator(zone); |
| - ZoneHashMap::Entry* p = (*map)->Lookup(name, hash, !IsFrozen()); |
| + if (*map == NULL) |
| + *map = new ZoneHashMap(Match, 8, allocator); |
|
danno
2012/06/05 13:42:35
Constant for default argument
sanjoy
2012/06/05 14:21:39
Fixed.
|
| + |
| + ZoneHashMap::Entry* p = (*map)->Lookup(name, hash, !IsFrozen(), allocator); |
| if (p == NULL) { |
| // This didn't have name but was frozen already, that's an error. |
| *ok = false; |
| @@ -97,7 +102,7 @@ void Interface::DoAdd( |
| #ifdef DEBUG |
| Nesting nested; |
| #endif |
| - static_cast<Interface*>(p->value)->Unify(interface, ok); |
| + static_cast<Interface*>(p->value)->Unify(interface, ok, zone); |
| } |
| #ifdef DEBUG |
| @@ -110,9 +115,9 @@ void Interface::DoAdd( |
| } |
| -void Interface::Unify(Interface* that, bool* ok) { |
| - if (this->forward_) return this->Chase()->Unify(that, ok); |
| - if (that->forward_) return this->Unify(that->Chase(), ok); |
| +void Interface::Unify(Interface* that, bool* ok, Zone* zone) { |
| + if (this->forward_) return this->Chase()->Unify(that, ok, zone); |
| + if (that->forward_) return this->Unify(that->Chase(), ok, zone); |
| ASSERT(this->forward_ == NULL); |
| ASSERT(that->forward_ == NULL); |
| @@ -134,9 +139,9 @@ void Interface::Unify(Interface* that, bool* ok) { |
| // Merge the smaller interface into the larger, for performance. |
| if (this->exports_ != NULL && (that->exports_ == NULL || |
| this->exports_->occupancy() >= that->exports_->occupancy())) { |
| - this->DoUnify(that, ok); |
| + this->DoUnify(that, ok, zone); |
| } else { |
| - that->DoUnify(this, ok); |
| + that->DoUnify(this, ok, zone); |
| } |
| #ifdef DEBUG |
| @@ -151,7 +156,7 @@ void Interface::Unify(Interface* that, bool* ok) { |
| } |
| -void Interface::DoUnify(Interface* that, bool* ok) { |
| +void Interface::DoUnify(Interface* that, bool* ok, Zone* zone) { |
| ASSERT(this->forward_ == NULL); |
| ASSERT(that->forward_ == NULL); |
| ASSERT(!this->IsValue()); |
| @@ -166,7 +171,7 @@ void Interface::DoUnify(Interface* that, bool* ok) { |
| ZoneHashMap* map = that->exports_; |
| if (map != NULL) { |
| for (ZoneHashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) { |
| - this->DoAdd(p->key, p->hash, static_cast<Interface*>(p->value), ok); |
| + this->DoAdd(p->key, p->hash, static_cast<Interface*>(p->value), ok, zone); |
| if (!*ok) return; |
| } |
| } |