29 return is_ready_to_use_;
42 is_ready_to_use_ =
true;
46 while (old_tables_->length() > 0) {
47 free(old_tables_->RemoveLast());
61 bool grown_backing_store =
false;
62 if (top_ == capacity_) {
65 grown_backing_store =
true;
69 ASSERT(expected_field_id == -1 || expected_field_id == top_);
71 table_[top_] = Object::sentinel().ptr();
74 return grown_backing_store;
79 intptr_t reused_free = free_head_;
82 table_[reused_free] = Object::sentinel().ptr();
87 table_[field_id] =
Smi::New(free_head_);
88 free_head_ = field_id;
92 if (index >= capacity_) {
103void FieldTable::Grow(intptr_t new_capacity) {
104 ASSERT(new_capacity > capacity_);
106 auto old_table = table_;
107 auto new_table =
static_cast<ObjectPtr*
>(
110 for (
i = 0;
i < top_;
i++) {
111 new_table[
i] = old_table[
i];
113 for (;
i < new_capacity;
i++) {
114 new_table[
i] = ObjectPtr();
116 capacity_ = new_capacity;
117 old_tables_->Add(old_table);
120 reinterpret_cast<AcqRelAtomic<ObjectPtr*>*
>(&table_)->
store(new_table);
121 if (isolate_group_ !=
nullptr) {
123 [&](Isolate* isolate) {
124 if (isolate->mutator_thread() !=
nullptr) {
125 isolate->mutator_thread()->shared_field_table_values_ = table_;
129 }
else if (isolate_ !=
nullptr && isolate_->
mutator_thread() !=
nullptr) {
140 ASSERT(clone->table_ ==
nullptr);
141 if (table_ ==
nullptr) {
146 auto new_table =
static_cast<ObjectPtr*
>(
148 memmove(new_table, table_, capacity_ *
sizeof(
ObjectPtr));
149 clone->table_ = new_table;
150 clone->capacity_ = capacity_;
152 clone->free_head_ = free_head_;
159 if (table_ ==
nullptr) {
163 ASSERT(visitor !=
nullptr);
#define DEBUG_ASSERT(cond)
bool Register(const Field &field, intptr_t expected_field_id=-1)
void Free(intptr_t index)
void AllocateIndex(intptr_t index)
bool IsReadyToUse() const
static constexpr int kCapacityIncrement
static intptr_t FieldOffsetFor(intptr_t field_id)
FieldTable * Clone(Isolate *for_isolate, IsolateGroup *for_isolate_group=nullptr)
FieldTable(Isolate *isolate, IsolateGroup *isolate_group=nullptr)
void VisitObjectPointers(ObjectPointerVisitor *visitor)
void set_field_id(intptr_t field_id) const
void ForEachIsolate(std::function< void(Isolate *isolate)> function, bool at_safepoint=false)
static IsolateGroup * Current()
Thread * mutator_thread() const
void clear_gc_root_type()
void set_gc_root_type(const char *gc_root_type)
virtual void VisitPointers(ObjectPtr *first, ObjectPtr *last)=0
static ObjectPtr RawCast(ObjectPtr obj)
static SmiPtr New(intptr_t value)
void * malloc(size_t size)