#include <field_table.h>
Definition at line 23 of file field_table.h.
◆ FieldTable()
Definition at line 25 of file field_table.h.
26 : top_(0),
27 capacity_(0),
28 free_head_(-1),
29 table_(nullptr),
30 old_tables_(new MallocGrowableArray<ObjectPtr*>()),
31 isolate_(isolate),
32 isolate_group_(isolate_group),
33 is_ready_to_use_(isolate == nullptr) {}
◆ ~FieldTable()
dart::FieldTable::~FieldTable |
( |
| ) |
|
Definition at line 19 of file field_table.cc.
19 {
21 delete old_tables_;
22 free(table_);
23}
◆ AllocateIndex()
void dart::FieldTable::AllocateIndex |
( |
intptr_t |
index | ) |
|
Definition at line 91 of file field_table.cc.
91 {
92 if (index >= capacity_) {
94 Grow(new_capacity);
95 }
96
97 ASSERT(table_[index] == ObjectPtr());
98 if (index >= top_) {
99 top_ = index + 1;
100 }
101}
static constexpr int kCapacityIncrement
◆ At()
ObjectPtr dart::FieldTable::At |
( |
intptr_t |
index, |
|
|
bool |
concurrent_use = false |
|
) |
| const |
|
inline |
Definition at line 62 of file field_table.h.
62 {
64 if (concurrent_use) {
66 reinterpret_cast<const AcqRelAtomic<ObjectPtr*>*
>(&table_)->
load();
67 return reinterpret_cast<AcqRelAtomic<ObjectPtr>*
>(&
table[index])->
load();
68 } else {
69
70
71
72 return table_[index];
73 }
74 }
bool IsValidIndex(intptr_t index) const
◆ Capacity()
intptr_t dart::FieldTable::Capacity |
( |
| ) |
const |
|
inline |
◆ Clone()
Definition at line 134 of file field_table.cc.
135 {
138
140 ASSERT(clone->table_ ==
nullptr);
141 if (table_ == nullptr) {
145 } else {
146 auto new_table = static_cast<ObjectPtr*>(
147 malloc(capacity_ *
sizeof(ObjectPtr)));
148 memmove(new_table, table_, capacity_ * sizeof(ObjectPtr));
149 clone->table_ = new_table;
150 clone->capacity_ = capacity_;
151 clone->top_ = top_;
152 clone->free_head_ = free_head_;
153 }
154 return clone;
155}
#define DEBUG_ASSERT(cond)
FieldTable(Isolate *isolate, IsolateGroup *isolate_group=nullptr)
static IsolateGroup * Current()
void * malloc(size_t size)
◆ FieldOffsetFor()
intptr_t dart::FieldTable::FieldOffsetFor |
( |
intptr_t |
field_id | ) |
|
|
static |
Definition at line 51 of file field_table.cc.
51 {
52 return field_id * sizeof(ObjectPtr);
53}
◆ Free()
void dart::FieldTable::Free |
( |
intptr_t |
index | ) |
|
Definition at line 86 of file field_table.cc.
86 {
87 table_[field_id] =
Smi::New(free_head_);
88 free_head_ = field_id;
89}
static SmiPtr New(intptr_t value)
◆ FreeOldTables()
void dart::FieldTable::FreeOldTables |
( |
| ) |
|
Definition at line 45 of file field_table.cc.
45 {
46 while (old_tables_->length() > 0) {
47 free(old_tables_->RemoveLast());
48 }
49}
◆ IsReadyToUse()
bool dart::FieldTable::IsReadyToUse |
( |
| ) |
const |
Definition at line 25 of file field_table.cc.
25 {
29 return is_ready_to_use_;
30}
◆ IsValidIndex()
bool dart::FieldTable::IsValidIndex |
( |
intptr_t |
index | ) |
const |
|
inline |
Definition at line 50 of file field_table.h.
50{ return index >= 0 && index < top_; }
◆ MarkReadyToUse()
void dart::FieldTable::MarkReadyToUse |
( |
| ) |
|
Definition at line 32 of file field_table.cc.
32 {
33
34
35
36
37
38
42 is_ready_to_use_ = true;
43}
◆ NumFieldIds()
intptr_t dart::FieldTable::NumFieldIds |
( |
| ) |
const |
|
inline |
◆ Register()
bool dart::FieldTable::Register |
( |
const Field & |
field, |
|
|
intptr_t |
expected_field_id = -1 |
|
) |
| |
Definition at line 55 of file field_table.cc.
55 {
59
60 if (free_head_ < 0) {
61 bool grown_backing_store = false;
62 if (top_ == capacity_) {
64 Grow(new_capacity);
65 grown_backing_store = true;
66 }
67
69 ASSERT(expected_field_id == -1 || expected_field_id == top_);
70 field.set_field_id(top_);
71 table_[top_] = Object::sentinel().ptr();
72
73 ++top_;
74 return grown_backing_store;
75 }
76
77
78
79 intptr_t reused_free = free_head_;
81 field.set_field_id(reused_free);
82 table_[reused_free] = Object::sentinel().ptr();
83 return false;
84}
static ObjectPtr RawCast(ObjectPtr obj)
◆ SetAt()
void dart::FieldTable::SetAt |
( |
intptr_t |
index, |
|
|
ObjectPtr |
raw_instance, |
|
|
bool |
concurrent_use = false |
|
) |
| |
|
inline |
Definition at line 76 of file field_table.h.
78 {
80 ObjectPtr* slot = &table_[index];
81 if (concurrent_use) {
82 reinterpret_cast<AcqRelAtomic<ObjectPtr>*
>(slot)->
store(raw_instance);
83 } else {
84
85
86
87 *slot = raw_instance;
88 }
89 }
◆ table()
◆ VisitObjectPointers()
Definition at line 157 of file field_table.cc.
157 {
158
159 if (table_ == nullptr) {
160 return;
161 }
162
163 ASSERT(visitor !=
nullptr);
164 visitor->set_gc_root_type("static fields table");
165 visitor->VisitPointers(&table_[0], &table_[top_ - 1]);
166 visitor->clear_gc_root_type();
167}
◆ kCapacityIncrement
constexpr int dart::FieldTable::kCapacityIncrement = 256 |
|
staticconstexpr |
◆ kInitialCapacity
constexpr int dart::FieldTable::kInitialCapacity = 512 |
|
staticconstexpr |
The documentation for this class was generated from the following files: