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 6704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6715 running_hash += (running_hash << 3); | 6715 running_hash += (running_hash << 3); |
6716 running_hash ^= (running_hash >> 11); | 6716 running_hash ^= (running_hash >> 11); |
6717 running_hash += (running_hash << 15); | 6717 running_hash += (running_hash << 15); |
6718 if ((running_hash & String::kHashBitMask) == 0) { | 6718 if ((running_hash & String::kHashBitMask) == 0) { |
6719 return kZeroHash; | 6719 return kZeroHash; |
6720 } | 6720 } |
6721 return running_hash; | 6721 return running_hash; |
6722 } | 6722 } |
6723 | 6723 |
6724 | 6724 |
6725 uint32_t StringHasher::ComputeRunningHash(uint32_t running_hash, | |
6726 const uc16* chars, int length) { | |
6727 DCHECK(chars && length > 0); | |
Dmitry Lomov (no reviews)
2014/11/27 07:23:05
Style nit: chars != nullptr.
Why 'length > 0', no
caitp (gmail)
2014/11/27 14:44:49
Well there's no harm in it being an empty loop, bu
| |
6728 for (int i = 0; i < length; ++i) { | |
6729 running_hash = AddCharacterCore(running_hash, *chars++); | |
6730 } | |
6731 return running_hash; | |
6732 } | |
6733 | |
6734 | |
6735 uint32_t StringHasher::ComputeRunningHashOneByte(uint32_t running_hash, | |
6736 const char* chars, | |
6737 int length) { | |
6738 DCHECK(chars && length > 0); | |
Dmitry Lomov (no reviews)
2014/11/27 07:23:05
Ditto
| |
6739 for (int i = 0; i < length; ++i) { | |
6740 uint16_t c = static_cast<uint16_t>(*chars++); | |
6741 running_hash = AddCharacterCore(running_hash, c); | |
6742 } | |
6743 return running_hash; | |
6744 } | |
6745 | |
6746 | |
6725 void StringHasher::AddCharacter(uint16_t c) { | 6747 void StringHasher::AddCharacter(uint16_t c) { |
6726 // Use the Jenkins one-at-a-time hash function to update the hash | 6748 // Use the Jenkins one-at-a-time hash function to update the hash |
6727 // for the given character. | 6749 // for the given character. |
6728 raw_running_hash_ = AddCharacterCore(raw_running_hash_, c); | 6750 raw_running_hash_ = AddCharacterCore(raw_running_hash_, c); |
6729 } | 6751 } |
6730 | 6752 |
6731 | 6753 |
6732 bool StringHasher::UpdateIndex(uint16_t c) { | 6754 bool StringHasher::UpdateIndex(uint16_t c) { |
6733 DCHECK(is_array_index_); | 6755 DCHECK(is_array_index_); |
6734 if (c < '0' || c > '9') { | 6756 if (c < '0' || c > '9') { |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7474 #undef READ_SHORT_FIELD | 7496 #undef READ_SHORT_FIELD |
7475 #undef WRITE_SHORT_FIELD | 7497 #undef WRITE_SHORT_FIELD |
7476 #undef READ_BYTE_FIELD | 7498 #undef READ_BYTE_FIELD |
7477 #undef WRITE_BYTE_FIELD | 7499 #undef WRITE_BYTE_FIELD |
7478 #undef NOBARRIER_READ_BYTE_FIELD | 7500 #undef NOBARRIER_READ_BYTE_FIELD |
7479 #undef NOBARRIER_WRITE_BYTE_FIELD | 7501 #undef NOBARRIER_WRITE_BYTE_FIELD |
7480 | 7502 |
7481 } } // namespace v8::internal | 7503 } } // namespace v8::internal |
7482 | 7504 |
7483 #endif // V8_OBJECTS_INL_H_ | 7505 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |