OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 6916 matching lines...) Loading... |
6927 | 6927 |
6928 class StringHasher { | 6928 class StringHasher { |
6929 public: | 6929 public: |
6930 explicit inline StringHasher(int length, uint32_t seed); | 6930 explicit inline StringHasher(int length, uint32_t seed); |
6931 | 6931 |
6932 template <typename schar> | 6932 template <typename schar> |
6933 static inline uint32_t HashSequentialString(const schar* chars, | 6933 static inline uint32_t HashSequentialString(const schar* chars, |
6934 int length, | 6934 int length, |
6935 uint32_t seed); | 6935 uint32_t seed); |
6936 | 6936 |
6937 static uint32_t ComputeHashField(unibrow::CharacterStream* buffer, | 6937 // Reads all the data, even for long strings and computes the utf16 length. |
6938 int length, | 6938 static uint32_t ComputeUtf8Hash(Vector<const char> chars, |
6939 uint32_t seed); | 6939 uint32_t seed, |
| 6940 int* utf16_length_out); |
6940 | 6941 |
6941 // Calculated hash value for a string consisting of 1 to | 6942 // Calculated hash value for a string consisting of 1 to |
6942 // String::kMaxArrayIndexSize digits with no leading zeros (except "0"). | 6943 // String::kMaxArrayIndexSize digits with no leading zeros (except "0"). |
6943 // value is represented decimal value. | 6944 // value is represented decimal value. |
6944 static uint32_t MakeArrayIndexHash(uint32_t value, int length); | 6945 static uint32_t MakeArrayIndexHash(uint32_t value, int length); |
6945 | 6946 |
6946 // No string is allowed to have a hash of zero. That value is reserved | 6947 // No string is allowed to have a hash of zero. That value is reserved |
6947 // for internal properties. If the hash calculation yields zero then we | 6948 // for internal properties. If the hash calculation yields zero then we |
6948 // use 27 instead. | 6949 // use 27 instead. |
6949 static const int kZeroHash = 27; | 6950 static const int kZeroHash = 27; |
(...skipping 1933 matching lines...) Loading... |
8883 } else { | 8884 } else { |
8884 value &= ~(1 << bit_position); | 8885 value &= ~(1 << bit_position); |
8885 } | 8886 } |
8886 return value; | 8887 return value; |
8887 } | 8888 } |
8888 }; | 8889 }; |
8889 | 8890 |
8890 } } // namespace v8::internal | 8891 } } // namespace v8::internal |
8891 | 8892 |
8892 #endif // V8_OBJECTS_H_ | 8893 #endif // V8_OBJECTS_H_ |
OLD | NEW |