#include <weak_table.h>
Definition at line 16 of file weak_table.h.
◆ WeakTable() [1/2]
dart::WeakTable::WeakTable |
( |
| ) |
|
|
inline |
◆ WeakTable() [2/2]
dart::WeakTable::WeakTable |
( |
intptr_t |
size | ) |
|
|
inlineexplicit |
Definition at line 21 of file weak_table.h.
21 : used_(0), count_(0) {
24 if (
size < kMinSize) {
26 }
27
28 const intptr_t kMaxSize =
31 if (
size > kMaxSize) {
33 }
36 data_ =
reinterpret_cast<intptr_t*
>(
malloc(size_ * kEntrySize *
kWordSize));
37 for (intptr_t
i = 0;
i < size_;
i++) {
38 data_[ObjectIndex(
i)] = kNoEntry;
40 }
41 }
static constexpr bool IsPowerOfTwo(T x)
static constexpr intptr_t kNoValue
constexpr intptr_t kBitsPerWord
void * malloc(size_t size)
constexpr intptr_t kIntptrOne
constexpr intptr_t kWordSize
◆ ~WeakTable()
dart::WeakTable::~WeakTable |
( |
| ) |
|
|
inline |
◆ CleanupValues()
Definition at line 156 of file weak_table.cc.
156 {
157 for (intptr_t
i = 0;
i < size_;
i++) {
159 cleanup(
reinterpret_cast<void*
>(data_[ValueIndex(
i)]));
160 }
161 }
162}
bool IsValidEntryAtExclusive(intptr_t i) const
◆ count()
intptr_t dart::WeakTable::count |
( |
| ) |
const |
|
inline |
◆ Forward()
Definition at line 131 of file weak_table.cc.
131 {
132 if (used_ == 0) return;
133
134 for (intptr_t
i = 0;
i < size_;
i++) {
136 visitor->VisitPointer(ObjectPointerAt(
i));
137 }
138 }
139
140 Rehash();
141}
◆ GetValue()
intptr_t dart::WeakTable::GetValue |
( |
ObjectPtr |
key | ) |
|
|
inline |
Definition at line 55 of file weak_table.h.
55 {
56 MutexLocker ml(&mutex_);
58 }
intptr_t GetValueExclusive(ObjectPtr key) const
◆ GetValueExclusive()
intptr_t dart::WeakTable::GetValueExclusive |
( |
ObjectPtr |
key | ) |
const |
|
inline |
Definition at line 109 of file weak_table.h.
109 {
110 intptr_t mask =
size() - 1;
111 intptr_t idx = Hash(
key) & mask;
113 while (obj != static_cast<ObjectPtr>(kNoEntry)) {
116 }
117 idx = (idx + 1) & mask;
119 }
122 }
intptr_t ValueAtExclusive(intptr_t i) const
ObjectPtr ObjectAtExclusive(intptr_t i) const
◆ InvalidateAtExclusive()
void dart::WeakTable::InvalidateAtExclusive |
( |
intptr_t |
i | ) |
|
|
inline |
◆ IsValidEntryAtExclusive()
bool dart::WeakTable::IsValidEntryAtExclusive |
( |
intptr_t |
i | ) |
const |
|
inline |
Definition at line 80 of file weak_table.h.
80 {
82 (data_[ObjectIndex(
i)] == kNoEntry ||
83 data_[ObjectIndex(
i)] == kDeletedEntry)) ||
85 data_[ObjectIndex(
i)] != kDeletedEntry));
86 return (data_[ValueIndex(
i)] != 0);
87 }
◆ MarkValueExclusive()
bool dart::WeakTable::MarkValueExclusive |
( |
ObjectPtr |
key, |
|
|
intptr_t |
val |
|
) |
| |
Definition at line 78 of file weak_table.cc.
78 {
79 const intptr_t mask =
size() - 1;
80 intptr_t idx = Hash(
key) & mask;
81 intptr_t empty_idx = -1;
83
84 while (obj != static_cast<ObjectPtr>(kNoEntry)) {
86 return false;
87 } else if ((empty_idx < 0) &&
88 (static_cast<intptr_t>(obj) == kDeletedEntry)) {
89 empty_idx = idx;
90 }
91 idx = (idx + 1) & mask;
93 }
94
96
97 if (empty_idx >= 0) {
98
100 idx = empty_idx;
101 }
102
104
105 SetObjectAt(idx,
key);
106 SetValueAt(idx, val);
107
108 set_used(
used() + 1);
109 set_count(
count() + 1);
110
111
112 if (used_ >= limit()) {
113 Rehash();
114 }
115 return true;
116}
◆ NewFrom()
Definition at line 45 of file weak_table.h.
45 {
46 return new WeakTable(SizeFor(original->count(), original->size()));
47 }
◆ ObjectAtExclusive()
ObjectPtr dart::WeakTable::ObjectAtExclusive |
( |
intptr_t |
i | ) |
const |
|
inline |
Definition at line 94 of file weak_table.h.
94 {
97 return static_cast<ObjectPtr
>(data_[ObjectIndex(
i)]);
98 }
◆ RemoveValueExclusive()
intptr_t dart::WeakTable::RemoveValueExclusive |
( |
ObjectPtr |
key | ) |
|
|
inline |
Definition at line 126 of file weak_table.h.
126 {
127 intptr_t mask =
size() - 1;
128 intptr_t idx = Hash(
key) & mask;
130 while (obj != static_cast<ObjectPtr>(kNoEntry)) {
135 }
136 idx = (idx + 1) & mask;
138 }
141 }
void InvalidateAtExclusive(intptr_t i)
◆ ReportSurvivingAllocations()
Definition at line 144 of file weak_table.cc.
146 {
147 MutexLocker ml(&mutex_);
148 for (intptr_t
i = 0;
i < size_;
i++) {
150 void*
data =
reinterpret_cast<void*
>(data_[ValueIndex(
i)]);
152 }
153 }
154}
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
static int8_t data[kExtLength]
◆ Reset()
void dart::WeakTable::Reset |
( |
| ) |
|
Definition at line 118 of file weak_table.cc.
118 {
119 intptr_t* old_data = data_;
120 used_ = 0;
121 count_ = 0;
122 size_ = kMinSize;
123 free(old_data);
124 data_ =
reinterpret_cast<intptr_t*
>(
malloc(size_ * kEntrySize *
kWordSize));
125 for (intptr_t
i = 0;
i < size_;
i++) {
126 data_[ObjectIndex(
i)] = kNoEntry;
128 }
129}
◆ SetValue()
void dart::WeakTable::SetValue |
( |
ObjectPtr |
key, |
|
|
intptr_t |
val |
|
) |
| |
|
inline |
Definition at line 60 of file weak_table.h.
60 {
61 MutexLocker ml(&mutex_);
63 }
void SetValueExclusive(ObjectPtr key, intptr_t val)
◆ SetValueExclusive()
void dart::WeakTable::SetValueExclusive |
( |
ObjectPtr |
key, |
|
|
intptr_t |
val |
|
) |
| |
Definition at line 33 of file weak_table.cc.
33 {
34 const intptr_t mask =
size() - 1;
35 intptr_t idx = Hash(
key) & mask;
36 intptr_t empty_idx = -1;
38
39 while (obj != static_cast<ObjectPtr>(kNoEntry)) {
41 SetValueAt(idx, val);
42 return;
43 } else if ((empty_idx < 0) &&
44 (static_cast<intptr_t>(obj) == kDeletedEntry)) {
45 empty_idx = idx;
46 }
47 idx = (idx + 1) & mask;
49 }
50
51 if (val == 0) {
52
53
54
55 return;
56 }
57
58 if (empty_idx >= 0) {
59
61 idx = empty_idx;
62 }
63
65
66 SetObjectAt(idx,
key);
67 SetValueAt(idx, val);
68
70 set_count(
count() + 1);
71
72
73 if (used_ >= limit()) {
74 Rehash();
75 }
76}
◆ SetValueIfNonExistent()
intptr_t dart::WeakTable::SetValueIfNonExistent |
( |
ObjectPtr |
key, |
|
|
intptr_t |
val |
|
) |
| |
|
inline |
Definition at line 65 of file weak_table.h.
65 {
66 MutexLocker ml(&mutex_);
70 return val;
71 }
72 return old_value;
73 }
◆ size()
intptr_t dart::WeakTable::size |
( |
| ) |
const |
|
inline |
◆ used()
intptr_t dart::WeakTable::used |
( |
| ) |
const |
|
inline |
◆ ValueAtExclusive()
intptr_t dart::WeakTable::ValueAtExclusive |
( |
intptr_t |
i | ) |
const |
|
inline |
Definition at line 100 of file weak_table.h.
100 {
103 return data_[ValueIndex(
i)];
104 }
◆ kNoValue
constexpr intptr_t dart::WeakTable::kNoValue = 0 |
|
staticconstexpr |
The documentation for this class was generated from the following files: