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 6544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6555 template <typename schar> | 6555 template <typename schar> |
6556 uint32_t StringHasher::HashSequentialString(const schar* chars, | 6556 uint32_t StringHasher::HashSequentialString(const schar* chars, |
6557 int length, | 6557 int length, |
6558 uint32_t seed) { | 6558 uint32_t seed) { |
6559 StringHasher hasher(length, seed); | 6559 StringHasher hasher(length, seed); |
6560 if (!hasher.has_trivial_hash()) hasher.AddCharacters(chars, length); | 6560 if (!hasher.has_trivial_hash()) hasher.AddCharacters(chars, length); |
6561 return hasher.GetHashField(); | 6561 return hasher.GetHashField(); |
6562 } | 6562 } |
6563 | 6563 |
6564 | 6564 |
| 6565 uint32_t IteratingStringHasher::Hash(String* string, uint32_t seed) { |
| 6566 IteratingStringHasher hasher(string->length(), seed); |
| 6567 // Nothing to do. |
| 6568 if (hasher.has_trivial_hash()) return hasher.GetHashField(); |
| 6569 ConsString* cons_string = String::VisitFlat(&hasher, string); |
| 6570 // The string was flat. |
| 6571 if (cons_string == NULL) return hasher.GetHashField(); |
| 6572 // This is a ConsString, iterate across it. |
| 6573 ConsStringIteratorOp op(cons_string); |
| 6574 int offset; |
| 6575 while (NULL != (string = op.Next(&offset))) { |
| 6576 String::VisitFlat(&hasher, string, offset); |
| 6577 } |
| 6578 return hasher.GetHashField(); |
| 6579 } |
| 6580 |
| 6581 |
| 6582 void IteratingStringHasher::VisitOneByteString(const uint8_t* chars, |
| 6583 int length) { |
| 6584 AddCharacters(chars, length); |
| 6585 } |
| 6586 |
| 6587 |
| 6588 void IteratingStringHasher::VisitTwoByteString(const uint16_t* chars, |
| 6589 int length) { |
| 6590 AddCharacters(chars, length); |
| 6591 } |
| 6592 |
| 6593 |
6565 bool Name::AsArrayIndex(uint32_t* index) { | 6594 bool Name::AsArrayIndex(uint32_t* index) { |
6566 return IsString() && String::cast(this)->AsArrayIndex(index); | 6595 return IsString() && String::cast(this)->AsArrayIndex(index); |
6567 } | 6596 } |
6568 | 6597 |
6569 | 6598 |
6570 bool String::AsArrayIndex(uint32_t* index) { | 6599 bool String::AsArrayIndex(uint32_t* index) { |
6571 uint32_t field = hash_field(); | 6600 uint32_t field = hash_field(); |
6572 if (IsHashFieldComputed(field) && (field & kIsNotArrayIndexMask)) { | 6601 if (IsHashFieldComputed(field) && (field & kIsNotArrayIndexMask)) { |
6573 return false; | 6602 return false; |
6574 } | 6603 } |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7169 #undef READ_SHORT_FIELD | 7198 #undef READ_SHORT_FIELD |
7170 #undef WRITE_SHORT_FIELD | 7199 #undef WRITE_SHORT_FIELD |
7171 #undef READ_BYTE_FIELD | 7200 #undef READ_BYTE_FIELD |
7172 #undef WRITE_BYTE_FIELD | 7201 #undef WRITE_BYTE_FIELD |
7173 #undef NOBARRIER_READ_BYTE_FIELD | 7202 #undef NOBARRIER_READ_BYTE_FIELD |
7174 #undef NOBARRIER_WRITE_BYTE_FIELD | 7203 #undef NOBARRIER_WRITE_BYTE_FIELD |
7175 | 7204 |
7176 } } // namespace v8::internal | 7205 } } // namespace v8::internal |
7177 | 7206 |
7178 #endif // V8_OBJECTS_INL_H_ | 7207 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |