Commit b42ecda5 authored by leszeks's avatar leszeks Committed by Commit bot

[base] Move hashmap allocator to a field

Moves the hashmap's allocator from being a parameter in the various
hashmap functions, to being a field in the hashmap itself. This

1. Protects against incorrectly passed allocators, and
2. Cleans up the API so that e.g. callers don't have to store their
   allocator

This is part of a wider set of changes discussed in:
https://groups.google.com/forum/#!topic/v8-dev/QLsC0XPYLeM

Review-Url: https://codereview.chromium.org/2345233003
Cr-Commit-Position: refs/heads/master@{#39538}
parent 044a62be
...@@ -361,8 +361,8 @@ bool AsmTyper::AddGlobal(Variable* variable, VariableInfo* info) { ...@@ -361,8 +361,8 @@ bool AsmTyper::AddGlobal(Variable* variable, VariableInfo* info) {
return false; return false;
} }
ZoneHashMap::Entry* entry = global_scope_.LookupOrInsert( ZoneHashMap::Entry* entry =
variable, ComputePointerHash(variable), ZoneAllocationPolicy(zone_)); global_scope_.LookupOrInsert(variable, ComputePointerHash(variable));
if (entry->value != nullptr) { if (entry->value != nullptr) {
return false; return false;
...@@ -378,8 +378,8 @@ bool AsmTyper::AddLocal(Variable* variable, VariableInfo* info) { ...@@ -378,8 +378,8 @@ bool AsmTyper::AddLocal(Variable* variable, VariableInfo* info) {
DCHECK(!info->IsGlobal()); DCHECK(!info->IsGlobal());
DCHECK(ValidAsmIdentifier(variable->name())); DCHECK(ValidAsmIdentifier(variable->name()));
ZoneHashMap::Entry* entry = local_scope_.LookupOrInsert( ZoneHashMap::Entry* entry =
variable, ComputePointerHash(variable), ZoneAllocationPolicy(zone_)); local_scope_.LookupOrInsert(variable, ComputePointerHash(variable));
if (entry->value != nullptr) { if (entry->value != nullptr) {
return false; return false;
......
...@@ -664,8 +664,8 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { ...@@ -664,8 +664,8 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
FunctionTableIndices* container = new (zone()) FunctionTableIndices(); FunctionTableIndices* container = new (zone()) FunctionTableIndices();
container->start_index = start_index; container->start_index = start_index;
container->signature_index = signature_index; container->signature_index = signature_index;
ZoneHashMap::Entry* entry = function_tables_.LookupOrInsert( ZoneHashMap::Entry* entry =
v, ComputePointerHash(v), ZoneAllocationPolicy(zone())); function_tables_.LookupOrInsert(v, ComputePointerHash(v));
entry->value = container; entry->value = container;
} }
...@@ -700,8 +700,8 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { ...@@ -700,8 +700,8 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
void AddImport(Variable* v, const char* name, int name_length) { void AddImport(Variable* v, const char* name, int name_length) {
ImportedFunctionIndices* indices = new (builder_->zone()) ImportedFunctionIndices* indices = new (builder_->zone())
ImportedFunctionIndices(name, name_length, builder_->zone()); ImportedFunctionIndices(name, name_length, builder_->zone());
ZoneHashMap::Entry* entry = table_.LookupOrInsert( ZoneHashMap::Entry* entry =
v, ComputePointerHash(v), ZoneAllocationPolicy(builder_->zone())); table_.LookupOrInsert(v, ComputePointerHash(v));
entry->value = indices; entry->value = indices;
} }
...@@ -1694,8 +1694,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { ...@@ -1694,8 +1694,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
index = current_function_builder_->AddLocal(type); index = current_function_builder_->AddLocal(type);
IndexContainer* container = new (zone()) IndexContainer(); IndexContainer* container = new (zone()) IndexContainer();
container->index = index; container->index = index;
entry = local_variables_.LookupOrInsert(v, ComputePointerHash(v), entry = local_variables_.LookupOrInsert(v, ComputePointerHash(v));
ZoneAllocationPolicy(zone()));
entry->value = container; entry->value = container;
} }
return (reinterpret_cast<IndexContainer*>(entry->value))->index; return (reinterpret_cast<IndexContainer*>(entry->value))->index;
...@@ -1709,8 +1708,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { ...@@ -1709,8 +1708,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
DCHECK_NULL(entry); DCHECK_NULL(entry);
IndexContainer* container = new (zone()) IndexContainer(); IndexContainer* container = new (zone()) IndexContainer();
container->index = index; container->index = index;
entry = local_variables_.LookupOrInsert(v, ComputePointerHash(v), entry = local_variables_.LookupOrInsert(v, ComputePointerHash(v));
ZoneAllocationPolicy(zone()));
entry->value = container; entry->value = container;
} }
...@@ -1721,8 +1719,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { ...@@ -1721,8 +1719,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
uint32_t index = builder_->AddGlobal(type, 0); uint32_t index = builder_->AddGlobal(type, 0);
IndexContainer* container = new (zone()) IndexContainer(); IndexContainer* container = new (zone()) IndexContainer();
container->index = index; container->index = index;
entry = global_variables_.LookupOrInsert(v, ComputePointerHash(v), entry = global_variables_.LookupOrInsert(v, ComputePointerHash(v));
ZoneAllocationPolicy(zone()));
entry->value = container; entry->value = container;
} }
return (reinterpret_cast<IndexContainer*>(entry->value))->index; return (reinterpret_cast<IndexContainer*>(entry->value))->index;
...@@ -1735,8 +1732,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { ...@@ -1735,8 +1732,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
uint32_t index = builder_->AddFunction(); uint32_t index = builder_->AddFunction();
IndexContainer* container = new (zone()) IndexContainer(); IndexContainer* container = new (zone()) IndexContainer();
container->index = index; container->index = index;
entry = functions_.LookupOrInsert(v, ComputePointerHash(v), entry = functions_.LookupOrInsert(v, ComputePointerHash(v));
ZoneAllocationPolicy(zone()));
entry->value = container; entry->value = container;
} }
return (reinterpret_cast<IndexContainer*>(entry->value))->index; return (reinterpret_cast<IndexContainer*>(entry->value))->index;
......
...@@ -472,7 +472,7 @@ void ObjectLiteral::CalculateEmitStore(Zone* zone) { ...@@ -472,7 +472,7 @@ void ObjectLiteral::CalculateEmitStore(Zone* zone) {
// If there is an existing entry do not emit a store unless the previous // If there is an existing entry do not emit a store unless the previous
// entry was also an accessor. // entry was also an accessor.
uint32_t hash = literal->Hash(); uint32_t hash = literal->Hash();
ZoneHashMap::Entry* entry = table.LookupOrInsert(literal, hash, allocator); ZoneHashMap::Entry* entry = table.LookupOrInsert(literal, hash);
if (entry->value != NULL) { if (entry->value != NULL) {
auto previous_kind = auto previous_kind =
static_cast<ObjectLiteral::Property*>(entry->value)->kind(); static_cast<ObjectLiteral::Property*>(entry->value)->kind();
......
...@@ -134,14 +134,13 @@ typedef ZoneList<Handle<Object>> ZoneObjectList; ...@@ -134,14 +134,13 @@ typedef ZoneList<Handle<Object>> ZoneObjectList;
class FeedbackVectorSlotCache { class FeedbackVectorSlotCache {
public: public:
explicit FeedbackVectorSlotCache(Zone* zone) explicit FeedbackVectorSlotCache(Zone* zone)
: zone_(zone), : hash_map_(base::HashMap::PointersMatch,
hash_map_(base::HashMap::PointersMatch,
ZoneHashMap::kDefaultHashMapCapacity, ZoneHashMap::kDefaultHashMapCapacity,
ZoneAllocationPolicy(zone)) {} ZoneAllocationPolicy(zone)) {}
void Put(Variable* variable, FeedbackVectorSlot slot) { void Put(Variable* variable, FeedbackVectorSlot slot) {
ZoneHashMap::Entry* entry = hash_map_.LookupOrInsert( ZoneHashMap::Entry* entry =
variable, ComputePointerHash(variable), ZoneAllocationPolicy(zone_)); hash_map_.LookupOrInsert(variable, ComputePointerHash(variable));
entry->value = reinterpret_cast<void*>(slot.ToInt()); entry->value = reinterpret_cast<void*>(slot.ToInt());
} }
...@@ -150,7 +149,6 @@ class FeedbackVectorSlotCache { ...@@ -150,7 +149,6 @@ class FeedbackVectorSlotCache {
} }
private: private:
Zone* zone_;
ZoneHashMap hash_map_; ZoneHashMap hash_map_;
}; };
...@@ -1530,7 +1528,7 @@ class AccessorTable ...@@ -1530,7 +1528,7 @@ class AccessorTable
zone_(zone) {} zone_(zone) {}
Iterator lookup(Literal* literal) { Iterator lookup(Literal* literal) {
Iterator it = find(literal, true, ZoneAllocationPolicy(zone_)); Iterator it = find(literal, true);
if (it->second == NULL) it->second = new (zone_) ObjectLiteral::Accessors(); if (it->second == NULL) it->second = new (zone_) ObjectLiteral::Accessors();
return it; return it;
} }
......
...@@ -36,9 +36,8 @@ Variable* VariableMap::Declare(Zone* zone, Scope* scope, ...@@ -36,9 +36,8 @@ Variable* VariableMap::Declare(Zone* zone, Scope* scope,
// AstRawStrings are unambiguous, i.e., the same string is always represented // AstRawStrings are unambiguous, i.e., the same string is always represented
// by the same AstRawString*. // by the same AstRawString*.
// FIXME(marja): fix the type of Lookup. // FIXME(marja): fix the type of Lookup.
Entry* p = Entry* p = ZoneHashMap::LookupOrInsert(const_cast<AstRawString*>(name),
ZoneHashMap::LookupOrInsert(const_cast<AstRawString*>(name), name->hash(), name->hash());
ZoneAllocationPolicy(zone));
if (added) *added = p->value == nullptr; if (added) *added = p->value == nullptr;
if (p->value == nullptr) { if (p->value == nullptr) {
// The variable has not been declared yet -> insert it. // The variable has not been declared yet -> insert it.
...@@ -54,11 +53,10 @@ void VariableMap::Remove(Variable* var) { ...@@ -54,11 +53,10 @@ void VariableMap::Remove(Variable* var) {
ZoneHashMap::Remove(const_cast<AstRawString*>(name), name->hash()); ZoneHashMap::Remove(const_cast<AstRawString*>(name), name->hash());
} }
void VariableMap::Add(Zone* zone, Variable* var) { void VariableMap::Add(Variable* var) {
const AstRawString* name = var->raw_name(); const AstRawString* name = var->raw_name();
Entry* p = Entry* p = ZoneHashMap::LookupOrInsert(const_cast<AstRawString*>(name),
ZoneHashMap::LookupOrInsert(const_cast<AstRawString*>(name), name->hash(), name->hash());
ZoneAllocationPolicy(zone));
DCHECK_NULL(p->value); DCHECK_NULL(p->value);
DCHECK_EQ(name, p->key); DCHECK_EQ(name, p->key);
p->value = var; p->value = var;
...@@ -77,13 +75,12 @@ Variable* VariableMap::Lookup(const AstRawString* name) { ...@@ -77,13 +75,12 @@ Variable* VariableMap::Lookup(const AstRawString* name) {
SloppyBlockFunctionMap::SloppyBlockFunctionMap(Zone* zone) SloppyBlockFunctionMap::SloppyBlockFunctionMap(Zone* zone)
: ZoneHashMap(ZoneHashMap::PointersMatch, 8, ZoneAllocationPolicy(zone)) {} : ZoneHashMap(ZoneHashMap::PointersMatch, 8, ZoneAllocationPolicy(zone)) {}
void SloppyBlockFunctionMap::Declare(Zone* zone, const AstRawString* name, void SloppyBlockFunctionMap::Declare(const AstRawString* name,
SloppyBlockFunctionStatement* stmt) { SloppyBlockFunctionStatement* stmt) {
// AstRawStrings are unambiguous, i.e., the same string is always represented // AstRawStrings are unambiguous, i.e., the same string is always represented
// by the same AstRawString*. // by the same AstRawString*.
Entry* p = Entry* p = ZoneHashMap::LookupOrInsert(const_cast<AstRawString*>(name),
ZoneHashMap::LookupOrInsert(const_cast<AstRawString*>(name), name->hash(), name->hash());
ZoneAllocationPolicy(zone));
stmt->set_next(static_cast<SloppyBlockFunctionStatement*>(p->value)); stmt->set_next(static_cast<SloppyBlockFunctionStatement*>(p->value));
p->value = stmt; p->value = stmt;
} }
...@@ -697,7 +694,7 @@ void Scope::Snapshot::Reparent(DeclarationScope* new_parent) const { ...@@ -697,7 +694,7 @@ void Scope::Snapshot::Reparent(DeclarationScope* new_parent) const {
new_parent->AddLocal(local); new_parent->AddLocal(local);
if (local->mode() == VAR) { if (local->mode() == VAR) {
outer_closure->variables_.Remove(local); outer_closure->variables_.Remove(local);
new_parent->variables_.Add(new_parent->zone(), local); new_parent->variables_.Add(local);
} }
} }
outer_closure->locals_.Rewind(top_local_); outer_closure->locals_.Rewind(top_local_);
......
...@@ -35,7 +35,7 @@ class VariableMap: public ZoneHashMap { ...@@ -35,7 +35,7 @@ class VariableMap: public ZoneHashMap {
Variable* Lookup(const AstRawString* name); Variable* Lookup(const AstRawString* name);
void Remove(Variable* var); void Remove(Variable* var);
void Add(Zone* zone, Variable* var); void Add(Variable* var);
}; };
...@@ -43,7 +43,7 @@ class VariableMap: public ZoneHashMap { ...@@ -43,7 +43,7 @@ class VariableMap: public ZoneHashMap {
class SloppyBlockFunctionMap : public ZoneHashMap { class SloppyBlockFunctionMap : public ZoneHashMap {
public: public:
explicit SloppyBlockFunctionMap(Zone* zone); explicit SloppyBlockFunctionMap(Zone* zone);
void Declare(Zone* zone, const AstRawString* name, void Declare(const AstRawString* name,
SloppyBlockFunctionStatement* statement); SloppyBlockFunctionStatement* statement);
}; };
...@@ -752,7 +752,7 @@ class DeclarationScope : public Scope { ...@@ -752,7 +752,7 @@ class DeclarationScope : public Scope {
void DeclareSloppyBlockFunction(const AstRawString* name, void DeclareSloppyBlockFunction(const AstRawString* name,
SloppyBlockFunctionStatement* statement) { SloppyBlockFunctionStatement* statement) {
sloppy_block_function_map_.Declare(zone(), name, statement); sloppy_block_function_map_.Declare(name, statement);
} }
// Go through sloppy_block_function_map_ and hoist those (into this scope) // Go through sloppy_block_function_map_ and hoist those (into this scope)
......
...@@ -55,11 +55,9 @@ class TemplateHashMapImpl { ...@@ -55,11 +55,9 @@ class TemplateHashMapImpl {
// If an entry with matching key is found, returns that entry. // If an entry with matching key is found, returns that entry.
// If no matching entry is found, a new entry is inserted with // If no matching entry is found, a new entry is inserted with
// corresponding key, key hash, and default initialized value. // corresponding key, key hash, and default initialized value.
Entry* LookupOrInsert(const Key& key, uint32_t hash, Entry* LookupOrInsert(const Key& key, uint32_t hash);
AllocationPolicy allocator = AllocationPolicy());
Entry* InsertNew(const Key& key, uint32_t hash, Entry* InsertNew(const Key& key, uint32_t hash);
AllocationPolicy allocator = AllocationPolicy());
// Removes the entry with matching key. // Removes the entry with matching key.
// It returns the value of the deleted entry // It returns the value of the deleted entry
...@@ -102,11 +100,12 @@ class TemplateHashMapImpl { ...@@ -102,11 +100,12 @@ class TemplateHashMapImpl {
Entry* map_; Entry* map_;
uint32_t capacity_; uint32_t capacity_;
uint32_t occupancy_; uint32_t occupancy_;
AllocationPolicy allocator_;
Entry* map_end() const { return map_ + capacity_; } Entry* map_end() const { return map_ + capacity_; }
Entry* Probe(const Key& key, uint32_t hash) const; Entry* Probe(const Key& key, uint32_t hash) const;
void Initialize(uint32_t capacity, AllocationPolicy allocator); void Initialize(uint32_t capacity);
void Resize(AllocationPolicy allocator); void Resize();
}; };
template <typename Key> template <typename Key>
...@@ -125,14 +124,15 @@ typedef TemplateHashMapImpl<void*, void*, DefaultAllocationPolicy> HashMap; ...@@ -125,14 +124,15 @@ typedef TemplateHashMapImpl<void*, void*, DefaultAllocationPolicy> HashMap;
template <typename Key, typename Value, class AllocationPolicy> template <typename Key, typename Value, class AllocationPolicy>
TemplateHashMapImpl<Key, Value, AllocationPolicy>::TemplateHashMapImpl( TemplateHashMapImpl<Key, Value, AllocationPolicy>::TemplateHashMapImpl(
MatchFun match, uint32_t initial_capacity, AllocationPolicy allocator) { MatchFun match, uint32_t initial_capacity, AllocationPolicy allocator)
: allocator_(allocator) {
match_ = match; match_ = match;
Initialize(initial_capacity, allocator); Initialize(initial_capacity);
} }
template <typename Key, typename Value, class AllocationPolicy> template <typename Key, typename Value, class AllocationPolicy>
TemplateHashMapImpl<Key, Value, AllocationPolicy>::~TemplateHashMapImpl() { TemplateHashMapImpl<Key, Value, AllocationPolicy>::~TemplateHashMapImpl() {
AllocationPolicy::Delete(map_); allocator_.Delete(map_);
} }
template <typename Key, typename Value, class AllocationPolicy> template <typename Key, typename Value, class AllocationPolicy>
...@@ -146,20 +146,20 @@ TemplateHashMapImpl<Key, Value, AllocationPolicy>::Lookup(const Key& key, ...@@ -146,20 +146,20 @@ TemplateHashMapImpl<Key, Value, AllocationPolicy>::Lookup(const Key& key,
template <typename Key, typename Value, class AllocationPolicy> template <typename Key, typename Value, class AllocationPolicy>
typename TemplateHashMapImpl<Key, Value, AllocationPolicy>::Entry* typename TemplateHashMapImpl<Key, Value, AllocationPolicy>::Entry*
TemplateHashMapImpl<Key, Value, AllocationPolicy>::LookupOrInsert( TemplateHashMapImpl<Key, Value, AllocationPolicy>::LookupOrInsert(
const Key& key, uint32_t hash, AllocationPolicy allocator) { const Key& key, uint32_t hash) {
// Find a matching entry. // Find a matching entry.
Entry* p = Probe(key, hash); Entry* p = Probe(key, hash);
if (p->exists()) { if (p->exists()) {
return p; return p;
} }
return InsertNew(key, hash, allocator); return InsertNew(key, hash);
} }
template <typename Key, typename Value, class AllocationPolicy> template <typename Key, typename Value, class AllocationPolicy>
typename TemplateHashMapImpl<Key, Value, AllocationPolicy>::Entry* typename TemplateHashMapImpl<Key, Value, AllocationPolicy>::Entry*
TemplateHashMapImpl<Key, Value, AllocationPolicy>::InsertNew( TemplateHashMapImpl<Key, Value, AllocationPolicy>::InsertNew(const Key& key,
const Key& key, uint32_t hash, AllocationPolicy allocator) { uint32_t hash) {
// Find a matching entry. // Find a matching entry.
Entry* p = Probe(key, hash); Entry* p = Probe(key, hash);
DCHECK(!p->exists()); DCHECK(!p->exists());
...@@ -171,7 +171,7 @@ TemplateHashMapImpl<Key, Value, AllocationPolicy>::InsertNew( ...@@ -171,7 +171,7 @@ TemplateHashMapImpl<Key, Value, AllocationPolicy>::InsertNew(
// Grow the map if we reached >= 80% occupancy. // Grow the map if we reached >= 80% occupancy.
if (occupancy_ + occupancy_ / 4 >= capacity_) { if (occupancy_ + occupancy_ / 4 >= capacity_) {
Resize(allocator); Resize();
p = Probe(key, hash); p = Probe(key, hash);
} }
...@@ -290,9 +290,9 @@ TemplateHashMapImpl<Key, Value, AllocationPolicy>::Probe(const Key& key, ...@@ -290,9 +290,9 @@ TemplateHashMapImpl<Key, Value, AllocationPolicy>::Probe(const Key& key,
template <typename Key, typename Value, class AllocationPolicy> template <typename Key, typename Value, class AllocationPolicy>
void TemplateHashMapImpl<Key, Value, AllocationPolicy>::Initialize( void TemplateHashMapImpl<Key, Value, AllocationPolicy>::Initialize(
uint32_t capacity, AllocationPolicy allocator) { uint32_t capacity) {
DCHECK(base::bits::IsPowerOfTwo32(capacity)); DCHECK(base::bits::IsPowerOfTwo32(capacity));
map_ = reinterpret_cast<Entry*>(allocator.New(capacity * sizeof(Entry))); map_ = reinterpret_cast<Entry*>(allocator_.New(capacity * sizeof(Entry)));
if (map_ == nullptr) { if (map_ == nullptr) {
FATAL("Out of memory: HashMap::Initialize"); FATAL("Out of memory: HashMap::Initialize");
return; return;
...@@ -302,25 +302,24 @@ void TemplateHashMapImpl<Key, Value, AllocationPolicy>::Initialize( ...@@ -302,25 +302,24 @@ void TemplateHashMapImpl<Key, Value, AllocationPolicy>::Initialize(
} }
template <typename Key, typename Value, class AllocationPolicy> template <typename Key, typename Value, class AllocationPolicy>
void TemplateHashMapImpl<Key, Value, AllocationPolicy>::Resize( void TemplateHashMapImpl<Key, Value, AllocationPolicy>::Resize() {
AllocationPolicy allocator) {
Entry* map = map_; Entry* map = map_;
uint32_t n = occupancy_; uint32_t n = occupancy_;
// Allocate larger map. // Allocate larger map.
Initialize(capacity_ * 2, allocator); Initialize(capacity_ * 2);
// Rehash all current entries. // Rehash all current entries.
for (Entry* p = map; n > 0; p++) { for (Entry* p = map; n > 0; p++) {
if (p->exists()) { if (p->exists()) {
Entry* entry = LookupOrInsert(p->key, p->hash, allocator); Entry* entry = LookupOrInsert(p->key, p->hash);
entry->value = p->value; entry->value = p->value;
n--; n--;
} }
} }
// Delete old map. // Delete old map.
AllocationPolicy::Delete(map); allocator_.Delete(map);
} }
// A hash map for pointer keys and values with an STL-like interface. // A hash map for pointer keys and values with an STL-like interface.
...@@ -368,10 +367,9 @@ class TemplateHashMap ...@@ -368,10 +367,9 @@ class TemplateHashMap
Iterator begin() const { return Iterator(this, this->Start()); } Iterator begin() const { return Iterator(this, this->Start()); }
Iterator end() const { return Iterator(this, nullptr); } Iterator end() const { return Iterator(this, nullptr); }
Iterator find(Key* key, bool insert = false, Iterator find(Key* key, bool insert = false) {
AllocationPolicy allocator = AllocationPolicy()) {
if (insert) { if (insert) {
return Iterator(this, this->LookupOrInsert(key, key->Hash(), allocator)); return Iterator(this, this->LookupOrInsert(key, key->Hash()));
} }
return Iterator(this, this->Lookup(key, key->Hash())); return Iterator(this, this->Lookup(key, key->Hash()));
} }
......
...@@ -104,8 +104,7 @@ int StateValuesHashKey(Node** nodes, size_t count) { ...@@ -104,8 +104,7 @@ int StateValuesHashKey(Node** nodes, size_t count) {
Node* StateValuesCache::GetValuesNodeFromCache(Node** nodes, size_t count) { Node* StateValuesCache::GetValuesNodeFromCache(Node** nodes, size_t count) {
StateValuesKey key(count, nodes); StateValuesKey key(count, nodes);
int hash = StateValuesHashKey(nodes, count); int hash = StateValuesHashKey(nodes, count);
ZoneHashMap::Entry* lookup = ZoneHashMap::Entry* lookup = hash_map_.LookupOrInsert(&key, hash);
hash_map_.LookupOrInsert(&key, hash, ZoneAllocationPolicy(zone()));
DCHECK_NOT_NULL(lookup); DCHECK_NOT_NULL(lookup);
Node* node; Node* node;
if (lookup->value == nullptr) { if (lookup->value == nullptr) {
......
...@@ -316,16 +316,14 @@ BoundsCheckTable::BoundsCheckTable(Zone* zone) ...@@ -316,16 +316,14 @@ BoundsCheckTable::BoundsCheckTable(Zone* zone)
BoundsCheckBbData** BoundsCheckTable::LookupOrInsert(BoundsCheckKey* key, BoundsCheckBbData** BoundsCheckTable::LookupOrInsert(BoundsCheckKey* key,
Zone* zone) { Zone* zone) {
return reinterpret_cast<BoundsCheckBbData**>( return reinterpret_cast<BoundsCheckBbData**>(
&(ZoneHashMap::LookupOrInsert(key, key->Hash(), &(ZoneHashMap::LookupOrInsert(key, key->Hash())->value));
ZoneAllocationPolicy(zone))->value));
} }
void BoundsCheckTable::Insert(BoundsCheckKey* key, void BoundsCheckTable::Insert(BoundsCheckKey* key,
BoundsCheckBbData* data, BoundsCheckBbData* data,
Zone* zone) { Zone* zone) {
ZoneHashMap::LookupOrInsert(key, key->Hash(), ZoneAllocationPolicy(zone)) ZoneHashMap::LookupOrInsert(key, key->Hash())->value = data;
->value = data;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment