Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Unified Diff: src/objects.cc

Issue 126262: Reimplemented the KeyedLookupCache to speed up access. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
===================================================================
--- src/objects.cc (revision 2194)
+++ src/objects.cc (working copy)
@@ -6756,60 +6756,6 @@
};
-// MapNameKeys are used as keys in lookup caches.
-class MapNameKey : public HashTableKey {
- public:
- MapNameKey(Map* map, String* name)
- : map_(map), name_(name) { }
-
- bool IsMatch(Object* other) {
- if (!other->IsFixedArray()) return false;
- FixedArray* pair = FixedArray::cast(other);
- Map* map = Map::cast(pair->get(0));
- if (map != map_) return false;
- String* name = String::cast(pair->get(1));
- return name->Equals(name_);
- }
-
- typedef uint32_t (*HashFunction)(Object* obj);
-
- virtual HashFunction GetHashFunction() { return MapNameHash; }
-
- static uint32_t MapNameHashHelper(Map* map, String* name) {
- // Uses only lower 32 bits if pointers are larger.
- uintptr_t addr_hash =
- static_cast<uint32_t>(reinterpret_cast<uintptr_t>(map));
- return addr_hash ^ name->Hash();
- }
-
- static uint32_t MapNameHash(Object* obj) {
- FixedArray* pair = FixedArray::cast(obj);
- Map* map = Map::cast(pair->get(0));
- String* name = String::cast(pair->get(1));
- return MapNameHashHelper(map, name);
- }
-
- virtual uint32_t Hash() {
- return MapNameHashHelper(map_, name_);
- }
-
- virtual Object* GetObject() {
- Object* obj = Heap::AllocateFixedArray(2);
- if (obj->IsFailure()) return obj;
- FixedArray* pair = FixedArray::cast(obj);
- pair->set(0, map_);
- pair->set(1, name_);
- return pair;
- }
-
- virtual bool IsStringKey() { return false; }
-
- private:
- Map* map_;
- String* name_;
-};
-
-
Object* MapCache::Lookup(FixedArray* array) {
SymbolsKey key(array);
int entry = FindEntry(&key);
@@ -6832,31 +6778,6 @@
}
-int LookupCache::Lookup(Map* map, String* name) {
- MapNameKey key(map, name);
- int entry = FindEntry(&key);
- if (entry == -1) return kNotFound;
- return Smi::cast(get(EntryToIndex(entry) + 1))->value();
-}
-
-
-Object* LookupCache::Put(Map* map, String* name, int value) {
- MapNameKey key(map, name);
- Object* obj = EnsureCapacity(1, &key);
- if (obj->IsFailure()) return obj;
- Object* k = key.GetObject();
- if (k->IsFailure()) return k;
-
- LookupCache* cache = reinterpret_cast<LookupCache*>(obj);
- int entry = cache->FindInsertionEntry(k, key.Hash());
- int index = EntryToIndex(entry);
- cache->set(index, k);
- cache->set(index + 1, Smi::FromInt(value), SKIP_WRITE_BARRIER);
- cache->ElementAdded();
- return cache;
-}
-
-
Object* Dictionary::Allocate(int at_least_space_for) {
Object* obj = DictionaryBase::Allocate(at_least_space_for);
// Initialize the next enumeration index.
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698