26 return AllocateNewId(
object);
29 int32_t
id = FindExistingIdForObject(
object);
34 return AllocateNewId(
object);
37int32_t ObjectIdRing::FindExistingIdForObject(
ObjectPtr raw_obj) {
38 for (int32_t
i = 0;
i < capacity_;
i++) {
39 if (table_[
i] == raw_obj) {
47 int32_t index = IndexOfId(
id);
59 ASSERT(IdOfIndex(index) ==
id);
78 for (int32_t
i = 0;
i < capacity_;
i++) {
96void ObjectIdRing::SetCapacityAndMaxSerial(int32_t capacity,
100 capacity_ = capacity;
101 if (table_ !=
nullptr) {
105 for (int32_t
i = 0;
i < capacity_;
i++) {
110 max_serial_ = max_serial - (max_serial % capacity_);
113int32_t ObjectIdRing::NextSerial() {
114 int32_t r = serial_num_;
116 if (serial_num_ >= max_serial_) {
123int32_t ObjectIdRing::AllocateNewId(ObjectPtr raw_obj) {
124 ASSERT(raw_obj->IsHeapObject());
125 int32_t
id = NextSerial();
127 int32_t index = IndexOfId(
id);
129 table_[index] = raw_obj;
133int32_t ObjectIdRing::IndexOfId(int32_t
id) {
134 if (!IsValidId(
id)) {
137 ASSERT((
id >= 0) && (
id < max_serial_));
138 return id % capacity_;
141int32_t ObjectIdRing::IdOfIndex(int32_t index) {
145 if (index >= capacity_) {
151 ASSERT(serial_num_ < capacity_);
152 if (index < serial_num_) {
158 const int32_t bottom = max_serial_ - capacity_;
161 }
else if (index < serial_num_) {
163 int32_t split_point = serial_num_ % capacity_;
164 if (index < split_point) {
167 int bottom = serial_num_ - split_point;
173 int bottom = serial_num_ - capacity_ - split_point;
178 ASSERT(!IsValidId(
id) || (IndexOfId(
id) == index));
182bool ObjectIdRing::IsValidContiguous(int32_t
id) {
184 ASSERT((
id >= 0) && (
id < max_serial_));
185 if (
id >= serial_num_) {
190 if (serial_num_ >= capacity_) {
191 bottom = serial_num_ - capacity_;
196bool ObjectIdRing::IsValidId(int32_t
id) {
203 if (
id >= max_serial_) {
206 ASSERT((
id >= 0) && (
id < max_serial_));
209 if (serial_num_ >= capacity_) {
213 return IsValidContiguous(
id);
221 if (
id < serial_num_) {
226 const int32_t max_serial_num = max_serial_;
227 const int32_t bottom = max_serial_num - (capacity_ - serial_num_);
228 return id >= bottom && bottom < max_serial_num;
231 ASSERT(wrapped_ ==
false);
232 return IsValidContiguous(
id);
void AddValue(bool b) const
void AddProperty(const char *name, bool b) const
static constexpr int32_t kDefaultCapacity
static constexpr int32_t kInvalidId
ObjectPtr GetObjectForId(int32_t id, LookupResult *kind)
static constexpr int32_t kMaxId
void VisitPointers(ObjectPointerVisitor *visitor)
int32_t GetIdForObject(ObjectPtr raw_obj, IdPolicy policy=kAllocateId)
void PrintJSON(JSONStream *js)
virtual void VisitPointers(ObjectPtr *first, ObjectPtr *last)=0
static Thread * Current()
void * calloc(size_t n, size_t size)
constexpr intptr_t kWordSize
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network policy