| 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 2933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2944 if (current_hash > hash) { | 2944 if (current_hash > hash) { |
| 2945 if (out_insertion_index != NULL) *out_insertion_index = sorted_index; | 2945 if (out_insertion_index != NULL) *out_insertion_index = sorted_index; |
| 2946 return T::kNotFound; | 2946 return T::kNotFound; |
| 2947 } | 2947 } |
| 2948 if (current_hash == hash && entry->Equals(name)) return sorted_index; | 2948 if (current_hash == hash && entry->Equals(name)) return sorted_index; |
| 2949 } | 2949 } |
| 2950 if (out_insertion_index != NULL) *out_insertion_index = len; | 2950 if (out_insertion_index != NULL) *out_insertion_index = len; |
| 2951 return T::kNotFound; | 2951 return T::kNotFound; |
| 2952 } else { | 2952 } else { |
| 2953 DCHECK(len >= valid_entries); | 2953 DCHECK(len >= valid_entries); |
| 2954 DCHECK_EQ(NULL, out_insertion_index); // Not supported here. | 2954 DCHECK(!out_insertion_index); // Not supported here. |
| 2955 for (int number = 0; number < valid_entries; number++) { | 2955 for (int number = 0; number < valid_entries; number++) { |
| 2956 Name* entry = array->GetKey(number); | 2956 Name* entry = array->GetKey(number); |
| 2957 uint32_t current_hash = entry->Hash(); | 2957 uint32_t current_hash = entry->Hash(); |
| 2958 if (current_hash == hash && entry->Equals(name)) return number; | 2958 if (current_hash == hash && entry->Equals(name)) return number; |
| 2959 } | 2959 } |
| 2960 return T::kNotFound; | 2960 return T::kNotFound; |
| 2961 } | 2961 } |
| 2962 } | 2962 } |
| 2963 | 2963 |
| 2964 | 2964 |
| (...skipping 3804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6769 running_hash += (running_hash << 15); | 6769 running_hash += (running_hash << 15); |
| 6770 if ((running_hash & String::kHashBitMask) == 0) { | 6770 if ((running_hash & String::kHashBitMask) == 0) { |
| 6771 return kZeroHash; | 6771 return kZeroHash; |
| 6772 } | 6772 } |
| 6773 return running_hash; | 6773 return running_hash; |
| 6774 } | 6774 } |
| 6775 | 6775 |
| 6776 | 6776 |
| 6777 uint32_t StringHasher::ComputeRunningHash(uint32_t running_hash, | 6777 uint32_t StringHasher::ComputeRunningHash(uint32_t running_hash, |
| 6778 const uc16* chars, int length) { | 6778 const uc16* chars, int length) { |
| 6779 DCHECK_NOT_NULL(chars); | 6779 DCHECK(chars); |
| 6780 DCHECK(length >= 0); | 6780 DCHECK(length >= 0); |
| 6781 for (int i = 0; i < length; ++i) { | 6781 for (int i = 0; i < length; ++i) { |
| 6782 running_hash = AddCharacterCore(running_hash, *chars++); | 6782 running_hash = AddCharacterCore(running_hash, *chars++); |
| 6783 } | 6783 } |
| 6784 return running_hash; | 6784 return running_hash; |
| 6785 } | 6785 } |
| 6786 | 6786 |
| 6787 | 6787 |
| 6788 uint32_t StringHasher::ComputeRunningHashOneByte(uint32_t running_hash, | 6788 uint32_t StringHasher::ComputeRunningHashOneByte(uint32_t running_hash, |
| 6789 const char* chars, | 6789 const char* chars, |
| 6790 int length) { | 6790 int length) { |
| 6791 DCHECK_NOT_NULL(chars); | 6791 DCHECK(chars); |
| 6792 DCHECK(length >= 0); | 6792 DCHECK(length >= 0); |
| 6793 for (int i = 0; i < length; ++i) { | 6793 for (int i = 0; i < length; ++i) { |
| 6794 uint16_t c = static_cast<uint16_t>(*chars++); | 6794 uint16_t c = static_cast<uint16_t>(*chars++); |
| 6795 running_hash = AddCharacterCore(running_hash, c); | 6795 running_hash = AddCharacterCore(running_hash, c); |
| 6796 } | 6796 } |
| 6797 return running_hash; | 6797 return running_hash; |
| 6798 } | 6798 } |
| 6799 | 6799 |
| 6800 | 6800 |
| 6801 void StringHasher::AddCharacter(uint16_t c) { | 6801 void StringHasher::AddCharacter(uint16_t c) { |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7595 #undef READ_SHORT_FIELD | 7595 #undef READ_SHORT_FIELD |
| 7596 #undef WRITE_SHORT_FIELD | 7596 #undef WRITE_SHORT_FIELD |
| 7597 #undef READ_BYTE_FIELD | 7597 #undef READ_BYTE_FIELD |
| 7598 #undef WRITE_BYTE_FIELD | 7598 #undef WRITE_BYTE_FIELD |
| 7599 #undef NOBARRIER_READ_BYTE_FIELD | 7599 #undef NOBARRIER_READ_BYTE_FIELD |
| 7600 #undef NOBARRIER_WRITE_BYTE_FIELD | 7600 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 7601 | 7601 |
| 7602 } } // namespace v8::internal | 7602 } } // namespace v8::internal |
| 7603 | 7603 |
| 7604 #endif // V8_OBJECTS_INL_H_ | 7604 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |