Commit 837c91e8 authored by leszeks's avatar leszeks Committed by Commit bot

[base] Template MatchFun in TemplateHashMapImpl

Make MatchFun a template parameter in TemplateHashMapImpl, moving the
PointersMatch function down to an implementation which extends
TemplateHashMapImpl to void* key and value (i.e. the same as the current
HashMap and ZoneHashMap typedefs).

This will allow other instantiations of TemplateHashMapImpl, with
different MatchFun values, e.g. std::equal_to, to have their key
equality test inlined, rather than calling a function pointer,

Review-Url: https://codereview.chromium.org/2354593002
Cr-Commit-Position: refs/heads/master@{#39868}
parent 4b27480e
......@@ -13,7 +13,7 @@ namespace internal {
RootIndexMap::RootIndexMap(Isolate* isolate) {
map_ = isolate->root_index_map();
if (map_ != NULL) return;
map_ = new base::HashMap(base::HashMap::PointersMatch);
map_ = new base::HashMap();
for (uint32_t i = 0; i < Heap::kStrongRootListLength; i++) {
Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i);
Object* root = isolate->heap()->root(root_index);
......
......@@ -189,9 +189,7 @@ class SerializerReference {
class SerializerReferenceMap : public AddressMapBase {
public:
SerializerReferenceMap()
: no_allocation_(),
map_(base::HashMap::PointersMatch),
attached_reference_index_(0) {}
: no_allocation_(), map_(), attached_reference_index_(0) {}
SerializerReference Lookup(HeapObject* obj) {
base::HashMap::Entry* entry = LookupEntry(&map_, obj, false);
......
This diff is collapsed.
......@@ -2016,7 +2016,7 @@ static uint32_t HashCodeAddress(Address addr) {
static base::HashMap* GetLineMap() {
static base::HashMap* line_map = NULL;
if (line_map == NULL) {
line_map = new base::HashMap(&base::HashMap::PointersMatch);
line_map = new base::HashMap();
}
return line_map;
}
......
......@@ -217,7 +217,7 @@ class Sampler::PlatformData {
class SamplerManager {
public:
SamplerManager() : sampler_map_(base::HashMap::PointersMatch) {}
SamplerManager() : sampler_map_() {}
void AddSampler(Sampler* sampler) {
AtomicGuard atomic_guard(&samplers_access_counter_);
......
......@@ -193,7 +193,7 @@ void AllocationTracker::DeleteFunctionInfo(FunctionInfo** info) {
AllocationTracker::AllocationTracker(HeapObjectsMap* ids, StringsStorage* names)
: ids_(ids),
names_(names),
id_to_function_info_index_(base::HashMap::PointersMatch),
id_to_function_info_index_(),
info_index_for_other_state_(0) {
FunctionInfo* info = new FunctionInfo();
info->name = "(root)";
......
......@@ -704,7 +704,7 @@ size_t HeapObjectsMap::GetUsedMemorySize() const {
GetMemoryUsedByList(entries_) + GetMemoryUsedByList(time_intervals_);
}
HeapEntriesMap::HeapEntriesMap() : entries_(base::HashMap::PointersMatch) {}
HeapEntriesMap::HeapEntriesMap() : entries_() {}
int HeapEntriesMap::Map(HeapThing thing) {
base::HashMap::Entry* cache_entry = entries_.Lookup(thing, Hash(thing));
......@@ -720,7 +720,7 @@ void HeapEntriesMap::Pair(HeapThing thing, int entry) {
cache_entry->value = reinterpret_cast<void*>(static_cast<intptr_t>(entry));
}
HeapObjectsSet::HeapObjectsSet() : entries_(base::HashMap::PointersMatch) {}
HeapObjectsSet::HeapObjectsSet() : entries_() {}
void HeapObjectsSet::Clear() {
entries_.Clear();
......
......@@ -14,7 +14,7 @@ namespace internal {
ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) {
map_ = isolate->external_reference_map();
if (map_ != NULL) return;
map_ = new base::HashMap(base::HashMap::PointersMatch);
map_ = new base::HashMap();
ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate);
for (int i = 0; i < table->size(); ++i) {
Address addr = table->address(i);
......
......@@ -38,7 +38,7 @@ class CodeAddressMap : public CodeEventLogger {
private:
class NameMap {
public:
NameMap() : impl_(base::HashMap::PointersMatch) {}
NameMap() : impl_() {}
~NameMap() {
for (base::HashMap::Entry* p = impl_.Start(); p != NULL;
......
......@@ -32,8 +32,7 @@ class StartupSerializer : public Serializer {
private:
class PartialCacheIndexMap : public AddressMapBase {
public:
PartialCacheIndexMap()
: map_(base::HashMap::PointersMatch), next_index_(0) {}
PartialCacheIndexMap() : map_(), next_index_(0) {}
// Lookup object in the map. Return its index if found, or create
// a new entry with new_index as value, and return kInvalidIndex.
......
......@@ -232,8 +232,7 @@ class ZoneSplayTree final : public SplayTree<Config, ZoneAllocationPolicy> {
void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); }
};
typedef base::TemplateHashMapImpl<void*, void*, ZoneAllocationPolicy>
ZoneHashMap;
typedef base::PointerTemplateHashMapImpl<ZoneAllocationPolicy> ZoneHashMap;
} // namespace internal
} // namespace v8
......
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