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

Side by Side Diff: src/objects.h

Issue 757143002: Optimize non-mutation Map and Set operations for String keys (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add lots more stuff Created 6 years 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_OBJECTS_H_ 5 #ifndef V8_OBJECTS_H_
6 #define V8_OBJECTS_H_ 6 #define V8_OBJECTS_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 3883 matching lines...) Expand 10 before | Expand all | Expand 10 after
3894 } 3894 }
3895 3895
3896 // When the table is obsolete we store the indexes of the removed holes. 3896 // When the table is obsolete we store the indexes of the removed holes.
3897 int RemovedIndexAt(int index) { 3897 int RemovedIndexAt(int index) {
3898 return Smi::cast(get(kRemovedHolesIndex + index))->value(); 3898 return Smi::cast(get(kRemovedHolesIndex + index))->value();
3899 } 3899 }
3900 3900
3901 static const int kNotFound = -1; 3901 static const int kNotFound = -1;
3902 static const int kMinCapacity = 4; 3902 static const int kMinCapacity = 4;
3903 3903
3904 static const int kNumberOfBucketsIndex = 0;
3905 static const int kNumberOfElementsIndex = kNumberOfBucketsIndex + 1;
3906 static const int kNumberOfDeletedElementsIndex = kNumberOfElementsIndex + 1;
3907 static const int kHashTableStartIndex = kNumberOfDeletedElementsIndex + 1;
3908
3909 static const int kEntrySize = entrysize + 1;
3910 static const int kChainOffset = entrysize;
3911
3904 private: 3912 private:
3905 static Handle<Derived> Rehash(Handle<Derived> table, int new_capacity); 3913 static Handle<Derived> Rehash(Handle<Derived> table, int new_capacity);
3906 3914
3907 void SetNumberOfBuckets(int num) { 3915 void SetNumberOfBuckets(int num) {
3908 set(kNumberOfBucketsIndex, Smi::FromInt(num)); 3916 set(kNumberOfBucketsIndex, Smi::FromInt(num));
3909 } 3917 }
3910 3918
3911 void SetNumberOfElements(int num) { 3919 void SetNumberOfElements(int num) {
3912 set(kNumberOfElementsIndex, Smi::FromInt(num)); 3920 set(kNumberOfElementsIndex, Smi::FromInt(num));
3913 } 3921 }
(...skipping 21 matching lines...) Expand all
3935 } 3943 }
3936 3944
3937 void SetNextTable(Derived* next_table) { 3945 void SetNextTable(Derived* next_table) {
3938 set(kNextTableIndex, next_table); 3946 set(kNextTableIndex, next_table);
3939 } 3947 }
3940 3948
3941 void SetRemovedIndexAt(int index, int removed_index) { 3949 void SetRemovedIndexAt(int index, int removed_index) {
3942 return set(kRemovedHolesIndex + index, Smi::FromInt(removed_index)); 3950 return set(kRemovedHolesIndex + index, Smi::FromInt(removed_index));
3943 } 3951 }
3944 3952
3945 static const int kNumberOfBucketsIndex = 0;
3946 static const int kNumberOfElementsIndex = kNumberOfBucketsIndex + 1;
3947 static const int kNumberOfDeletedElementsIndex = kNumberOfElementsIndex + 1;
3948 static const int kHashTableStartIndex = kNumberOfDeletedElementsIndex + 1;
3949
3950 static const int kNextTableIndex = kNumberOfElementsIndex; 3953 static const int kNextTableIndex = kNumberOfElementsIndex;
3951 static const int kRemovedHolesIndex = kHashTableStartIndex; 3954 static const int kRemovedHolesIndex = kHashTableStartIndex;
3952 3955
3953 static const int kEntrySize = entrysize + 1;
3954 static const int kChainOffset = entrysize;
3955
3956 static const int kLoadFactor = 2; 3956 static const int kLoadFactor = 2;
3957 static const int kMaxCapacity = 3957 static const int kMaxCapacity =
3958 (FixedArray::kMaxLength - kHashTableStartIndex) 3958 (FixedArray::kMaxLength - kHashTableStartIndex)
3959 / (1 + (kEntrySize * kLoadFactor)); 3959 / (1 + (kEntrySize * kLoadFactor));
3960 }; 3960 };
3961 3961
3962 3962
3963 class JSSetIterator; 3963 class JSSetIterator;
3964 3964
3965 3965
(...skipping 19 matching lines...) Expand all
3985 Object* Lookup(Handle<Object> key); 3985 Object* Lookup(Handle<Object> key);
3986 static Handle<OrderedHashMap> Put( 3986 static Handle<OrderedHashMap> Put(
3987 Handle<OrderedHashMap> table, 3987 Handle<OrderedHashMap> table,
3988 Handle<Object> key, 3988 Handle<Object> key,
3989 Handle<Object> value); 3989 Handle<Object> value);
3990 3990
3991 Object* ValueAt(int entry) { 3991 Object* ValueAt(int entry) {
3992 return get(EntryToIndex(entry) + kValueOffset); 3992 return get(EntryToIndex(entry) + kValueOffset);
3993 } 3993 }
3994 3994
3995 private:
3996 static const int kValueOffset = 1; 3995 static const int kValueOffset = 1;
3997 }; 3996 };
3998 3997
3999 3998
4000 template <int entrysize> 3999 template <int entrysize>
4001 class WeakHashTableShape : public BaseShape<Handle<Object> > { 4000 class WeakHashTableShape : public BaseShape<Handle<Object> > {
4002 public: 4001 public:
4003 static inline bool IsMatch(Handle<Object> key, Object* other); 4002 static inline bool IsMatch(Handle<Object> key, Object* other);
4004 static inline uint32_t Hash(Handle<Object> key); 4003 static inline uint32_t Hash(Handle<Object> key);
4005 static inline uint32_t HashForObject(Handle<Object> key, Object* object); 4004 static inline uint32_t HashForObject(Handle<Object> key, Object* object);
(...skipping 6973 matching lines...) Expand 10 before | Expand all | Expand 10 after
10979 } else { 10978 } else {
10980 value &= ~(1 << bit_position); 10979 value &= ~(1 << bit_position);
10981 } 10980 }
10982 return value; 10981 return value;
10983 } 10982 }
10984 }; 10983 };
10985 10984
10986 } } // namespace v8::internal 10985 } } // namespace v8::internal
10987 10986
10988 #endif // V8_OBJECTS_H_ 10987 #endif // V8_OBJECTS_H_
OLDNEW
« src/hydrogen.cc ('K') | « src/hydrogen.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698