OLD | NEW |
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 3136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3147 inline void ElementRemoved(); | 3147 inline void ElementRemoved(); |
3148 inline void ElementsRemoved(int n); | 3148 inline void ElementsRemoved(int n); |
3149 | 3149 |
3150 // Computes the required capacity for a table holding the given | 3150 // Computes the required capacity for a table holding the given |
3151 // number of elements. May be more than HashTable::kMaxCapacity. | 3151 // number of elements. May be more than HashTable::kMaxCapacity. |
3152 static inline int ComputeCapacity(int at_least_space_for); | 3152 static inline int ComputeCapacity(int at_least_space_for); |
3153 | 3153 |
3154 // Tells whether k is a real key. The hole and undefined are not allowed | 3154 // Tells whether k is a real key. The hole and undefined are not allowed |
3155 // as keys and can be used to indicate missing or deleted elements. | 3155 // as keys and can be used to indicate missing or deleted elements. |
3156 inline bool IsKey(Object* k); | 3156 inline bool IsKey(Object* k); |
3157 inline bool IsKey(Heap* heap, Object* k); | 3157 inline bool IsKey(Isolate* isolate, Object* k); |
3158 | 3158 |
3159 // Compute the probe offset (quadratic probing). | 3159 // Compute the probe offset (quadratic probing). |
3160 INLINE(static uint32_t GetProbeOffset(uint32_t n)) { | 3160 INLINE(static uint32_t GetProbeOffset(uint32_t n)) { |
3161 return (n + n * n) >> 1; | 3161 return (n + n * n) >> 1; |
3162 } | 3162 } |
3163 | 3163 |
3164 static const int kNumberOfElementsIndex = 0; | 3164 static const int kNumberOfElementsIndex = 0; |
3165 static const int kNumberOfDeletedElementsIndex = 1; | 3165 static const int kNumberOfDeletedElementsIndex = 1; |
3166 static const int kCapacityIndex = 2; | 3166 static const int kCapacityIndex = 2; |
3167 static const int kPrefixStartIndex = 3; | 3167 static const int kPrefixStartIndex = 3; |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3872 } | 3872 } |
3873 | 3873 |
3874 int HashToBucket(int hash) { return hash & (NumberOfBuckets() - 1); } | 3874 int HashToBucket(int hash) { return hash & (NumberOfBuckets() - 1); } |
3875 | 3875 |
3876 int HashToEntry(int hash) { | 3876 int HashToEntry(int hash) { |
3877 int bucket = HashToBucket(hash); | 3877 int bucket = HashToBucket(hash); |
3878 Object* entry = this->get(kHashTableStartIndex + bucket); | 3878 Object* entry = this->get(kHashTableStartIndex + bucket); |
3879 return Smi::cast(entry)->value(); | 3879 return Smi::cast(entry)->value(); |
3880 } | 3880 } |
3881 | 3881 |
3882 int KeyToFirstEntry(Object* key) { | 3882 int KeyToFirstEntry(Isolate* isolate, Object* key) { |
3883 Object* hash = key->GetHash(); | 3883 Object* hash = key->GetHash(); |
3884 // If the object does not have an identity hash, it was never used as a key | 3884 // If the object does not have an identity hash, it was never used as a key |
3885 if (hash->IsUndefined(GetIsolate())) return kNotFound; | 3885 if (hash->IsUndefined(isolate)) return kNotFound; |
3886 return HashToEntry(Smi::cast(hash)->value()); | 3886 return HashToEntry(Smi::cast(hash)->value()); |
3887 } | 3887 } |
3888 | 3888 |
3889 int NextChainEntry(int entry) { | 3889 int NextChainEntry(int entry) { |
3890 Object* next_entry = get(EntryToIndex(entry) + kChainOffset); | 3890 Object* next_entry = get(EntryToIndex(entry) + kChainOffset); |
3891 return Smi::cast(next_entry)->value(); | 3891 return Smi::cast(next_entry)->value(); |
3892 } | 3892 } |
3893 | 3893 |
3894 // use KeyAt(i)->IsTheHole(isolate) to determine if this is a deleted entry. | 3894 // use KeyAt(i)->IsTheHole(isolate) to determine if this is a deleted entry. |
3895 Object* KeyAt(int entry) { | 3895 Object* KeyAt(int entry) { |
(...skipping 6894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10790 } | 10790 } |
10791 return value; | 10791 return value; |
10792 } | 10792 } |
10793 }; | 10793 }; |
10794 | 10794 |
10795 | 10795 |
10796 } // NOLINT, false-positive due to second-order macros. | 10796 } // NOLINT, false-positive due to second-order macros. |
10797 } // NOLINT, false-positive due to second-order macros. | 10797 } // NOLINT, false-positive due to second-order macros. |
10798 | 10798 |
10799 #endif // V8_OBJECTS_H_ | 10799 #endif // V8_OBJECTS_H_ |
OLD | NEW |