LCOV - code coverage report
Current view: top level - src/objects - string-table.h (source / functions) Hit Total Coverage
Test: app.info Lines: 3 3 100.0 %
Date: 2017-10-20 Functions: 0 2 0.0 %

          Line data    Source code
       1             : // Copyright 2017 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #ifndef V8_OBJECTS_STRING_TABLE_H_
       6             : #define V8_OBJECTS_STRING_TABLE_H_
       7             : 
       8             : #include "src/objects/hash-table.h"
       9             : 
      10             : // Has to be the last include (doesn't have include guards):
      11             : #include "src/objects/object-macros.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : 
      16       53400 : class StringTableKey : public HashTableKey {
      17             :  public:
      18             :   explicit inline StringTableKey(uint32_t hash_field);
      19             : 
      20             :   virtual Handle<String> AsHandle(Isolate* isolate) = 0;
      21             :   uint32_t HashField() const {
      22             :     DCHECK_NE(0, hash_field_);
      23             :     return hash_field_;
      24             :   }
      25             : 
      26             :  protected:
      27             :   inline void set_hash_field(uint32_t hash_field);
      28             : 
      29             :  private:
      30             :   uint32_t hash_field_ = 0;
      31             : };
      32             : 
      33             : class StringTableShape : public BaseShape<StringTableKey*> {
      34             :  public:
      35             :   static inline bool IsMatch(Key key, Object* value) {
      36   118450889 :     return key->IsMatch(value);
      37             :   }
      38             : 
      39    65246131 :   static inline uint32_t Hash(Isolate* isolate, Key key) { return key->Hash(); }
      40             : 
      41             :   static inline uint32_t HashForObject(Isolate* isolate, Object* object);
      42             : 
      43             :   static inline Handle<Object> AsHandle(Isolate* isolate, Key key);
      44             : 
      45             :   static const int kPrefixSize = 0;
      46             :   static const int kEntrySize = 1;
      47             : };
      48             : 
      49             : class SeqOneByteString;
      50             : 
      51             : // StringTable.
      52             : //
      53             : // No special elements in the prefix and the element size is 1
      54             : // because only the string itself (the key) needs to be stored.
      55             : class StringTable : public HashTable<StringTable, StringTableShape> {
      56             :  public:
      57             :   // Find string in the string table. If it is not there yet, it is
      58             :   // added. The return value is the string found.
      59             :   V8_EXPORT_PRIVATE static Handle<String> LookupString(Isolate* isolate,
      60             :                                                        Handle<String> key);
      61             :   static Handle<String> LookupKey(Isolate* isolate, StringTableKey* key);
      62             :   static String* LookupKeyIfExists(Isolate* isolate, StringTableKey* key);
      63             : 
      64             :   // Looks up a string that is equal to the given string and returns
      65             :   // string handle if it is found, or an empty handle otherwise.
      66             :   MUST_USE_RESULT static MaybeHandle<String> LookupTwoCharsStringIfExists(
      67             :       Isolate* isolate, uint16_t c1, uint16_t c2);
      68             :   static Object* LookupStringIfExists_NoAllocate(String* string);
      69             : 
      70             :   static void EnsureCapacityForDeserialization(Isolate* isolate, int expected);
      71             : 
      72             :   DECL_CAST(StringTable)
      73             : 
      74             :  private:
      75             :   template <bool seq_one_byte>
      76             :   friend class JsonParser;
      77             : 
      78             :   DISALLOW_IMPLICIT_CONSTRUCTORS(StringTable);
      79             : };
      80             : 
      81             : class StringSetShape : public BaseShape<String*> {
      82             :  public:
      83             :   static inline bool IsMatch(String* key, Object* value);
      84             :   static inline uint32_t Hash(Isolate* isolate, String* key);
      85             :   static inline uint32_t HashForObject(Isolate* isolate, Object* object);
      86             : 
      87             :   static const int kPrefixSize = 0;
      88             :   static const int kEntrySize = 1;
      89             : };
      90             : 
      91             : class StringSet : public HashTable<StringSet, StringSetShape> {
      92             :  public:
      93             :   static Handle<StringSet> New(Isolate* isolate);
      94             :   static Handle<StringSet> Add(Handle<StringSet> blacklist,
      95             :                                Handle<String> name);
      96             :   bool Has(Handle<String> name);
      97             : 
      98             :   DECL_CAST(StringSet)
      99             : };
     100             : 
     101             : }  // namespace internal
     102             : }  // namespace v8
     103             : 
     104             : #include "src/objects/object-macros-undef.h"
     105             : 
     106             : #endif  // V8_OBJECTS_STRING_TABLE_H_

Generated by: LCOV version 1.10