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

Side by Side Diff: src/objects-inl.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 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 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 852
853 853
854 bool Object::IsUnseededNumberDictionary() const { 854 bool Object::IsUnseededNumberDictionary() const {
855 return IsDictionary(); 855 return IsDictionary();
856 } 856 }
857 857
858 bool HeapObject::IsStringTable() const { return IsHashTable(); } 858 bool HeapObject::IsStringTable() const { return IsHashTable(); }
859 859
860 bool HeapObject::IsStringSet() const { return IsHashTable(); } 860 bool HeapObject::IsStringSet() const { return IsHashTable(); }
861 861
862 bool HeapObject::IsObjectHashSet() const { return IsHashTable(); }
863
862 bool HeapObject::IsNormalizedMapCache() const { 864 bool HeapObject::IsNormalizedMapCache() const {
863 return NormalizedMapCache::IsNormalizedMapCache(this); 865 return NormalizedMapCache::IsNormalizedMapCache(this);
864 } 866 }
865 867
866 868
867 int NormalizedMapCache::GetIndex(Handle<Map> map) { 869 int NormalizedMapCache::GetIndex(Handle<Map> map) {
868 return map->Hash() % NormalizedMapCache::kEntries; 870 return map->Hash() % NormalizedMapCache::kEntries;
869 } 871 }
870 872
871 bool NormalizedMapCache::IsNormalizedMapCache(const HeapObject* obj) { 873 bool NormalizedMapCache::IsNormalizedMapCache(const HeapObject* obj) {
(...skipping 2197 matching lines...) Expand 10 before | Expand all | Expand 10 after
3069 int HashTable<Derived, Shape, Key>::FindEntry(Key key) { 3071 int HashTable<Derived, Shape, Key>::FindEntry(Key key) {
3070 return FindEntry(GetIsolate(), key); 3072 return FindEntry(GetIsolate(), key);
3071 } 3073 }
3072 3074
3073 3075
3074 template<typename Derived, typename Shape, typename Key> 3076 template<typename Derived, typename Shape, typename Key>
3075 int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key) { 3077 int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key) {
3076 return FindEntry(isolate, key, HashTable::Hash(key)); 3078 return FindEntry(isolate, key, HashTable::Hash(key));
3077 } 3079 }
3078 3080
3079
3080 // Find entry for key otherwise return kNotFound. 3081 // Find entry for key otherwise return kNotFound.
3081 template <typename Derived, typename Shape, typename Key> 3082 template <typename Derived, typename Shape, typename Key>
3082 int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key, 3083 int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key,
3083 int32_t hash) { 3084 int32_t hash) {
3084 uint32_t capacity = Capacity(); 3085 uint32_t capacity = Capacity();
3085 uint32_t entry = FirstProbe(hash, capacity); 3086 uint32_t entry = FirstProbe(hash, capacity);
3086 uint32_t count = 1; 3087 uint32_t count = 1;
3087 // EnsureCapacity will guarantee the hash table is never full. 3088 // EnsureCapacity will guarantee the hash table is never full.
3088 Object* undefined = isolate->heap()->undefined_value(); 3089 Object* undefined = isolate->heap()->undefined_value();
3089 Object* the_hole = isolate->heap()->the_hole_value(); 3090 Object* the_hole = isolate->heap()->the_hole_value();
3090 while (true) { 3091 while (true) {
3091 Object* element = KeyAt(entry); 3092 Object* element = KeyAt(entry);
3092 // Empty entry. Uses raw unchecked accessors because it is called by the 3093 // Empty entry. Uses raw unchecked accessors because it is called by the
3093 // string table during bootstrapping. 3094 // string table during bootstrapping.
3094 if (element == undefined) break; 3095 if (element == undefined) break;
3095 if (element != the_hole && Shape::IsMatch(key, element)) return entry; 3096 if (element != the_hole && Shape::IsMatch(key, element)) return entry;
3096 entry = NextProbe(entry, count++, capacity); 3097 entry = NextProbe(entry, count++, capacity);
3097 } 3098 }
3098 return kNotFound; 3099 return kNotFound;
3099 } 3100 }
3100 3101
3102 template <typename Derived, typename Shape, typename Key>
3103 bool HashTable<Derived, Shape, Key>::Has(Key key) {
3104 return FindEntry(key) != kNotFound;
3105 }
3106
3107 template <typename Derived, typename Shape, typename Key>
3108 bool HashTable<Derived, Shape, Key>::Has(Isolate* isolate, Key key) {
3109 return FindEntry(isolate, key) != kNotFound;
3110 }
3111
3112 bool ObjectHashSet::Has(Isolate* isolate, Handle<Object> key, int32_t hash) {
3113 return FindEntry(isolate, key, hash) != kNotFound;
3114 }
3115
3116 bool ObjectHashSet::Has(Isolate* isolate, Handle<Object> key) {
3117 Object* hash = key->GetHash();
3118 if (!hash->IsSmi()) return false;
3119 return FindEntry(isolate, key, Smi::cast(hash)->value()) != kNotFound;
3120 }
3121
3101 bool StringSetShape::IsMatch(String* key, Object* value) { 3122 bool StringSetShape::IsMatch(String* key, Object* value) {
3102 return value->IsString() && key->Equals(String::cast(value)); 3123 return value->IsString() && key->Equals(String::cast(value));
3103 } 3124 }
3104 3125
3105 uint32_t StringSetShape::Hash(String* key) { return key->Hash(); } 3126 uint32_t StringSetShape::Hash(String* key) { return key->Hash(); }
3106 3127
3107 uint32_t StringSetShape::HashForObject(String* key, Object* object) { 3128 uint32_t StringSetShape::HashForObject(String* key, Object* object) {
3108 return object->IsString() ? String::cast(object)->Hash() : 0; 3129 return object->IsString() ? String::cast(object)->Hash() : 0;
3109 } 3130 }
3110 3131
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
3188 CAST_ACCESSOR(JSValue) 3209 CAST_ACCESSOR(JSValue)
3189 CAST_ACCESSOR(JSWeakMap) 3210 CAST_ACCESSOR(JSWeakMap)
3190 CAST_ACCESSOR(JSWeakSet) 3211 CAST_ACCESSOR(JSWeakSet)
3191 CAST_ACCESSOR(LayoutDescriptor) 3212 CAST_ACCESSOR(LayoutDescriptor)
3192 CAST_ACCESSOR(Map) 3213 CAST_ACCESSOR(Map)
3193 CAST_ACCESSOR(Name) 3214 CAST_ACCESSOR(Name)
3194 CAST_ACCESSOR(NameDictionary) 3215 CAST_ACCESSOR(NameDictionary)
3195 CAST_ACCESSOR(NormalizedMapCache) 3216 CAST_ACCESSOR(NormalizedMapCache)
3196 CAST_ACCESSOR(Object) 3217 CAST_ACCESSOR(Object)
3197 CAST_ACCESSOR(ObjectHashTable) 3218 CAST_ACCESSOR(ObjectHashTable)
3219 CAST_ACCESSOR(ObjectHashSet)
adamk 2016/06/27 19:19:33 Nit: looks like this list is in alphabetical order
Camillo Bruni 2016/06/29 17:27:56 done.
3198 CAST_ACCESSOR(Oddball) 3220 CAST_ACCESSOR(Oddball)
3199 CAST_ACCESSOR(OrderedHashMap) 3221 CAST_ACCESSOR(OrderedHashMap)
3200 CAST_ACCESSOR(OrderedHashSet) 3222 CAST_ACCESSOR(OrderedHashSet)
3201 CAST_ACCESSOR(PropertyCell) 3223 CAST_ACCESSOR(PropertyCell)
3202 CAST_ACCESSOR(ScopeInfo) 3224 CAST_ACCESSOR(ScopeInfo)
3203 CAST_ACCESSOR(SeededNumberDictionary) 3225 CAST_ACCESSOR(SeededNumberDictionary)
3204 CAST_ACCESSOR(SeqOneByteString) 3226 CAST_ACCESSOR(SeqOneByteString)
3205 CAST_ACCESSOR(SeqString) 3227 CAST_ACCESSOR(SeqString)
3206 CAST_ACCESSOR(SeqTwoByteString) 3228 CAST_ACCESSOR(SeqTwoByteString)
3207 CAST_ACCESSOR(SharedFunctionInfo) 3229 CAST_ACCESSOR(SharedFunctionInfo)
(...skipping 1884 matching lines...) Expand 10 before | Expand all | Expand 10 after
5092 default: return false; 5114 default: return false;
5093 } 5115 }
5094 } 5116 }
5095 5117
5096 bool Code::is_debug_stub() { 5118 bool Code::is_debug_stub() {
5097 if (kind() != BUILTIN) return false; 5119 if (kind() != BUILTIN) return false;
5098 switch (builtin_index()) { 5120 switch (builtin_index()) {
5099 #define CASE_DEBUG_BUILTIN(name, kind, extra) case Builtins::k##name: 5121 #define CASE_DEBUG_BUILTIN(name, kind, extra) case Builtins::k##name:
5100 BUILTIN_LIST_DEBUG_A(CASE_DEBUG_BUILTIN) 5122 BUILTIN_LIST_DEBUG_A(CASE_DEBUG_BUILTIN)
5101 #undef CASE_DEBUG_BUILTIN 5123 #undef CASE_DEBUG_BUILTIN
5102 return true; 5124 return true;
adamk 2016/06/27 19:19:33 This whitespace change looks wrong..git cl format'
Camillo Bruni 2016/06/29 17:27:56 indeed, changing back
5103 default: 5125 default:
5104 return false; 5126 return false;
5105 } 5127 }
5106 return false; 5128 return false;
5107 } 5129 }
5108 bool Code::is_handler() { return kind() == HANDLER; } 5130 bool Code::is_handler() { return kind() == HANDLER; }
5109 bool Code::is_call_stub() { return kind() == CALL_IC; } 5131 bool Code::is_call_stub() { return kind() == CALL_IC; }
5110 bool Code::is_binary_op_stub() { return kind() == BINARY_OP_IC; } 5132 bool Code::is_binary_op_stub() { return kind() == BINARY_OP_IC; }
5111 bool Code::is_compare_ic_stub() { return kind() == COMPARE_IC; } 5133 bool Code::is_compare_ic_stub() { return kind() == COMPARE_IC; }
5112 bool Code::is_to_boolean_ic_stub() { return kind() == TO_BOOLEAN_IC; } 5134 bool Code::is_to_boolean_ic_stub() { return kind() == TO_BOOLEAN_IC; }
(...skipping 2844 matching lines...) Expand 10 before | Expand all | Expand 10 after
7957 #undef WRITE_INT64_FIELD 7979 #undef WRITE_INT64_FIELD
7958 #undef READ_BYTE_FIELD 7980 #undef READ_BYTE_FIELD
7959 #undef WRITE_BYTE_FIELD 7981 #undef WRITE_BYTE_FIELD
7960 #undef NOBARRIER_READ_BYTE_FIELD 7982 #undef NOBARRIER_READ_BYTE_FIELD
7961 #undef NOBARRIER_WRITE_BYTE_FIELD 7983 #undef NOBARRIER_WRITE_BYTE_FIELD
7962 7984
7963 } // namespace internal 7985 } // namespace internal
7964 } // namespace v8 7986 } // namespace v8
7965 7987
7966 #endif // V8_OBJECTS_INL_H_ 7988 #endif // V8_OBJECTS_INL_H_
OLDNEW
« src/objects.cc ('K') | « src/objects.cc ('k') | test/cctest/test-dictionary.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698