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 <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 17638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17649 length_, seed); | 17649 length_, seed); |
17650 } else { | 17650 } else { |
17651 two_byte_content_ = new uint16_t[length_]; | 17651 two_byte_content_ = new uint16_t[length_]; |
17652 String::WriteToFlat(string, two_byte_content_, 0, length_); | 17652 String::WriteToFlat(string, two_byte_content_, 0, length_); |
17653 hash_field = StringHasher::HashSequentialString(two_byte_content_, | 17653 hash_field = StringHasher::HashSequentialString(two_byte_content_, |
17654 length_, seed); | 17654 length_, seed); |
17655 } | 17655 } |
17656 string->set_hash_field(hash_field); | 17656 string->set_hash_field(hash_field); |
17657 } else { | 17657 } else { |
17658 special_flattening_ = false; | 17658 special_flattening_ = false; |
| 17659 one_byte_content_ = nullptr; |
17659 } | 17660 } |
17660 hash_ = string->Hash(); | 17661 hash_ = string->Hash(); |
17661 } | 17662 } |
17662 | 17663 |
17663 ~StringTableNoAllocateKey() { | 17664 ~StringTableNoAllocateKey() { |
17664 if (one_byte_) { | 17665 if (one_byte_) { |
17665 delete[] one_byte_content_; | 17666 delete[] one_byte_content_; |
17666 } else { | 17667 } else { |
17667 delete[] two_byte_content_; | 17668 delete[] two_byte_content_; |
17668 } | 17669 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17737 return Handle<String>(); | 17738 return Handle<String>(); |
17738 } | 17739 } |
17739 | 17740 |
17740 private: | 17741 private: |
17741 String* string_; | 17742 String* string_; |
17742 int length_; | 17743 int length_; |
17743 bool one_byte_; | 17744 bool one_byte_; |
17744 bool special_flattening_; | 17745 bool special_flattening_; |
17745 uint32_t hash_ = 0; | 17746 uint32_t hash_ = 0; |
17746 union { | 17747 union { |
17747 uint8_t* one_byte_content_ = nullptr; | 17748 uint8_t* one_byte_content_; |
17748 uint16_t* two_byte_content_; | 17749 uint16_t* two_byte_content_; |
17749 }; | 17750 }; |
17750 }; | 17751 }; |
17751 | 17752 |
17752 } // namespace | 17753 } // namespace |
17753 | 17754 |
17754 // static | 17755 // static |
17755 Object* StringTable::LookupStringIfExists_NoAllocate(String* string) { | 17756 Object* StringTable::LookupStringIfExists_NoAllocate(String* string) { |
17756 DisallowHeapAllocation no_gc; | 17757 DisallowHeapAllocation no_gc; |
17757 Heap* heap = string->GetHeap(); | 17758 Heap* heap = string->GetHeap(); |
(...skipping 2910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20668 // depend on this. | 20669 // depend on this. |
20669 return DICTIONARY_ELEMENTS; | 20670 return DICTIONARY_ELEMENTS; |
20670 } | 20671 } |
20671 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20672 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
20672 return kind; | 20673 return kind; |
20673 } | 20674 } |
20674 } | 20675 } |
20675 | 20676 |
20676 } // namespace internal | 20677 } // namespace internal |
20677 } // namespace v8 | 20678 } // namespace v8 |
OLD | NEW |