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

Side by Side Diff: src/objects.h

Issue 773993002: Optimize add/set/delete operations for string keys in Maps and Sets (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add shrinking logic 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
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/runtime/runtime.h » ('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 // 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 3897 matching lines...) Expand 10 before | Expand all | Expand 10 after
3908 3908
3909 static const int kNumberOfBucketsIndex = 0; 3909 static const int kNumberOfBucketsIndex = 0;
3910 static const int kNumberOfElementsIndex = kNumberOfBucketsIndex + 1; 3910 static const int kNumberOfElementsIndex = kNumberOfBucketsIndex + 1;
3911 static const int kNumberOfDeletedElementsIndex = kNumberOfElementsIndex + 1; 3911 static const int kNumberOfDeletedElementsIndex = kNumberOfElementsIndex + 1;
3912 static const int kHashTableStartIndex = kNumberOfDeletedElementsIndex + 1; 3912 static const int kHashTableStartIndex = kNumberOfDeletedElementsIndex + 1;
3913 3913
3914 static const int kNumberOfBucketsOffset = 3914 static const int kNumberOfBucketsOffset =
3915 kHeaderSize + kNumberOfBucketsIndex * kPointerSize; 3915 kHeaderSize + kNumberOfBucketsIndex * kPointerSize;
3916 static const int kNumberOfElementsOffset = 3916 static const int kNumberOfElementsOffset =
3917 kHeaderSize + kNumberOfElementsIndex * kPointerSize; 3917 kHeaderSize + kNumberOfElementsIndex * kPointerSize;
3918 static const int kNumberOfDeletedElementsOffset =
3919 kHeaderSize + kNumberOfDeletedElementsIndex * kPointerSize;
3918 3920
3919 static const int kEntrySize = entrysize + 1; 3921 static const int kEntrySize = entrysize + 1;
3920 static const int kChainOffset = entrysize; 3922 static const int kChainOffset = entrysize;
3921 3923
3924 static const int kLoadFactor = 2;
3925
3922 private: 3926 private:
3923 static Handle<Derived> Rehash(Handle<Derived> table, int new_capacity); 3927 static Handle<Derived> Rehash(Handle<Derived> table, int new_capacity);
3924 3928
3925 void SetNumberOfBuckets(int num) { 3929 void SetNumberOfBuckets(int num) {
3926 set(kNumberOfBucketsIndex, Smi::FromInt(num)); 3930 set(kNumberOfBucketsIndex, Smi::FromInt(num));
3927 } 3931 }
3928 3932
3929 void SetNumberOfElements(int num) { 3933 void SetNumberOfElements(int num) {
3930 set(kNumberOfElementsIndex, Smi::FromInt(num)); 3934 set(kNumberOfElementsIndex, Smi::FromInt(num));
3931 } 3935 }
(...skipping 24 matching lines...) Expand all
3956 set(kNextTableIndex, next_table); 3960 set(kNextTableIndex, next_table);
3957 } 3961 }
3958 3962
3959 void SetRemovedIndexAt(int index, int removed_index) { 3963 void SetRemovedIndexAt(int index, int removed_index) {
3960 return set(kRemovedHolesIndex + index, Smi::FromInt(removed_index)); 3964 return set(kRemovedHolesIndex + index, Smi::FromInt(removed_index));
3961 } 3965 }
3962 3966
3963 static const int kNextTableIndex = kNumberOfElementsIndex; 3967 static const int kNextTableIndex = kNumberOfElementsIndex;
3964 static const int kRemovedHolesIndex = kHashTableStartIndex; 3968 static const int kRemovedHolesIndex = kHashTableStartIndex;
3965 3969
3966 static const int kLoadFactor = 2;
3967 static const int kMaxCapacity = 3970 static const int kMaxCapacity =
3968 (FixedArray::kMaxLength - kHashTableStartIndex) 3971 (FixedArray::kMaxLength - kHashTableStartIndex)
3969 / (1 + (kEntrySize * kLoadFactor)); 3972 / (1 + (kEntrySize * kLoadFactor));
3970 }; 3973 };
3971 3974
3972 3975
3973 class JSSetIterator; 3976 class JSSetIterator;
3974 3977
3975 3978
3976 class OrderedHashSet: public OrderedHashTable< 3979 class OrderedHashSet: public OrderedHashTable<
(...skipping 7028 matching lines...) Expand 10 before | Expand all | Expand 10 after
11005 } else { 11008 } else {
11006 value &= ~(1 << bit_position); 11009 value &= ~(1 << bit_position);
11007 } 11010 }
11008 return value; 11011 return value;
11009 } 11012 }
11010 }; 11013 };
11011 11014
11012 } } // namespace v8::internal 11015 } } // namespace v8::internal
11013 11016
11014 #endif // V8_OBJECTS_H_ 11017 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698