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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
// Copyright 2019 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.
#include 'src/objects/ordered-hash-table.h'
// Using int as a dummy type-parameter to get access to these constants which
// don't actually depend on the derived class. This avoids accidentially
// depending on something from a concrete derived class.
const kSmallOrderedHashTableMaxCapacity: constexpr int31
generates 'SmallOrderedHashTable<int>::kMaxCapacity';
const kSmallOrderedHashTableNotFound: constexpr int31
generates 'SmallOrderedHashTable<int>::kNotFound';
const kSmallOrderedHashTableLoadFactor: constexpr int31
generates 'SmallOrderedHashTable<int>::kLoadFactor';
@noVerifier
@abstract
extern class SmallOrderedHashTable extends HeapObject
generates 'TNode<HeapObject>' {
}
extern macro SmallOrderedHashSetMapConstant(): Map;
const kSmallOrderedHashSetMap: Map = SmallOrderedHashSetMapConstant();
extern class SmallOrderedHashSet extends SmallOrderedHashTable {
number_of_elements: uint8;
number_of_deleted_elements: uint8;
const number_of_buckets: uint8;
@if(TAGGED_SIZE_8_BYTES) padding[5]: uint8;
@ifnot(TAGGED_SIZE_8_BYTES) padding[1]: uint8;
data_table[Convert<intptr>(number_of_buckets) * kSmallOrderedHashTableLoadFactor]:
JSAny|TheHole;
hash_table[number_of_buckets]: uint8;
chain_table[Convert<intptr>(number_of_buckets) * kSmallOrderedHashTableLoadFactor]:
uint8;
}
@export
macro AllocateSmallOrderedHashSet(capacity: intptr): SmallOrderedHashSet {
const hashTableSize = capacity / kSmallOrderedHashTableLoadFactor;
assert(
0 <= hashTableSize && hashTableSize <= kSmallOrderedHashTableMaxCapacity);
return new SmallOrderedHashSet{
map: kSmallOrderedHashSetMap,
number_of_elements: 0,
number_of_deleted_elements: 0,
number_of_buckets: (Convert<uint8>(hashTableSize)),
padding: ...ConstantIterator<uint8>(0),
data_table: ...ConstantIterator(TheHole),
hash_table: ...ConstantIterator<uint8>(kSmallOrderedHashTableNotFound),
chain_table: ...ConstantIterator<uint8>(kSmallOrderedHashTableNotFound)
};
}
struct HashMapEntry {
key: JSAny|TheHole;
value: JSAny|TheHole;
}
extern macro SmallOrderedHashMapMapConstant(): Map;
const kSmallOrderedHashMapMap: Map = SmallOrderedHashMapMapConstant();
extern class SmallOrderedHashMap extends SmallOrderedHashTable {
number_of_elements: uint8;
number_of_deleted_elements: uint8;
const number_of_buckets: uint8;
@if(TAGGED_SIZE_8_BYTES) padding[5]: uint8;
@ifnot(TAGGED_SIZE_8_BYTES) padding[1]: uint8;
data_table[Convert<intptr>(number_of_buckets) * kSmallOrderedHashTableLoadFactor]:
HashMapEntry;
hash_table[number_of_buckets]: uint8;
chain_table[Convert<intptr>(number_of_buckets) * kSmallOrderedHashTableLoadFactor]:
uint8;
}
@export
macro AllocateSmallOrderedHashMap(capacity: intptr): SmallOrderedHashMap {
const hashTableSize = capacity / kSmallOrderedHashTableLoadFactor;
assert(
0 <= hashTableSize && hashTableSize <= kSmallOrderedHashTableMaxCapacity);
return new SmallOrderedHashMap{
map: kSmallOrderedHashMapMap,
number_of_elements: 0,
number_of_deleted_elements: 0,
number_of_buckets: (Convert<uint8>(hashTableSize)),
padding: ...ConstantIterator<uint8>(0),
data_table: ...ConstantIterator(HashMapEntry{key: TheHole, value: TheHole}),
hash_table: ...ConstantIterator<uint8>(kSmallOrderedHashTableNotFound),
chain_table: ...ConstantIterator<uint8>(kSmallOrderedHashTableNotFound)
};
}
struct NameDictionaryEntry {
key: JSAny|TheHole;
value: JSAny|TheHole;
property_details: Smi|TheHole;
}
extern class SmallOrderedNameDictionary extends SmallOrderedHashTable {
hash: int32;
@if(TAGGED_SIZE_8_BYTES) padding_0: int32;
@ifnot(TAGGED_SIZE_8_BYTES) padding_0: void;
number_of_elements: uint8;
number_of_deleted_elements: uint8;
const number_of_buckets: uint8;
@if(TAGGED_SIZE_8_BYTES) padding_1[5]: uint8;
@ifnot(TAGGED_SIZE_8_BYTES) padding_1[1]: uint8;
data_table[Convert<intptr>(number_of_buckets) * kSmallOrderedHashTableLoadFactor]:
NameDictionaryEntry;
hash_table[number_of_buckets]: uint8;
chain_table[number_of_buckets]: uint8;
}
|