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

Side by Side Diff: src/objects.h

Issue 2081733002: [keys] support shadowing keys in the KeyAccumulator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebasing Created 4 years, 5 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/assert-scope.h" 10 #include "src/assert-scope.h"
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 #define DECLARE_PRINTER(Name) 881 #define DECLARE_PRINTER(Name)
882 #endif 882 #endif
883 883
884 #define OBJECT_TYPE_LIST(V) \ 884 #define OBJECT_TYPE_LIST(V) \
885 V(Smi) \ 885 V(Smi) \
886 V(LayoutDescriptor) \ 886 V(LayoutDescriptor) \
887 V(HeapObject) \ 887 V(HeapObject) \
888 V(Primitive) \ 888 V(Primitive) \
889 V(Number) 889 V(Number)
890 890
891 #define HEAP_OBJECT_TYPE_LIST(V) \ 891 #define HEAP_OBJECT_TYPE_LIST(V) \
892 V(HeapNumber) \ 892 V(HeapNumber) \
893 V(MutableHeapNumber) \ 893 V(MutableHeapNumber) \
894 V(Simd128Value) \ 894 V(Simd128Value) \
895 V(Float32x4) \ 895 V(Float32x4) \
896 V(Int32x4) \ 896 V(Int32x4) \
897 V(Uint32x4) \ 897 V(Uint32x4) \
898 V(Bool32x4) \ 898 V(Bool32x4) \
899 V(Int16x8) \ 899 V(Int16x8) \
900 V(Uint16x8) \ 900 V(Uint16x8) \
901 V(Bool16x8) \ 901 V(Bool16x8) \
902 V(Int8x16) \ 902 V(Int8x16) \
903 V(Uint8x16) \ 903 V(Uint8x16) \
904 V(Bool8x16) \ 904 V(Bool8x16) \
905 V(Name) \ 905 V(Name) \
906 V(UniqueName) \ 906 V(UniqueName) \
907 V(String) \ 907 V(String) \
908 V(SeqString) \ 908 V(SeqString) \
909 V(ExternalString) \ 909 V(ExternalString) \
910 V(ConsString) \ 910 V(ConsString) \
911 V(SlicedString) \ 911 V(SlicedString) \
912 V(ExternalTwoByteString) \ 912 V(ExternalTwoByteString) \
913 V(ExternalOneByteString) \ 913 V(ExternalOneByteString) \
914 V(SeqTwoByteString) \ 914 V(SeqTwoByteString) \
915 V(SeqOneByteString) \ 915 V(SeqOneByteString) \
916 V(InternalizedString) \ 916 V(InternalizedString) \
917 V(Symbol) \ 917 V(Symbol) \
918 \ 918 \
919 V(FixedTypedArrayBase) \ 919 V(FixedTypedArrayBase) \
920 V(FixedUint8Array) \ 920 V(FixedUint8Array) \
921 V(FixedInt8Array) \ 921 V(FixedInt8Array) \
922 V(FixedUint16Array) \ 922 V(FixedUint16Array) \
923 V(FixedInt16Array) \ 923 V(FixedInt16Array) \
924 V(FixedUint32Array) \ 924 V(FixedUint32Array) \
925 V(FixedInt32Array) \ 925 V(FixedInt32Array) \
926 V(FixedFloat32Array) \ 926 V(FixedFloat32Array) \
927 V(FixedFloat64Array) \ 927 V(FixedFloat64Array) \
928 V(FixedUint8ClampedArray) \ 928 V(FixedUint8ClampedArray) \
929 V(ByteArray) \ 929 V(ByteArray) \
930 V(BytecodeArray) \ 930 V(BytecodeArray) \
931 V(FreeSpace) \ 931 V(FreeSpace) \
932 V(JSReceiver) \ 932 V(JSReceiver) \
933 V(JSObject) \ 933 V(JSObject) \
934 V(JSContextExtensionObject) \ 934 V(JSContextExtensionObject) \
935 V(JSGeneratorObject) \ 935 V(JSGeneratorObject) \
936 V(JSModule) \ 936 V(JSModule) \
937 V(Map) \ 937 V(Map) \
938 V(DescriptorArray) \ 938 V(DescriptorArray) \
939 V(TransitionArray) \ 939 V(TransitionArray) \
940 V(LiteralsArray) \ 940 V(LiteralsArray) \
941 V(TypeFeedbackMetadata) \ 941 V(TypeFeedbackMetadata) \
942 V(TypeFeedbackVector) \ 942 V(TypeFeedbackVector) \
943 V(DeoptimizationInputData) \ 943 V(DeoptimizationInputData) \
944 V(DeoptimizationOutputData) \ 944 V(DeoptimizationOutputData) \
945 V(DependentCode) \ 945 V(DependentCode) \
946 V(HandlerTable) \ 946 V(HandlerTable) \
947 V(FixedArray) \ 947 V(FixedArray) \
948 V(FixedDoubleArray) \ 948 V(FixedDoubleArray) \
949 V(WeakFixedArray) \ 949 V(WeakFixedArray) \
950 V(ArrayList) \ 950 V(ArrayList) \
951 V(Context) \ 951 V(Context) \
952 V(ScriptContextTable) \ 952 V(ScriptContextTable) \
953 V(NativeContext) \ 953 V(NativeContext) \
954 V(ScopeInfo) \ 954 V(ScopeInfo) \
955 V(JSBoundFunction) \ 955 V(JSBoundFunction) \
956 V(JSFunction) \ 956 V(JSFunction) \
957 V(Code) \ 957 V(Code) \
958 V(AbstractCode) \ 958 V(AbstractCode) \
959 V(Oddball) \ 959 V(Oddball) \
960 V(SharedFunctionInfo) \ 960 V(SharedFunctionInfo) \
961 V(JSValue) \ 961 V(JSValue) \
962 V(JSDate) \ 962 V(JSDate) \
963 V(JSMessageObject) \ 963 V(JSMessageObject) \
964 V(StringWrapper) \ 964 V(StringWrapper) \
965 V(Foreign) \ 965 V(Foreign) \
966 V(Boolean) \ 966 V(Boolean) \
967 V(JSArray) \ 967 V(JSArray) \
968 V(JSArrayBuffer) \ 968 V(JSArrayBuffer) \
969 V(JSArrayBufferView) \ 969 V(JSArrayBufferView) \
970 V(JSTypedArray) \ 970 V(JSTypedArray) \
971 V(JSDataView) \ 971 V(JSDataView) \
972 V(JSProxy) \ 972 V(JSProxy) \
973 V(JSSet) \ 973 V(JSSet) \
974 V(JSMap) \ 974 V(JSMap) \
975 V(JSSetIterator) \ 975 V(JSSetIterator) \
976 V(JSMapIterator) \ 976 V(JSMapIterator) \
977 V(JSWeakCollection) \ 977 V(JSWeakCollection) \
978 V(JSWeakMap) \ 978 V(JSWeakMap) \
979 V(JSWeakSet) \ 979 V(JSWeakSet) \
980 V(JSRegExp) \ 980 V(JSRegExp) \
981 V(HashTable) \ 981 V(HashTable) \
982 V(Dictionary) \ 982 V(Dictionary) \
983 V(StringTable) \ 983 V(StringTable) \
984 V(StringSet) \ 984 V(StringSet) \
985 V(NormalizedMapCache) \ 985 V(NormalizedMapCache) \
986 V(CompilationCacheTable) \ 986 V(CompilationCacheTable) \
987 V(CodeCacheHashTable) \ 987 V(CodeCacheHashTable) \
988 V(MapCache) \ 988 V(MapCache) \
989 V(JSGlobalObject) \ 989 V(JSGlobalObject) \
990 V(JSGlobalProxy) \ 990 V(JSGlobalProxy) \
991 V(Undetectable) \ 991 V(Undetectable) \
992 V(AccessCheckNeeded) \ 992 V(AccessCheckNeeded) \
993 V(Callable) \ 993 V(Callable) \
994 V(Function) \ 994 V(Function) \
995 V(Constructor) \ 995 V(Constructor) \
996 V(TemplateInfo) \ 996 V(TemplateInfo) \
997 V(Filler) \ 997 V(Filler) \
998 V(FixedArrayBase) \ 998 V(FixedArrayBase) \
999 V(External) \ 999 V(External) \
1000 V(Struct) \ 1000 V(Struct) \
1001 V(Cell) \ 1001 V(Cell) \
1002 V(PropertyCell) \ 1002 V(PropertyCell) \
1003 V(WeakCell) \ 1003 V(WeakCell) \
1004 V(ObjectHashTable) \ 1004 V(ObjectHashTable) \
1005 V(WeakHashTable) \ 1005 V(ObjectHashSet) \
1006 V(WeakHashTable) \
1006 V(OrderedHashTable) 1007 V(OrderedHashTable)
1007 1008
1008 #define ODDBALL_LIST(V) \ 1009 #define ODDBALL_LIST(V) \
1009 V(Undefined, undefined_value) \ 1010 V(Undefined, undefined_value) \
1010 V(Null, null_value) \ 1011 V(Null, null_value) \
1011 V(TheHole, the_hole_value) \ 1012 V(TheHole, the_hole_value) \
1012 V(Exception, exception) \ 1013 V(Exception, exception) \
1013 V(Uninitialized, uninitialized_value) \ 1014 V(Uninitialized, uninitialized_value) \
1014 V(True, true_value) \ 1015 V(True, true_value) \
1015 V(False, false_value) \ 1016 V(False, false_value) \
(...skipping 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after
3226 DECLARE_CAST(HashTable) 3227 DECLARE_CAST(HashTable)
3227 3228
3228 // Garbage collection support. 3229 // Garbage collection support.
3229 void IteratePrefix(ObjectVisitor* visitor); 3230 void IteratePrefix(ObjectVisitor* visitor);
3230 void IterateElements(ObjectVisitor* visitor); 3231 void IterateElements(ObjectVisitor* visitor);
3231 3232
3232 // Find entry for key otherwise return kNotFound. 3233 // Find entry for key otherwise return kNotFound.
3233 inline int FindEntry(Key key); 3234 inline int FindEntry(Key key);
3234 inline int FindEntry(Isolate* isolate, Key key, int32_t hash); 3235 inline int FindEntry(Isolate* isolate, Key key, int32_t hash);
3235 int FindEntry(Isolate* isolate, Key key); 3236 int FindEntry(Isolate* isolate, Key key);
3237 inline bool Has(Isolate* isolate, Key key);
3238 inline bool Has(Key key);
3236 3239
3237 // Rehashes the table in-place. 3240 // Rehashes the table in-place.
3238 void Rehash(Key key); 3241 void Rehash(Key key);
3239 3242
3240 // Returns the key at entry. 3243 // Returns the key at entry.
3241 Object* KeyAt(int entry) { return get(EntryToIndex(entry)); } 3244 Object* KeyAt(int entry) { return get(EntryToIndex(entry)); }
3242 3245
3243 static const int kElementsStartIndex = kPrefixStartIndex + Shape::kPrefixSize; 3246 static const int kElementsStartIndex = kPrefixStartIndex + Shape::kPrefixSize;
3244 static const int kEntrySize = Shape::kEntrySize; 3247 static const int kEntrySize = Shape::kEntrySize;
3245 static const int kElementsStartOffset = 3248 static const int kElementsStartOffset =
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
3450 3453
3451 // Returns the number of enumerable elements in the dictionary. 3454 // Returns the number of enumerable elements in the dictionary.
3452 int NumberOfEnumElements() { 3455 int NumberOfEnumElements() {
3453 return NumberOfElementsFilterAttributes(ENUMERABLE_STRINGS); 3456 return NumberOfElementsFilterAttributes(ENUMERABLE_STRINGS);
3454 } 3457 }
3455 3458
3456 enum SortMode { UNSORTED, SORTED }; 3459 enum SortMode { UNSORTED, SORTED };
3457 3460
3458 // Collect the keys into the given KeyAccumulator, in ascending chronological 3461 // Collect the keys into the given KeyAccumulator, in ascending chronological
3459 // order of property creation. 3462 // order of property creation.
3460 static void CollectKeysTo(Handle<Dictionary<Derived, Shape, Key> > dictionary, 3463 static void CollectKeysTo(Handle<Dictionary<Derived, Shape, Key>> dictionary,
3461 KeyAccumulator* keys, PropertyFilter filter); 3464 KeyAccumulator* keys);
3462 3465
3463 // Copies enumerable keys to preallocated fixed array. 3466 // Copies enumerable keys to preallocated fixed array.
3464 void CopyEnumKeysTo(FixedArray* storage); 3467 static void CopyEnumKeysTo(Handle<Dictionary<Derived, Shape, Key>> dictionary,
3468 Handle<FixedArray> storage, KeyCollectionMode mode,
3469 KeyAccumulator* accumulator);
3465 3470
3466 // Accessors for next enumeration index. 3471 // Accessors for next enumeration index.
3467 void SetNextEnumerationIndex(int index) { 3472 void SetNextEnumerationIndex(int index) {
3468 DCHECK(index != 0); 3473 DCHECK(index != 0);
3469 this->set(kNextEnumerationIndexIndex, Smi::FromInt(index)); 3474 this->set(kNextEnumerationIndexIndex, Smi::FromInt(index));
3470 } 3475 }
3471 3476
3472 int NextEnumerationIndex() { 3477 int NextEnumerationIndex() {
3473 return Smi::cast(this->get(kNextEnumerationIndexIndex))->value(); 3478 return Smi::cast(this->get(kNextEnumerationIndexIndex))->value();
3474 } 3479 }
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
3786 3791
3787 void AddEntry(int entry, Object* key, Object* value); 3792 void AddEntry(int entry, Object* key, Object* value);
3788 void RemoveEntry(int entry); 3793 void RemoveEntry(int entry);
3789 3794
3790 // Returns the index to the value of an entry. 3795 // Returns the index to the value of an entry.
3791 static inline int EntryToValueIndex(int entry) { 3796 static inline int EntryToValueIndex(int entry) {
3792 return EntryToIndex(entry) + 1; 3797 return EntryToIndex(entry) + 1;
3793 } 3798 }
3794 }; 3799 };
3795 3800
3801 class ObjectHashSetShape : public ObjectHashTableShape {
3802 public:
3803 static const int kPrefixSize = 0;
3804 static const int kEntrySize = 1;
3805 };
3806
3807 class ObjectHashSet
3808 : public HashTable<ObjectHashSet, ObjectHashSetShape, Handle<Object>> {
3809 public:
3810 static Handle<ObjectHashSet> Add(Handle<ObjectHashSet> set,
3811 Handle<Object> key);
3812
3813 inline bool Has(Isolate* isolate, Handle<Object> key, int32_t hash);
3814 inline bool Has(Isolate* isolate, Handle<Object> key);
3815
3816 DECLARE_CAST(ObjectHashSet)
3817 };
3796 3818
3797 // OrderedHashTable is a HashTable with Object keys that preserves 3819 // OrderedHashTable is a HashTable with Object keys that preserves
3798 // insertion order. There are Map and Set interfaces (OrderedHashMap 3820 // insertion order. There are Map and Set interfaces (OrderedHashMap
3799 // and OrderedHashTable, below). It is meant to be used by JSMap/JSSet. 3821 // and OrderedHashTable, below). It is meant to be used by JSMap/JSSet.
3800 // 3822 //
3801 // Only Object* keys are supported, with Object::SameValueZero() used as the 3823 // Only Object* keys are supported, with Object::SameValueZero() used as the
3802 // equality operator and Object::GetHash() for the hash function. 3824 // equality operator and Object::GetHash() for the hash function.
3803 // 3825 //
3804 // Based on the "Deterministic Hash Table" as described by Jason Orendorff at 3826 // Based on the "Deterministic Hash Table" as described by Jason Orendorff at
3805 // https://wiki.mozilla.org/User:Jorend/Deterministic_hash_tables 3827 // https://wiki.mozilla.org/User:Jorend/Deterministic_hash_tables
(...skipping 7023 matching lines...) Expand 10 before | Expand all | Expand 10 after
10829 } 10851 }
10830 return value; 10852 return value;
10831 } 10853 }
10832 }; 10854 };
10833 10855
10834 10856
10835 } // NOLINT, false-positive due to second-order macros. 10857 } // NOLINT, false-positive due to second-order macros.
10836 } // NOLINT, false-positive due to second-order macros. 10858 } // NOLINT, false-positive due to second-order macros.
10837 10859
10838 #endif // V8_OBJECTS_H_ 10860 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698