| 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 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 } | 844 } |
| 845 | 845 |
| 846 | 846 |
| 847 bool Object::IsGlobalDictionary() const { return IsDictionary(); } | 847 bool Object::IsGlobalDictionary() const { return IsDictionary(); } |
| 848 | 848 |
| 849 | 849 |
| 850 bool Object::IsSeededNumberDictionary() const { | 850 bool Object::IsSeededNumberDictionary() const { |
| 851 return IsDictionary(); | 851 return IsDictionary(); |
| 852 } | 852 } |
| 853 | 853 |
| 854 | 854 bool HeapObject::IsUnseededNumberDictionary() const { |
| 855 bool Object::IsUnseededNumberDictionary() const { | 855 return map() == GetHeap()->unseeded_number_dictionary_map(); |
| 856 return IsDictionary(); | |
| 857 } | 856 } |
| 858 | 857 |
| 859 bool HeapObject::IsStringTable() const { return IsHashTable(); } | 858 bool HeapObject::IsStringTable() const { return IsHashTable(); } |
| 860 | 859 |
| 861 bool HeapObject::IsStringSet() const { return IsHashTable(); } | 860 bool HeapObject::IsStringSet() const { return IsHashTable(); } |
| 862 | 861 |
| 863 bool HeapObject::IsNormalizedMapCache() const { | 862 bool HeapObject::IsNormalizedMapCache() const { |
| 864 return NormalizedMapCache::IsNormalizedMapCache(this); | 863 return NormalizedMapCache::IsNormalizedMapCache(this); |
| 865 } | 864 } |
| 866 | 865 |
| (...skipping 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3058 | 3057 |
| 3059 void HashTableBase::SetNumberOfElements(int nof) { | 3058 void HashTableBase::SetNumberOfElements(int nof) { |
| 3060 set(kNumberOfElementsIndex, Smi::FromInt(nof)); | 3059 set(kNumberOfElementsIndex, Smi::FromInt(nof)); |
| 3061 } | 3060 } |
| 3062 | 3061 |
| 3063 | 3062 |
| 3064 void HashTableBase::SetNumberOfDeletedElements(int nod) { | 3063 void HashTableBase::SetNumberOfDeletedElements(int nod) { |
| 3065 set(kNumberOfDeletedElementsIndex, Smi::FromInt(nod)); | 3064 set(kNumberOfDeletedElementsIndex, Smi::FromInt(nod)); |
| 3066 } | 3065 } |
| 3067 | 3066 |
| 3067 template <typename Key> |
| 3068 Map* BaseShape<Key>::GetMap(Isolate* isolate) { |
| 3069 return isolate->heap()->hash_table_map(); |
| 3070 } |
| 3068 | 3071 |
| 3069 template <typename Derived, typename Shape, typename Key> | 3072 template <typename Derived, typename Shape, typename Key> |
| 3070 int HashTable<Derived, Shape, Key>::FindEntry(Key key) { | 3073 int HashTable<Derived, Shape, Key>::FindEntry(Key key) { |
| 3071 return FindEntry(GetIsolate(), key); | 3074 return FindEntry(GetIsolate(), key); |
| 3072 } | 3075 } |
| 3073 | 3076 |
| 3074 | 3077 |
| 3075 template<typename Derived, typename Shape, typename Key> | 3078 template<typename Derived, typename Shape, typename Key> |
| 3076 int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key) { | 3079 int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key) { |
| 3077 return FindEntry(isolate, key, HashTable::Hash(key)); | 3080 return FindEntry(isolate, key, HashTable::Hash(key)); |
| (...skipping 4372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7450 Shape::SetEntry(static_cast<Derived*>(this), entry, key, value, details); | 7453 Shape::SetEntry(static_cast<Derived*>(this), entry, key, value, details); |
| 7451 } | 7454 } |
| 7452 | 7455 |
| 7453 | 7456 |
| 7454 template <typename Key> | 7457 template <typename Key> |
| 7455 template <typename Dictionary> | 7458 template <typename Dictionary> |
| 7456 void BaseDictionaryShape<Key>::SetEntry(Dictionary* dict, int entry, | 7459 void BaseDictionaryShape<Key>::SetEntry(Dictionary* dict, int entry, |
| 7457 Handle<Object> key, | 7460 Handle<Object> key, |
| 7458 Handle<Object> value, | 7461 Handle<Object> value, |
| 7459 PropertyDetails details) { | 7462 PropertyDetails details) { |
| 7460 STATIC_ASSERT(Dictionary::kEntrySize == 3); | 7463 STATIC_ASSERT(Dictionary::kEntrySize == 2 || Dictionary::kEntrySize == 3); |
| 7461 DCHECK(!key->IsName() || details.dictionary_index() > 0); | 7464 DCHECK(!key->IsName() || details.dictionary_index() > 0); |
| 7462 int index = dict->EntryToIndex(entry); | 7465 int index = dict->EntryToIndex(entry); |
| 7463 DisallowHeapAllocation no_gc; | 7466 DisallowHeapAllocation no_gc; |
| 7464 WriteBarrierMode mode = dict->GetWriteBarrierMode(no_gc); | 7467 WriteBarrierMode mode = dict->GetWriteBarrierMode(no_gc); |
| 7465 dict->set(index + Dictionary::kEntryKeyIndex, *key, mode); | 7468 dict->set(index + Dictionary::kEntryKeyIndex, *key, mode); |
| 7466 dict->set(index + Dictionary::kEntryValueIndex, *value, mode); | 7469 dict->set(index + Dictionary::kEntryValueIndex, *value, mode); |
| 7467 dict->set(index + Dictionary::kEntryDetailsIndex, details.AsSmi()); | 7470 if (Dictionary::kEntrySize == 3) { |
| 7471 dict->set(index + Dictionary::kEntryDetailsIndex, details.AsSmi()); |
| 7472 } |
| 7468 } | 7473 } |
| 7469 | 7474 |
| 7470 | 7475 |
| 7471 template <typename Dictionary> | 7476 template <typename Dictionary> |
| 7472 void GlobalDictionaryShape::SetEntry(Dictionary* dict, int entry, | 7477 void GlobalDictionaryShape::SetEntry(Dictionary* dict, int entry, |
| 7473 Handle<Object> key, Handle<Object> value, | 7478 Handle<Object> key, Handle<Object> value, |
| 7474 PropertyDetails details) { | 7479 PropertyDetails details) { |
| 7475 STATIC_ASSERT(Dictionary::kEntrySize == 2); | 7480 STATIC_ASSERT(Dictionary::kEntrySize == 2); |
| 7476 DCHECK(!key->IsName() || details.dictionary_index() > 0); | 7481 DCHECK(!key->IsName() || details.dictionary_index() > 0); |
| 7477 DCHECK(value->IsPropertyCell()); | 7482 DCHECK(value->IsPropertyCell()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 7494 return ComputeIntegerHash(key, 0); | 7499 return ComputeIntegerHash(key, 0); |
| 7495 } | 7500 } |
| 7496 | 7501 |
| 7497 | 7502 |
| 7498 uint32_t UnseededNumberDictionaryShape::HashForObject(uint32_t key, | 7503 uint32_t UnseededNumberDictionaryShape::HashForObject(uint32_t key, |
| 7499 Object* other) { | 7504 Object* other) { |
| 7500 DCHECK(other->IsNumber()); | 7505 DCHECK(other->IsNumber()); |
| 7501 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), 0); | 7506 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), 0); |
| 7502 } | 7507 } |
| 7503 | 7508 |
| 7509 Map* UnseededNumberDictionaryShape::GetMap(Isolate* isolate) { |
| 7510 return *isolate->factory()->unseeded_number_dictionary_map(); |
| 7511 } |
| 7504 | 7512 |
| 7505 uint32_t SeededNumberDictionaryShape::SeededHash(uint32_t key, uint32_t seed) { | 7513 uint32_t SeededNumberDictionaryShape::SeededHash(uint32_t key, uint32_t seed) { |
| 7506 return ComputeIntegerHash(key, seed); | 7514 return ComputeIntegerHash(key, seed); |
| 7507 } | 7515 } |
| 7508 | 7516 |
| 7509 | 7517 |
| 7510 uint32_t SeededNumberDictionaryShape::SeededHashForObject(uint32_t key, | 7518 uint32_t SeededNumberDictionaryShape::SeededHashForObject(uint32_t key, |
| 7511 uint32_t seed, | 7519 uint32_t seed, |
| 7512 Object* other) { | 7520 Object* other) { |
| 7513 DCHECK(other->IsNumber()); | 7521 DCHECK(other->IsNumber()); |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7999 #undef WRITE_INT64_FIELD | 8007 #undef WRITE_INT64_FIELD |
| 8000 #undef READ_BYTE_FIELD | 8008 #undef READ_BYTE_FIELD |
| 8001 #undef WRITE_BYTE_FIELD | 8009 #undef WRITE_BYTE_FIELD |
| 8002 #undef NOBARRIER_READ_BYTE_FIELD | 8010 #undef NOBARRIER_READ_BYTE_FIELD |
| 8003 #undef NOBARRIER_WRITE_BYTE_FIELD | 8011 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 8004 | 8012 |
| 8005 } // namespace internal | 8013 } // namespace internal |
| 8006 } // namespace v8 | 8014 } // namespace v8 |
| 8007 | 8015 |
| 8008 #endif // V8_OBJECTS_INL_H_ | 8016 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |