OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 <iosfwd> | 8 #include <iosfwd> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 3506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3517 // No special elements in the prefix and the element size is 1 | 3517 // No special elements in the prefix and the element size is 1 |
3518 // because only the string itself (the key) needs to be stored. | 3518 // because only the string itself (the key) needs to be stored. |
3519 class StringTable: public HashTable<StringTable, | 3519 class StringTable: public HashTable<StringTable, |
3520 StringTableShape, | 3520 StringTableShape, |
3521 HashTableKey*> { | 3521 HashTableKey*> { |
3522 public: | 3522 public: |
3523 // Find string in the string table. If it is not there yet, it is | 3523 // Find string in the string table. If it is not there yet, it is |
3524 // added. The return value is the string found. | 3524 // added. The return value is the string found. |
3525 V8_EXPORT_PRIVATE static Handle<String> LookupString(Isolate* isolate, | 3525 V8_EXPORT_PRIVATE static Handle<String> LookupString(Isolate* isolate, |
3526 Handle<String> key); | 3526 Handle<String> key); |
3527 static Handle<String> LookupKey(Isolate* isolate, HashTableKey* key); | 3527 static V8_INLINE Handle<String> LookupKey(Isolate* isolate, |
| 3528 HashTableKey* key); |
3528 static String* LookupKeyIfExists(Isolate* isolate, HashTableKey* key); | 3529 static String* LookupKeyIfExists(Isolate* isolate, HashTableKey* key); |
3529 | 3530 |
3530 // Tries to internalize given string and returns string handle on success | 3531 // Tries to internalize given string and returns string handle on success |
3531 // or an empty handle otherwise. | 3532 // or an empty handle otherwise. |
3532 MUST_USE_RESULT static MaybeHandle<String> InternalizeStringIfExists( | 3533 MUST_USE_RESULT static MaybeHandle<String> InternalizeStringIfExists( |
3533 Isolate* isolate, | 3534 Isolate* isolate, |
3534 Handle<String> string); | 3535 Handle<String> string); |
3535 | 3536 |
3536 // Looks up a string that is equal to the given string and returns | 3537 // Looks up a string that is equal to the given string and returns |
3537 // string handle if it is found, or an empty handle otherwise. | 3538 // string handle if it is found, or an empty handle otherwise. |
3538 MUST_USE_RESULT static MaybeHandle<String> LookupStringIfExists( | 3539 MUST_USE_RESULT static MaybeHandle<String> LookupStringIfExists( |
3539 Isolate* isolate, | 3540 Isolate* isolate, |
3540 Handle<String> str); | 3541 Handle<String> str); |
3541 MUST_USE_RESULT static MaybeHandle<String> LookupTwoCharsStringIfExists( | 3542 MUST_USE_RESULT static MaybeHandle<String> LookupTwoCharsStringIfExists( |
3542 Isolate* isolate, | 3543 Isolate* isolate, |
3543 uint16_t c1, | 3544 uint16_t c1, |
3544 uint16_t c2); | 3545 uint16_t c2); |
3545 | 3546 |
3546 static void EnsureCapacityForDeserialization(Isolate* isolate, int expected); | 3547 static void EnsureCapacityForDeserialization(Isolate* isolate, int expected); |
3547 | 3548 |
3548 DECLARE_CAST(StringTable) | 3549 DECLARE_CAST(StringTable) |
3549 | 3550 |
3550 private: | 3551 private: |
| 3552 static Handle<String> InsertKey(Isolate* isolate, Handle<StringTable> table, |
| 3553 HashTableKey* key, int32_t hash); |
| 3554 |
3551 template <bool seq_one_byte> | 3555 template <bool seq_one_byte> |
3552 friend class JsonParser; | 3556 friend class JsonParser; |
3553 | 3557 |
3554 DISALLOW_IMPLICIT_CONSTRUCTORS(StringTable); | 3558 DISALLOW_IMPLICIT_CONSTRUCTORS(StringTable); |
3555 }; | 3559 }; |
3556 | 3560 |
3557 class StringSetShape : public BaseShape<String*> { | 3561 class StringSetShape : public BaseShape<String*> { |
3558 public: | 3562 public: |
3559 static inline bool IsMatch(String* key, Object* value); | 3563 static inline bool IsMatch(String* key, Object* value); |
3560 static inline uint32_t Hash(String* key); | 3564 static inline uint32_t Hash(String* key); |
(...skipping 5467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9028 INLINE(static uint32_t GetHashCore(uint32_t running_hash)); | 9032 INLINE(static uint32_t GetHashCore(uint32_t running_hash)); |
9029 INLINE(static uint32_t ComputeRunningHash(uint32_t running_hash, | 9033 INLINE(static uint32_t ComputeRunningHash(uint32_t running_hash, |
9030 const uc16* chars, int length)); | 9034 const uc16* chars, int length)); |
9031 INLINE(static uint32_t ComputeRunningHashOneByte(uint32_t running_hash, | 9035 INLINE(static uint32_t ComputeRunningHashOneByte(uint32_t running_hash, |
9032 const char* chars, | 9036 const char* chars, |
9033 int length)); | 9037 int length)); |
9034 | 9038 |
9035 protected: | 9039 protected: |
9036 // Returns the value to store in the hash field of a string with | 9040 // Returns the value to store in the hash field of a string with |
9037 // the given length and contents. | 9041 // the given length and contents. |
9038 uint32_t GetHashField(); | 9042 V8_INLINE uint32_t GetHashField(); |
9039 // Returns true if the hash of this string can be computed without | 9043 // Returns true if the hash of this string can be computed without |
9040 // looking at the contents. | 9044 // looking at the contents. |
9041 inline bool has_trivial_hash(); | 9045 inline bool has_trivial_hash(); |
9042 // Adds a block of characters to the hash. | 9046 // Adds a block of characters to the hash. |
9043 template<typename Char> | 9047 template<typename Char> |
9044 inline void AddCharacters(const Char* chars, int len); | 9048 inline void AddCharacters(const Char* chars, int len); |
9045 | 9049 |
9046 private: | 9050 private: |
9047 // Add a character to the hash. | 9051 // Add a character to the hash. |
9048 inline void AddCharacter(uint16_t c); | 9052 inline void AddCharacter(uint16_t c); |
(...skipping 2539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11588 } | 11592 } |
11589 }; | 11593 }; |
11590 | 11594 |
11591 | 11595 |
11592 } // NOLINT, false-positive due to second-order macros. | 11596 } // NOLINT, false-positive due to second-order macros. |
11593 } // NOLINT, false-positive due to second-order macros. | 11597 } // NOLINT, false-positive due to second-order macros. |
11594 | 11598 |
11595 #include "src/objects/object-macros-undef.h" | 11599 #include "src/objects/object-macros-undef.h" |
11596 | 11600 |
11597 #endif // V8_OBJECTS_H_ | 11601 #endif // V8_OBJECTS_H_ |
OLD | NEW |