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 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/assert-scope.h" | 9 #include "src/assert-scope.h" |
10 #include "src/builtins.h" | 10 #include "src/builtins.h" |
(...skipping 8836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8847 | 8847 |
8848 int length_; | 8848 int length_; |
8849 uint32_t raw_running_hash_; | 8849 uint32_t raw_running_hash_; |
8850 uint32_t array_index_; | 8850 uint32_t array_index_; |
8851 bool is_array_index_; | 8851 bool is_array_index_; |
8852 bool is_first_char_; | 8852 bool is_first_char_; |
8853 DISALLOW_COPY_AND_ASSIGN(StringHasher); | 8853 DISALLOW_COPY_AND_ASSIGN(StringHasher); |
8854 }; | 8854 }; |
8855 | 8855 |
8856 | 8856 |
8857 class IteratingStringHasher : public StringHasher { | |
8858 public: | |
8859 static inline uint32_t Hash(String* string, uint32_t seed); | |
8860 inline void VisitOneByteString(const uint8_t* chars, int length); | |
8861 inline void VisitTwoByteString(const uint16_t* chars, int length); | |
8862 | |
8863 private: | |
8864 inline IteratingStringHasher(int len, uint32_t seed) | |
8865 : StringHasher(len, seed) {} | |
8866 DISALLOW_COPY_AND_ASSIGN(IteratingStringHasher); | |
8867 }; | |
vogelheim
2014/07/15 13:42:31
design nitpick: Not sure if exposing this class is
| |
8868 | |
8869 | |
8857 // The characteristics of a string are stored in its map. Retrieving these | 8870 // The characteristics of a string are stored in its map. Retrieving these |
8858 // few bits of information is moderately expensive, involving two memory | 8871 // few bits of information is moderately expensive, involving two memory |
8859 // loads where the second is dependent on the first. To improve efficiency | 8872 // loads where the second is dependent on the first. To improve efficiency |
8860 // the shape of the string is given its own class so that it can be retrieved | 8873 // the shape of the string is given its own class so that it can be retrieved |
8861 // once and used for several string operations. A StringShape is small enough | 8874 // once and used for several string operations. A StringShape is small enough |
8862 // to be passed by value and is immutable, but be aware that flattening a | 8875 // to be passed by value and is immutable, but be aware that flattening a |
8863 // string can potentially alter its shape. Also be aware that a GC caused by | 8876 // string can potentially alter its shape. Also be aware that a GC caused by |
8864 // something else can alter the shape of a string due to ConsString | 8877 // something else can alter the shape of a string due to ConsString |
8865 // shortcutting. Keeping these restrictions in mind has proven to be error- | 8878 // shortcutting. Keeping these restrictions in mind has proven to be error- |
8866 // prone and so we no longer put StringShapes in variables unless there is a | 8879 // prone and so we no longer put StringShapes in variables unless there is a |
(...skipping 2360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11227 } else { | 11240 } else { |
11228 value &= ~(1 << bit_position); | 11241 value &= ~(1 << bit_position); |
11229 } | 11242 } |
11230 return value; | 11243 return value; |
11231 } | 11244 } |
11232 }; | 11245 }; |
11233 | 11246 |
11234 } } // namespace v8::internal | 11247 } } // namespace v8::internal |
11235 | 11248 |
11236 #endif // V8_OBJECTS_H_ | 11249 #endif // V8_OBJECTS_H_ |
OLD | NEW |