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

Side by Side Diff: src/objects.h

Issue 240023004: Handlify HashTable and Dictionary growing. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CR feedback Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/factory.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3840 matching lines...) Expand 10 before | Expand all | Expand 10 after
3851 void Rehash(Derived* new_table, Key key); 3851 void Rehash(Derived* new_table, Key key);
3852 3852
3853 // Attempt to shrink hash table after removal of key. 3853 // Attempt to shrink hash table after removal of key.
3854 static Handle<Derived> Shrink(Handle<Derived> table, Key key); 3854 static Handle<Derived> Shrink(Handle<Derived> table, Key key);
3855 3855
3856 // Ensure enough space for n additional elements. 3856 // Ensure enough space for n additional elements.
3857 MUST_USE_RESULT MaybeObject* EnsureCapacity( 3857 MUST_USE_RESULT MaybeObject* EnsureCapacity(
3858 int n, 3858 int n,
3859 Key key, 3859 Key key,
3860 PretenureFlag pretenure = NOT_TENURED); 3860 PretenureFlag pretenure = NOT_TENURED);
3861 static Handle<Derived> EnsureCapacity(
3862 Handle<Derived> table,
3863 int n,
3864 Key key,
3865 PretenureFlag pretenure = NOT_TENURED);
3861 }; 3866 };
3862 3867
3863 3868
3864 // HashTableKey is an abstract superclass for virtual key behavior. 3869 // HashTableKey is an abstract superclass for virtual key behavior.
3865 class HashTableKey { 3870 class HashTableKey {
3866 public: 3871 public:
3867 // Returns whether the other object matches this key. 3872 // Returns whether the other object matches this key.
3868 virtual bool IsMatch(Object* other) = 0; 3873 virtual bool IsMatch(Object* other) = 0;
3869 // Returns the hash value for this key. 3874 // Returns the hash value for this key.
3870 virtual uint32_t Hash() = 0; 3875 virtual uint32_t Hash() = 0;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
3957 3962
3958 3963
3959 // MapCache. 3964 // MapCache.
3960 // 3965 //
3961 // Maps keys that are a fixed array of unique names to a map. 3966 // Maps keys that are a fixed array of unique names to a map.
3962 // Used for canonicalize maps for object literals. 3967 // Used for canonicalize maps for object literals.
3963 class MapCache: public HashTable<MapCache, MapCacheShape, HashTableKey*> { 3968 class MapCache: public HashTable<MapCache, MapCacheShape, HashTableKey*> {
3964 public: 3969 public:
3965 // Find cached value for a name key, otherwise return null. 3970 // Find cached value for a name key, otherwise return null.
3966 Object* Lookup(FixedArray* key); 3971 Object* Lookup(FixedArray* key);
3967 MUST_USE_RESULT MaybeObject* Put(FixedArray* key, Map* value); 3972 static Handle<MapCache> Put(
3973 Handle<MapCache> map_cache, Handle<FixedArray> key, Handle<Map> value);
3968 static inline MapCache* cast(Object* obj); 3974 static inline MapCache* cast(Object* obj);
3969 3975
3970 private: 3976 private:
3971 DISALLOW_IMPLICIT_CONSTRUCTORS(MapCache); 3977 DISALLOW_IMPLICIT_CONSTRUCTORS(MapCache);
3972 }; 3978 };
3973 3979
3974 3980
3975 template <typename Derived, typename Shape, typename Key> 3981 template <typename Derived, typename Shape, typename Key>
3976 class Dictionary: public HashTable<Derived, Shape, Key> { 3982 class Dictionary: public HashTable<Derived, Shape, Key> {
3977 protected: 3983 protected:
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
4056 4062
4057 // Creates a new dictionary. 4063 // Creates a new dictionary.
4058 static Handle<Derived> New( 4064 static Handle<Derived> New(
4059 Isolate* isolate, 4065 Isolate* isolate,
4060 int at_least_space_for, 4066 int at_least_space_for,
4061 PretenureFlag pretenure = NOT_TENURED); 4067 PretenureFlag pretenure = NOT_TENURED);
4062 4068
4063 // Ensure enough space for n additional elements. 4069 // Ensure enough space for n additional elements.
4064 MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key); 4070 MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key);
4065 4071
4072 static Handle<Derived> EnsureCapacity(Handle<Derived> obj, int n, Key key);
4073
4066 #ifdef OBJECT_PRINT 4074 #ifdef OBJECT_PRINT
4067 void Print(FILE* out = stdout); 4075 void Print(FILE* out = stdout);
4068 #endif 4076 #endif
4069 // Returns the key (slow). 4077 // Returns the key (slow).
4070 Object* SlowReverseLookup(Object* value); 4078 Object* SlowReverseLookup(Object* value);
4071 4079
4072 // Sets the entry to (key, value) pair. 4080 // Sets the entry to (key, value) pair.
4073 inline void SetEntry(int entry, 4081 inline void SetEntry(int entry,
4074 Object* key, 4082 Object* key,
4075 Object* value); 4083 Object* value);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
4266 class ObjectHashTable: public HashTable<ObjectHashTable, 4274 class ObjectHashTable: public HashTable<ObjectHashTable,
4267 ObjectHashTableShape, 4275 ObjectHashTableShape,
4268 Object*> { 4276 Object*> {
4269 typedef HashTable<ObjectHashTable, ObjectHashTableShape, Object*> HashTable_; 4277 typedef HashTable<ObjectHashTable, ObjectHashTableShape, Object*> HashTable_;
4270 public: 4278 public:
4271 static inline ObjectHashTable* cast(Object* obj) { 4279 static inline ObjectHashTable* cast(Object* obj) {
4272 ASSERT(obj->IsHashTable()); 4280 ASSERT(obj->IsHashTable());
4273 return reinterpret_cast<ObjectHashTable*>(obj); 4281 return reinterpret_cast<ObjectHashTable*>(obj);
4274 } 4282 }
4275 4283
4276 static Handle<ObjectHashTable> EnsureCapacity(
4277 Handle<ObjectHashTable> table,
4278 int n,
4279 Handle<Object> key,
4280 PretenureFlag pretenure = NOT_TENURED);
4281
4282 // Attempt to shrink hash table after removal of key. 4284 // Attempt to shrink hash table after removal of key.
4283 static inline Handle<ObjectHashTable> Shrink(Handle<ObjectHashTable> table, 4285 static inline Handle<ObjectHashTable> Shrink(Handle<ObjectHashTable> table,
4284 Handle<Object> key); 4286 Handle<Object> key);
4285 4287
4286 // Looks up the value associated with the given key. The hole value is 4288 // Looks up the value associated with the given key. The hole value is
4287 // returned in case the key is not present. 4289 // returned in case the key is not present.
4288 Object* Lookup(Object* key); 4290 Object* Lookup(Object* key);
4289 4291
4290 // Adds (or overwrites) the value associated with the given key. Mapping a 4292 // Adds (or overwrites) the value associated with the given key. Mapping a
4291 // key to the hole value causes removal of the whole entry. 4293 // key to the hole value causes removal of the whole entry.
(...skipping 3986 matching lines...) Expand 10 before | Expand all | Expand 10 after
8278 static Handle<CompilationCacheTable> Put( 8280 static Handle<CompilationCacheTable> Put(
8279 Handle<CompilationCacheTable> cache, Handle<String> src, 8281 Handle<CompilationCacheTable> cache, Handle<String> src,
8280 Handle<Context> context, Handle<Object> value); 8282 Handle<Context> context, Handle<Object> value);
8281 static Handle<CompilationCacheTable> PutEval( 8283 static Handle<CompilationCacheTable> PutEval(
8282 Handle<CompilationCacheTable> cache, Handle<String> src, 8284 Handle<CompilationCacheTable> cache, Handle<String> src,
8283 Handle<Context> context, Handle<SharedFunctionInfo> value, 8285 Handle<Context> context, Handle<SharedFunctionInfo> value,
8284 int scope_position); 8286 int scope_position);
8285 static Handle<CompilationCacheTable> PutRegExp( 8287 static Handle<CompilationCacheTable> PutRegExp(
8286 Handle<CompilationCacheTable> cache, Handle<String> src, 8288 Handle<CompilationCacheTable> cache, Handle<String> src,
8287 JSRegExp::Flags flags, Handle<FixedArray> value); 8289 JSRegExp::Flags flags, Handle<FixedArray> value);
8288 static Handle<CompilationCacheTable> EnsureCapacityFor(
8289 Handle<CompilationCacheTable> cache, int n, HashTableKey* key);
8290 void Remove(Object* value); 8290 void Remove(Object* value);
8291 8291
8292 static inline CompilationCacheTable* cast(Object* obj); 8292 static inline CompilationCacheTable* cast(Object* obj);
8293 8293
8294 private: 8294 private:
8295 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheTable); 8295 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheTable);
8296 }; 8296 };
8297 8297
8298 8298
8299 class CodeCache: public Struct { 8299 class CodeCache: public Struct {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
8383 8383
8384 int GetIndex(Name* name, Code::Flags flags); 8384 int GetIndex(Name* name, Code::Flags flags);
8385 void RemoveByIndex(int index); 8385 void RemoveByIndex(int index);
8386 8386
8387 static inline CodeCacheHashTable* cast(Object* obj); 8387 static inline CodeCacheHashTable* cast(Object* obj);
8388 8388
8389 // Initial size of the fixed array backing the hash table. 8389 // Initial size of the fixed array backing the hash table.
8390 static const int kInitialSize = 64; 8390 static const int kInitialSize = 64;
8391 8391
8392 private: 8392 private:
8393 MUST_USE_RESULT MaybeObject* Put(Name* name, Code* code);
8394
8395 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeCacheHashTable); 8393 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeCacheHashTable);
8396 }; 8394 };
8397 8395
8398 8396
8399 class PolymorphicCodeCache: public Struct { 8397 class PolymorphicCodeCache: public Struct {
8400 public: 8398 public:
8401 DECL_ACCESSORS(cache, Object) 8399 DECL_ACCESSORS(cache, Object)
8402 8400
8403 static void Update(Handle<PolymorphicCodeCache> cache, 8401 static void Update(Handle<PolymorphicCodeCache> cache,
8404 MapHandleList* maps, 8402 MapHandleList* maps,
(...skipping 2697 matching lines...) Expand 10 before | Expand all | Expand 10 after
11102 } else { 11100 } else {
11103 value &= ~(1 << bit_position); 11101 value &= ~(1 << bit_position);
11104 } 11102 }
11105 return value; 11103 return value;
11106 } 11104 }
11107 }; 11105 };
11108 11106
11109 } } // namespace v8::internal 11107 } } // namespace v8::internal
11110 11108
11111 #endif // V8_OBJECTS_H_ 11109 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/factory.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698