Revision: 20773
Author: ma...@chromium.org
Date: Tue Apr 15 14:48:21 2014 UTC
Log: Refactoring: HashMap: provide a pointer match function, so users
don't need to.
R=yang...@chromium.org
Review URL: https://codereview.chromium.org/239133002
http://code.google.com/p/v8/source/detail?r=20773
Modified:
/branches/bleeding_edge/src/allocation-tracker.cc
/branches/bleeding_edge/src/bootstrapper.cc
/branches/bleeding_edge/src/debug.h
/branches/bleeding_edge/src/hashmap.h
/branches/bleeding_edge/src/heap-snapshot-generator.cc
/branches/bleeding_edge/src/heap-snapshot-generator.h
/branches/bleeding_edge/src/serialize.cc
/branches/bleeding_edge/src/serialize.h
=======================================
--- /branches/bleeding_edge/src/allocation-tracker.cc Fri Mar 7 16:34:10
2014 UTC
+++ /branches/bleeding_edge/src/allocation-tracker.cc Tue Apr 15 14:48:21
2014 UTC
@@ -209,11 +209,6 @@
ranges_.insert(RangeMap::value_type(start, prev_range));
}
}
-
-
-static bool AddressesMatch(void* key1, void* key2) {
- return key1 == key2;
-}
void AllocationTracker::DeleteFunctionInfo(FunctionInfo** info) {
@@ -225,7 +220,7 @@
HeapObjectsMap* ids, StringsStorage* names)
: ids_(ids),
names_(names),
- id_to_function_info_index_(AddressesMatch),
+ id_to_function_info_index_(HashMap::PointersMatch),
info_index_for_other_state_(0) {
FunctionInfo* info = new FunctionInfo();
info->name = "(root)";
=======================================
--- /branches/bleeding_edge/src/bootstrapper.cc Tue Apr 15 13:25:17 2014 UTC
+++ /branches/bleeding_edge/src/bootstrapper.cc Tue Apr 15 14:48:21 2014 UTC
@@ -2179,12 +2179,7 @@
}
-static bool MatchRegisteredExtensions(void* key1, void* key2) {
- return key1 == key2;
-}
-
-Genesis::ExtensionStates::ExtensionStates()
- : map_(MatchRegisteredExtensions, 8) { }
+Genesis::ExtensionStates::ExtensionStates() : map_(HashMap::PointersMatch,
8) {}
Genesis::ExtensionTraversalState Genesis::ExtensionStates::get_state(
RegisteredExtension* extension) {
=======================================
--- /branches/bleeding_edge/src/debug.h Fri Apr 11 10:41:09 2014 UTC
+++ /branches/bleeding_edge/src/debug.h Tue Apr 15 14:48:21 2014 UTC
@@ -175,7 +175,9 @@
class ScriptCache : private HashMap {
public:
explicit ScriptCache(Isolate* isolate)
- : HashMap(ScriptMatch), isolate_(isolate), collected_scripts_(10) {}
+ : HashMap(HashMap::PointersMatch),
+ isolate_(isolate),
+ collected_scripts_(10) {}
virtual ~ScriptCache() { Clear(); }
// Add script to the cache.
@@ -192,9 +194,6 @@
static uint32_t Hash(int key) {
return ComputeIntegerHash(key, v8::internal::kZeroHashSeed);
}
-
- // Scripts match if their keys (script id) match.
- static bool ScriptMatch(void* key1, void* key2) { return key1 == key2; }
// Clear the cache releasing all the weak handles.
void Clear();
=======================================
--- /branches/bleeding_edge/src/hashmap.h Thu Aug 23 08:15:38 2012 UTC
+++ /branches/bleeding_edge/src/hashmap.h Tue Apr 15 14:48:21 2014 UTC
@@ -97,6 +97,11 @@
// calling Next() is undefined.
Entry* Start() const;
Entry* Next(Entry* p) const;
+
+ // Some match functions defined for convenience.
+ static bool PointersMatch(void* key1, void* key2) {
+ return key1 == key2;
+ }
private:
MatchFun match_;
=======================================
--- /branches/bleeding_edge/src/heap-snapshot-generator.cc Fri Apr 4
04:49:07 2014 UTC
+++ /branches/bleeding_edge/src/heap-snapshot-generator.cc Tue Apr 15
14:48:21 2014 UTC
@@ -732,7 +732,7 @@
HeapEntriesMap::HeapEntriesMap()
- : entries_(HeapThingsMatch) {
+ : entries_(HashMap::PointersMatch) {
}
@@ -751,7 +751,7 @@
HeapObjectsSet::HeapObjectsSet()
- : entries_(HeapEntriesMap::HeapThingsMatch) {
+ : entries_(HashMap::PointersMatch) {
}
=======================================
--- /branches/bleeding_edge/src/heap-snapshot-generator.h Wed Apr 2
11:19:53 2014 UTC
+++ /branches/bleeding_edge/src/heap-snapshot-generator.h Tue Apr 15
14:48:21 2014 UTC
@@ -315,9 +315,6 @@
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(thing)),
v8::internal::kZeroHashSeed);
}
- static bool HeapThingsMatch(HeapThing key1, HeapThing key2) {
- return key1 == key2;
- }
HashMap entries_;
=======================================
--- /branches/bleeding_edge/src/serialize.cc Tue Apr 15 13:25:17 2014 UTC
+++ /branches/bleeding_edge/src/serialize.cc Tue Apr 15 14:48:21 2014 UTC
@@ -586,7 +586,7 @@
ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate)
- : encodings_(Match),
+ : encodings_(HashMap::PointersMatch),
isolate_(isolate) {
ExternalReferenceTable* external_references =
ExternalReferenceTable::instance(isolate_);
@@ -680,7 +680,7 @@
private:
class NameMap {
public:
- NameMap() : impl_(&PointerEquals) {}
+ NameMap() : impl_(HashMap::PointersMatch) {}
~NameMap() {
for (HashMap::Entry* p = impl_.Start(); p != NULL; p =
impl_.Next(p)) {
@@ -720,10 +720,6 @@
}
private:
- static bool PointerEquals(void* lhs, void* rhs) {
- return lhs == rhs;
- }
-
static char* CopyName(const char* name, int name_size) {
char* result = NewArray<char>(name_size + 1);
for (int i = 0; i < name_size; ++i) {
=======================================
--- /branches/bleeding_edge/src/serialize.h Wed Mar 12 13:13:13 2014 UTC
+++ /branches/bleeding_edge/src/serialize.h Tue Apr 15 14:48:21 2014 UTC
@@ -123,8 +123,6 @@
}
int IndexOf(Address key) const;
-
- static bool Match(void* key1, void* key2) { return key1 == key2; }
void Put(Address key, int index);
@@ -414,7 +412,7 @@
public:
SerializationAddressMapper()
: no_allocation_(),
- serialization_map_(new HashMap(&SerializationMatchFun)) { }
+ serialization_map_(new HashMap(HashMap::PointersMatch)) { }
~SerializationAddressMapper() {
delete serialization_map_;
@@ -438,10 +436,6 @@
}
private:
- static bool SerializationMatchFun(void* key1, void* key2) {
- return key1 == key2;
- }
-
static uint32_t Hash(HeapObject* obj) {
return
static_cast<int32_t>(reinterpret_cast<intptr_t>(obj->address()));
}
--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.