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 11075 matching lines...) Loading... |
11086 // be zero. | 11086 // be zero. |
11087 DCHECK(length > 0); | 11087 DCHECK(length > 0); |
11088 DCHECK(length <= String::kMaxArrayIndexSize); | 11088 DCHECK(length <= String::kMaxArrayIndexSize); |
11089 DCHECK(TenToThe(String::kMaxCachedArrayIndexLength) < | 11089 DCHECK(TenToThe(String::kMaxCachedArrayIndexLength) < |
11090 (1 << String::kArrayIndexValueBits)); | 11090 (1 << String::kArrayIndexValueBits)); |
11091 | 11091 |
11092 value <<= String::ArrayIndexValueBits::kShift; | 11092 value <<= String::ArrayIndexValueBits::kShift; |
11093 value |= length << String::ArrayIndexLengthBits::kShift; | 11093 value |= length << String::ArrayIndexLengthBits::kShift; |
11094 | 11094 |
11095 DCHECK((value & String::kIsNotArrayIndexMask) == 0); | 11095 DCHECK((value & String::kIsNotArrayIndexMask) == 0); |
11096 DCHECK((length > String::kMaxCachedArrayIndexLength) || | 11096 DCHECK_EQ(length <= String::kMaxCachedArrayIndexLength, |
11097 (value & String::kContainsCachedArrayIndexMask) == 0); | 11097 (value & String::kContainsCachedArrayIndexMask) == 0); |
11098 return value; | 11098 return value; |
11099 } | 11099 } |
11100 | 11100 |
11101 | 11101 |
11102 uint32_t StringHasher::GetHashField() { | 11102 uint32_t StringHasher::GetHashField() { |
11103 if (length_ <= String::kMaxHashCalcLength) { | 11103 if (length_ <= String::kMaxHashCalcLength) { |
11104 if (is_array_index_) { | 11104 if (is_array_index_) { |
11105 return MakeArrayIndexHash(array_index_, length_); | 11105 return MakeArrayIndexHash(array_index_, length_); |
11106 } | 11106 } |
11107 return (GetHashCore(raw_running_hash_) << String::kHashShift) | | 11107 return (GetHashCore(raw_running_hash_) << String::kHashShift) | |
(...skipping 3900 matching lines...) Loading... |
15008 os << "\n "; | 15008 os << "\n "; |
15009 if (k->IsString()) { | 15009 if (k->IsString()) { |
15010 String::cast(k)->StringPrint(os); | 15010 String::cast(k)->StringPrint(os); |
15011 } else { | 15011 } else { |
15012 os << Brief(k); | 15012 os << Brief(k); |
15013 } | 15013 } |
15014 os << ": " << Brief(this->ValueAt(i)) << " " << this->DetailsAt(i); | 15014 os << ": " << Brief(this->ValueAt(i)) << " " << this->DetailsAt(i); |
15015 } | 15015 } |
15016 } | 15016 } |
15017 } | 15017 } |
| 15018 template <typename Derived, typename Shape, typename Key> |
| 15019 void Dictionary<Derived, Shape, Key>::Print() { |
| 15020 OFStream os(stdout); |
| 15021 Print(os); |
| 15022 } |
15018 #endif | 15023 #endif |
15019 | 15024 |
15020 | 15025 |
15021 template<typename Derived, typename Shape, typename Key> | 15026 template<typename Derived, typename Shape, typename Key> |
15022 void Dictionary<Derived, Shape, Key>::CopyValuesTo(FixedArray* elements) { | 15027 void Dictionary<Derived, Shape, Key>::CopyValuesTo(FixedArray* elements) { |
15023 int pos = 0; | 15028 int pos = 0; |
15024 int capacity = this->Capacity(); | 15029 int capacity = this->Capacity(); |
15025 DisallowHeapAllocation no_gc; | 15030 DisallowHeapAllocation no_gc; |
15026 WriteBarrierMode mode = elements->GetWriteBarrierMode(no_gc); | 15031 WriteBarrierMode mode = elements->GetWriteBarrierMode(no_gc); |
15027 for (int i = 0; i < capacity; i++) { | 15032 for (int i = 0; i < capacity; i++) { |
(...skipping 695 matching lines...) Loading... |
15723 // EnsureCapacity will guarantee the hash table is never full. | 15728 // EnsureCapacity will guarantee the hash table is never full. |
15724 uint32_t capacity = this->Capacity(); | 15729 uint32_t capacity = this->Capacity(); |
15725 uint32_t entry = Derived::FirstProbe(key->Hash(), capacity); | 15730 uint32_t entry = Derived::FirstProbe(key->Hash(), capacity); |
15726 uint32_t count = 1; | 15731 uint32_t count = 1; |
15727 | 15732 |
15728 while (true) { | 15733 while (true) { |
15729 int index = Derived::EntryToIndex(entry); | 15734 int index = Derived::EntryToIndex(entry); |
15730 Object* element = this->get(index); | 15735 Object* element = this->get(index); |
15731 if (element->IsUndefined()) break; // Empty entry. | 15736 if (element->IsUndefined()) break; // Empty entry. |
15732 if (*key == element) return entry; | 15737 if (*key == element) return entry; |
15733 if (!element->IsUniqueName() && | 15738 DCHECK(element->IsTheHole() || element->IsUniqueName()); |
15734 !element->IsTheHole() && | |
15735 Name::cast(element)->Equals(*key)) { | |
15736 // Replace a key that is a non-internalized string by the equivalent | |
15737 // internalized string for faster further lookups. | |
15738 this->set(index, *key); | |
15739 return entry; | |
15740 } | |
15741 DCHECK(element->IsTheHole() || !Name::cast(element)->Equals(*key)); | |
15742 entry = Derived::NextProbe(entry, count++, capacity); | 15739 entry = Derived::NextProbe(entry, count++, capacity); |
15743 } | 15740 } |
15744 return Derived::kNotFound; | 15741 return Derived::kNotFound; |
15745 } | 15742 } |
15746 | 15743 |
15747 | 15744 |
15748 template<typename Derived, typename Shape, typename Key> | 15745 template<typename Derived, typename Shape, typename Key> |
15749 void HashTable<Derived, Shape, Key>::Rehash( | 15746 void HashTable<Derived, Shape, Key>::Rehash( |
15750 Handle<Derived> new_table, | 15747 Handle<Derived> new_table, |
15751 Key key) { | 15748 Key key) { |
(...skipping 2629 matching lines...) Loading... |
18381 if (cell->value() != *new_value) { | 18378 if (cell->value() != *new_value) { |
18382 cell->set_value(*new_value); | 18379 cell->set_value(*new_value); |
18383 Isolate* isolate = cell->GetIsolate(); | 18380 Isolate* isolate = cell->GetIsolate(); |
18384 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 18381 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
18385 isolate, DependentCode::kPropertyCellChangedGroup); | 18382 isolate, DependentCode::kPropertyCellChangedGroup); |
18386 } | 18383 } |
18387 } | 18384 } |
18388 | 18385 |
18389 } // namespace internal | 18386 } // namespace internal |
18390 } // namespace v8 | 18387 } // namespace v8 |
OLD | NEW |