| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 4972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4983 // Isolate the array index form the full hash field. | 4983 // Isolate the array index form the full hash field. |
| 4984 *index = (kArrayIndexHashMask & field) >> kHashShift; | 4984 *index = (kArrayIndexHashMask & field) >> kHashShift; |
| 4985 return true; | 4985 return true; |
| 4986 } else { | 4986 } else { |
| 4987 StringInputBuffer buffer(this); | 4987 StringInputBuffer buffer(this); |
| 4988 return ComputeArrayIndex(&buffer, index, length()); | 4988 return ComputeArrayIndex(&buffer, index, length()); |
| 4989 } | 4989 } |
| 4990 } | 4990 } |
| 4991 | 4991 |
| 4992 | 4992 |
| 4993 uint32_t StringHasher::MakeCachedArrayIndex(uint32_t value, int length) { | 4993 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { |
| 4994 value <<= String::kHashShift; | |
| 4995 // For array indexes mix the length into the hash as an array index could | 4994 // For array indexes mix the length into the hash as an array index could |
| 4996 // be zero. | 4995 // be zero. |
| 4997 ASSERT(length > 0); | 4996 ASSERT(length > 0); |
| 4998 ASSERT(length <= String::kMaxArrayIndexSize); | 4997 ASSERT(length <= String::kMaxArrayIndexSize); |
| 4999 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < | 4998 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < |
| 5000 (1 << String::kArrayIndexValueBits)); | 4999 (1 << String::kArrayIndexValueBits)); |
| 5001 ASSERT(String::kMaxArrayIndexSize < (1 << String::kArrayIndexValueBits)); | 5000 |
| 5002 value &= ~String::kIsNotArrayIndexMask; | 5001 value <<= String::kHashShift; |
| 5003 value |= length << String::kArrayIndexHashLengthShift; | 5002 value |= length << String::kArrayIndexHashLengthShift; |
| 5003 |
| 5004 ASSERT((value & String::kIsNotArrayIndexMask) == 0); |
| 5005 ASSERT((length > String::kMaxCachedArrayIndexLength) || |
| 5006 (value & String::kContainsCachedArrayIndexMask) == 0); |
| 5004 return value; | 5007 return value; |
| 5005 } | 5008 } |
| 5006 | 5009 |
| 5007 | 5010 |
| 5008 uint32_t StringHasher::GetHashField() { | 5011 uint32_t StringHasher::GetHashField() { |
| 5009 ASSERT(is_valid()); | 5012 ASSERT(is_valid()); |
| 5010 if (length_ <= String::kMaxHashCalcLength) { | 5013 if (length_ <= String::kMaxHashCalcLength) { |
| 5011 if (is_array_index()) { | 5014 if (is_array_index()) { |
| 5012 return MakeCachedArrayIndex(array_index(), length_); | 5015 return MakeArrayIndexHash(array_index(), length_); |
| 5013 } | 5016 } |
| 5014 return (GetHash() << String::kHashShift) | String::kIsNotArrayIndexMask; | 5017 return (GetHash() << String::kHashShift) | String::kIsNotArrayIndexMask; |
| 5015 } else { | 5018 } else { |
| 5016 return (length_ << String::kHashShift) | String::kIsNotArrayIndexMask; | 5019 return (length_ << String::kHashShift) | String::kIsNotArrayIndexMask; |
| 5017 } | 5020 } |
| 5018 } | 5021 } |
| 5019 | 5022 |
| 5020 | 5023 |
| 5021 uint32_t String::ComputeHashField(unibrow::CharacterStream* buffer, | 5024 uint32_t String::ComputeHashField(unibrow::CharacterStream* buffer, |
| 5022 int length) { | 5025 int length) { |
| (...skipping 3865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8888 if (break_point_objects()->IsUndefined()) return 0; | 8891 if (break_point_objects()->IsUndefined()) return 0; |
| 8889 // Single beak point. | 8892 // Single beak point. |
| 8890 if (!break_point_objects()->IsFixedArray()) return 1; | 8893 if (!break_point_objects()->IsFixedArray()) return 1; |
| 8891 // Multiple break points. | 8894 // Multiple break points. |
| 8892 return FixedArray::cast(break_point_objects())->length(); | 8895 return FixedArray::cast(break_point_objects())->length(); |
| 8893 } | 8896 } |
| 8894 #endif | 8897 #endif |
| 8895 | 8898 |
| 8896 | 8899 |
| 8897 } } // namespace v8::internal | 8900 } } // namespace v8::internal |
| OLD | NEW |