OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 3667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3678 result += (result << 3); | 3678 result += (result << 3); |
3679 result ^= (result >> 11); | 3679 result ^= (result >> 11); |
3680 result += (result << 15); | 3680 result += (result << 15); |
3681 if (result == 0) { | 3681 if (result == 0) { |
3682 result = 27; | 3682 result = 27; |
3683 } | 3683 } |
3684 return result; | 3684 return result; |
3685 } | 3685 } |
3686 | 3686 |
3687 | 3687 |
| 3688 template <typename schar> |
| 3689 uint32_t HashSequentialString(const schar* chars, int length) { |
| 3690 StringHasher hasher(length); |
| 3691 if (!hasher.has_trivial_hash()) { |
| 3692 int i; |
| 3693 for (i = 0; hasher.is_array_index() && (i < length); i++) { |
| 3694 hasher.AddCharacter(chars[i]); |
| 3695 } |
| 3696 for (; i < length; i++) { |
| 3697 hasher.AddCharacterNoIndex(chars[i]); |
| 3698 } |
| 3699 } |
| 3700 return hasher.GetHashField(); |
| 3701 } |
| 3702 |
| 3703 |
3688 bool String::AsArrayIndex(uint32_t* index) { | 3704 bool String::AsArrayIndex(uint32_t* index) { |
3689 uint32_t field = hash_field(); | 3705 uint32_t field = hash_field(); |
3690 if (IsHashFieldComputed(field) && (field & kIsNotArrayIndexMask)) { | 3706 if (IsHashFieldComputed(field) && (field & kIsNotArrayIndexMask)) { |
3691 return false; | 3707 return false; |
3692 } | 3708 } |
3693 return SlowAsArrayIndex(index); | 3709 return SlowAsArrayIndex(index); |
3694 } | 3710 } |
3695 | 3711 |
3696 | 3712 |
3697 Object* JSObject::GetPrototype() { | 3713 Object* JSObject::GetPrototype() { |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3937 #undef WRITE_INT_FIELD | 3953 #undef WRITE_INT_FIELD |
3938 #undef READ_SHORT_FIELD | 3954 #undef READ_SHORT_FIELD |
3939 #undef WRITE_SHORT_FIELD | 3955 #undef WRITE_SHORT_FIELD |
3940 #undef READ_BYTE_FIELD | 3956 #undef READ_BYTE_FIELD |
3941 #undef WRITE_BYTE_FIELD | 3957 #undef WRITE_BYTE_FIELD |
3942 | 3958 |
3943 | 3959 |
3944 } } // namespace v8::internal | 3960 } } // namespace v8::internal |
3945 | 3961 |
3946 #endif // V8_OBJECTS_INL_H_ | 3962 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |