OLD | NEW |
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 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 } | 843 } |
844 | 844 |
845 | 845 |
846 bool Object::IsGlobalDictionary() const { return IsDictionary(); } | 846 bool Object::IsGlobalDictionary() const { return IsDictionary(); } |
847 | 847 |
848 | 848 |
849 bool Object::IsSeededNumberDictionary() const { | 849 bool Object::IsSeededNumberDictionary() const { |
850 return IsDictionary(); | 850 return IsDictionary(); |
851 } | 851 } |
852 | 852 |
853 | 853 bool HeapObject::IsUnseededNumberDictionary() const { |
854 bool Object::IsUnseededNumberDictionary() const { | 854 return map() == GetHeap()->unseeded_number_dictionary_map(); |
855 return IsDictionary(); | |
856 } | 855 } |
857 | 856 |
858 bool HeapObject::IsStringTable() const { return IsHashTable(); } | 857 bool HeapObject::IsStringTable() const { return IsHashTable(); } |
859 | 858 |
860 bool HeapObject::IsStringSet() const { return IsHashTable(); } | 859 bool HeapObject::IsStringSet() const { return IsHashTable(); } |
861 | 860 |
862 bool HeapObject::IsObjectHashSet() const { return IsHashTable(); } | 861 bool HeapObject::IsObjectHashSet() const { return IsHashTable(); } |
863 | 862 |
864 bool HeapObject::IsNormalizedMapCache() const { | 863 bool HeapObject::IsNormalizedMapCache() const { |
865 return NormalizedMapCache::IsNormalizedMapCache(this); | 864 return NormalizedMapCache::IsNormalizedMapCache(this); |
(...skipping 2190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3056 | 3055 |
3057 void HashTableBase::SetNumberOfElements(int nof) { | 3056 void HashTableBase::SetNumberOfElements(int nof) { |
3058 set(kNumberOfElementsIndex, Smi::FromInt(nof)); | 3057 set(kNumberOfElementsIndex, Smi::FromInt(nof)); |
3059 } | 3058 } |
3060 | 3059 |
3061 | 3060 |
3062 void HashTableBase::SetNumberOfDeletedElements(int nod) { | 3061 void HashTableBase::SetNumberOfDeletedElements(int nod) { |
3063 set(kNumberOfDeletedElementsIndex, Smi::FromInt(nod)); | 3062 set(kNumberOfDeletedElementsIndex, Smi::FromInt(nod)); |
3064 } | 3063 } |
3065 | 3064 |
| 3065 template <typename Key> |
| 3066 Map* BaseShape<Key>::GetMap(Isolate* isolate) { |
| 3067 return isolate->heap()->hash_table_map(); |
| 3068 } |
3066 | 3069 |
3067 template <typename Derived, typename Shape, typename Key> | 3070 template <typename Derived, typename Shape, typename Key> |
3068 int HashTable<Derived, Shape, Key>::FindEntry(Key key) { | 3071 int HashTable<Derived, Shape, Key>::FindEntry(Key key) { |
3069 return FindEntry(GetIsolate(), key); | 3072 return FindEntry(GetIsolate(), key); |
3070 } | 3073 } |
3071 | 3074 |
3072 | 3075 |
3073 template<typename Derived, typename Shape, typename Key> | 3076 template<typename Derived, typename Shape, typename Key> |
3074 int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key) { | 3077 int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key) { |
3075 return FindEntry(isolate, key, HashTable::Hash(key)); | 3078 return FindEntry(isolate, key, HashTable::Hash(key)); |
(...skipping 4390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7466 Shape::SetEntry(static_cast<Derived*>(this), entry, key, value, details); | 7469 Shape::SetEntry(static_cast<Derived*>(this), entry, key, value, details); |
7467 } | 7470 } |
7468 | 7471 |
7469 | 7472 |
7470 template <typename Key> | 7473 template <typename Key> |
7471 template <typename Dictionary> | 7474 template <typename Dictionary> |
7472 void BaseDictionaryShape<Key>::SetEntry(Dictionary* dict, int entry, | 7475 void BaseDictionaryShape<Key>::SetEntry(Dictionary* dict, int entry, |
7473 Handle<Object> key, | 7476 Handle<Object> key, |
7474 Handle<Object> value, | 7477 Handle<Object> value, |
7475 PropertyDetails details) { | 7478 PropertyDetails details) { |
7476 STATIC_ASSERT(Dictionary::kEntrySize == 3); | 7479 STATIC_ASSERT(Dictionary::kEntrySize == 2 || Dictionary::kEntrySize == 3); |
7477 DCHECK(!key->IsName() || details.dictionary_index() > 0); | 7480 DCHECK(!key->IsName() || details.dictionary_index() > 0); |
7478 int index = dict->EntryToIndex(entry); | 7481 int index = dict->EntryToIndex(entry); |
7479 DisallowHeapAllocation no_gc; | 7482 DisallowHeapAllocation no_gc; |
7480 WriteBarrierMode mode = dict->GetWriteBarrierMode(no_gc); | 7483 WriteBarrierMode mode = dict->GetWriteBarrierMode(no_gc); |
7481 dict->set(index + Dictionary::kEntryKeyIndex, *key, mode); | 7484 dict->set(index + Dictionary::kEntryKeyIndex, *key, mode); |
7482 dict->set(index + Dictionary::kEntryValueIndex, *value, mode); | 7485 dict->set(index + Dictionary::kEntryValueIndex, *value, mode); |
7483 dict->set(index + Dictionary::kEntryDetailsIndex, details.AsSmi()); | 7486 if (Dictionary::kEntrySize == 3) { |
| 7487 dict->set(index + Dictionary::kEntryDetailsIndex, details.AsSmi()); |
| 7488 } |
7484 } | 7489 } |
7485 | 7490 |
7486 | 7491 |
7487 template <typename Dictionary> | 7492 template <typename Dictionary> |
7488 void GlobalDictionaryShape::SetEntry(Dictionary* dict, int entry, | 7493 void GlobalDictionaryShape::SetEntry(Dictionary* dict, int entry, |
7489 Handle<Object> key, Handle<Object> value, | 7494 Handle<Object> key, Handle<Object> value, |
7490 PropertyDetails details) { | 7495 PropertyDetails details) { |
7491 STATIC_ASSERT(Dictionary::kEntrySize == 2); | 7496 STATIC_ASSERT(Dictionary::kEntrySize == 2); |
7492 DCHECK(!key->IsName() || details.dictionary_index() > 0); | 7497 DCHECK(!key->IsName() || details.dictionary_index() > 0); |
7493 DCHECK(value->IsPropertyCell()); | 7498 DCHECK(value->IsPropertyCell()); |
(...skipping 16 matching lines...) Expand all Loading... |
7510 return ComputeIntegerHash(key, 0); | 7515 return ComputeIntegerHash(key, 0); |
7511 } | 7516 } |
7512 | 7517 |
7513 | 7518 |
7514 uint32_t UnseededNumberDictionaryShape::HashForObject(uint32_t key, | 7519 uint32_t UnseededNumberDictionaryShape::HashForObject(uint32_t key, |
7515 Object* other) { | 7520 Object* other) { |
7516 DCHECK(other->IsNumber()); | 7521 DCHECK(other->IsNumber()); |
7517 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), 0); | 7522 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), 0); |
7518 } | 7523 } |
7519 | 7524 |
| 7525 Map* UnseededNumberDictionaryShape::GetMap(Isolate* isolate) { |
| 7526 return *isolate->factory()->unseeded_number_dictionary_map(); |
| 7527 } |
7520 | 7528 |
7521 uint32_t SeededNumberDictionaryShape::SeededHash(uint32_t key, uint32_t seed) { | 7529 uint32_t SeededNumberDictionaryShape::SeededHash(uint32_t key, uint32_t seed) { |
7522 return ComputeIntegerHash(key, seed); | 7530 return ComputeIntegerHash(key, seed); |
7523 } | 7531 } |
7524 | 7532 |
7525 | 7533 |
7526 uint32_t SeededNumberDictionaryShape::SeededHashForObject(uint32_t key, | 7534 uint32_t SeededNumberDictionaryShape::SeededHashForObject(uint32_t key, |
7527 uint32_t seed, | 7535 uint32_t seed, |
7528 Object* other) { | 7536 Object* other) { |
7529 DCHECK(other->IsNumber()); | 7537 DCHECK(other->IsNumber()); |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8015 #undef WRITE_INT64_FIELD | 8023 #undef WRITE_INT64_FIELD |
8016 #undef READ_BYTE_FIELD | 8024 #undef READ_BYTE_FIELD |
8017 #undef WRITE_BYTE_FIELD | 8025 #undef WRITE_BYTE_FIELD |
8018 #undef NOBARRIER_READ_BYTE_FIELD | 8026 #undef NOBARRIER_READ_BYTE_FIELD |
8019 #undef NOBARRIER_WRITE_BYTE_FIELD | 8027 #undef NOBARRIER_WRITE_BYTE_FIELD |
8020 | 8028 |
8021 } // namespace internal | 8029 } // namespace internal |
8022 } // namespace v8 | 8030 } // namespace v8 |
8023 | 8031 |
8024 #endif // V8_OBJECTS_INL_H_ | 8032 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |