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 #include "src/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 11121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11132 // be zero. | 11132 // be zero. |
11133 DCHECK(length > 0); | 11133 DCHECK(length > 0); |
11134 DCHECK(length <= String::kMaxArrayIndexSize); | 11134 DCHECK(length <= String::kMaxArrayIndexSize); |
11135 DCHECK(TenToThe(String::kMaxCachedArrayIndexLength) < | 11135 DCHECK(TenToThe(String::kMaxCachedArrayIndexLength) < |
11136 (1 << String::kArrayIndexValueBits)); | 11136 (1 << String::kArrayIndexValueBits)); |
11137 | 11137 |
11138 value <<= String::ArrayIndexValueBits::kShift; | 11138 value <<= String::ArrayIndexValueBits::kShift; |
11139 value |= length << String::ArrayIndexLengthBits::kShift; | 11139 value |= length << String::ArrayIndexLengthBits::kShift; |
11140 | 11140 |
11141 DCHECK((value & String::kIsNotArrayIndexMask) == 0); | 11141 DCHECK((value & String::kIsNotArrayIndexMask) == 0); |
11142 DCHECK_EQ(length <= String::kMaxCachedArrayIndexLength, | 11142 DCHECK((length > String::kMaxCachedArrayIndexLength) || |
11143 (value & String::kContainsCachedArrayIndexMask) == 0); | 11143 (value & String::kContainsCachedArrayIndexMask) == 0); |
11144 return value; | 11144 return value; |
11145 } | 11145 } |
11146 | 11146 |
11147 | 11147 |
11148 uint32_t StringHasher::GetHashField() { | 11148 uint32_t StringHasher::GetHashField() { |
11149 if (length_ <= String::kMaxHashCalcLength) { | 11149 if (length_ <= String::kMaxHashCalcLength) { |
11150 if (is_array_index_) { | 11150 if (is_array_index_) { |
11151 return MakeArrayIndexHash(array_index_, length_); | 11151 return MakeArrayIndexHash(array_index_, length_); |
11152 } | 11152 } |
11153 return (GetHashCore(raw_running_hash_) << String::kHashShift) | | 11153 return (GetHashCore(raw_running_hash_) << String::kHashShift) | |
(...skipping 4009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15163 os << "\n "; | 15163 os << "\n "; |
15164 if (k->IsString()) { | 15164 if (k->IsString()) { |
15165 String::cast(k)->StringPrint(os); | 15165 String::cast(k)->StringPrint(os); |
15166 } else { | 15166 } else { |
15167 os << Brief(k); | 15167 os << Brief(k); |
15168 } | 15168 } |
15169 os << ": " << Brief(this->ValueAt(i)) << " " << this->DetailsAt(i); | 15169 os << ": " << Brief(this->ValueAt(i)) << " " << this->DetailsAt(i); |
15170 } | 15170 } |
15171 } | 15171 } |
15172 } | 15172 } |
15173 template <typename Derived, typename Shape, typename Key> | |
15174 void Dictionary<Derived, Shape, Key>::Print() { | |
15175 OFStream os(stdout); | |
15176 Print(os); | |
15177 } | |
15178 #endif | 15173 #endif |
15179 | 15174 |
15180 | 15175 |
15181 template<typename Derived, typename Shape, typename Key> | 15176 template<typename Derived, typename Shape, typename Key> |
15182 void Dictionary<Derived, Shape, Key>::CopyValuesTo(FixedArray* elements) { | 15177 void Dictionary<Derived, Shape, Key>::CopyValuesTo(FixedArray* elements) { |
15183 int pos = 0; | 15178 int pos = 0; |
15184 int capacity = this->Capacity(); | 15179 int capacity = this->Capacity(); |
15185 DisallowHeapAllocation no_gc; | 15180 DisallowHeapAllocation no_gc; |
15186 WriteBarrierMode mode = elements->GetWriteBarrierMode(no_gc); | 15181 WriteBarrierMode mode = elements->GetWriteBarrierMode(no_gc); |
15187 for (int i = 0; i < capacity; i++) { | 15182 for (int i = 0; i < capacity; i++) { |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15899 // EnsureCapacity will guarantee the hash table is never full. | 15894 // EnsureCapacity will guarantee the hash table is never full. |
15900 uint32_t capacity = this->Capacity(); | 15895 uint32_t capacity = this->Capacity(); |
15901 uint32_t entry = Derived::FirstProbe(key->Hash(), capacity); | 15896 uint32_t entry = Derived::FirstProbe(key->Hash(), capacity); |
15902 uint32_t count = 1; | 15897 uint32_t count = 1; |
15903 | 15898 |
15904 while (true) { | 15899 while (true) { |
15905 int index = Derived::EntryToIndex(entry); | 15900 int index = Derived::EntryToIndex(entry); |
15906 Object* element = this->get(index); | 15901 Object* element = this->get(index); |
15907 if (element->IsUndefined()) break; // Empty entry. | 15902 if (element->IsUndefined()) break; // Empty entry. |
15908 if (*key == element) return entry; | 15903 if (*key == element) return entry; |
15909 DCHECK(element->IsTheHole() || element->IsUniqueName()); | 15904 if (!element->IsUniqueName() && |
| 15905 !element->IsTheHole() && |
| 15906 Name::cast(element)->Equals(*key)) { |
| 15907 // Replace a key that is a non-internalized string by the equivalent |
| 15908 // internalized string for faster further lookups. |
| 15909 this->set(index, *key); |
| 15910 return entry; |
| 15911 } |
| 15912 DCHECK(element->IsTheHole() || !Name::cast(element)->Equals(*key)); |
15910 entry = Derived::NextProbe(entry, count++, capacity); | 15913 entry = Derived::NextProbe(entry, count++, capacity); |
15911 } | 15914 } |
15912 return Derived::kNotFound; | 15915 return Derived::kNotFound; |
15913 } | 15916 } |
15914 | 15917 |
15915 | 15918 |
15916 template<typename Derived, typename Shape, typename Key> | 15919 template<typename Derived, typename Shape, typename Key> |
15917 void HashTable<Derived, Shape, Key>::Rehash( | 15920 void HashTable<Derived, Shape, Key>::Rehash( |
15918 Handle<Derived> new_table, | 15921 Handle<Derived> new_table, |
15919 Key key) { | 15922 Key key) { |
(...skipping 2663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18583 if (cell->value() != *new_value) { | 18586 if (cell->value() != *new_value) { |
18584 cell->set_value(*new_value); | 18587 cell->set_value(*new_value); |
18585 Isolate* isolate = cell->GetIsolate(); | 18588 Isolate* isolate = cell->GetIsolate(); |
18586 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 18589 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
18587 isolate, DependentCode::kPropertyCellChangedGroup); | 18590 isolate, DependentCode::kPropertyCellChangedGroup); |
18588 } | 18591 } |
18589 } | 18592 } |
18590 | 18593 |
18591 } // namespace internal | 18594 } // namespace internal |
18592 } // namespace v8 | 18595 } // namespace v8 |
OLD | NEW |