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