Chromium Code Reviews| Index: runtime/vm/object_id_ring.h |
| diff --git a/runtime/vm/object_id_ring.h b/runtime/vm/object_id_ring.h |
| index a7acb76c18728a430c77b296d9066f70a4a117cf..1c2c3229e745adeeca0f5921dbb70a003ab51d00 100644 |
| --- a/runtime/vm/object_id_ring.h |
| +++ b/runtime/vm/object_id_ring.h |
| @@ -11,6 +11,7 @@ namespace dart { |
| class RawObject; |
| class Isolate; |
| class ObjectPointerVisitor; |
| +class JSONStream; |
| // A ring buffer of object pointers that have been given an id. An object |
| // may be pointed to by multiple ids. Objects contained in the ring will |
| @@ -26,6 +27,13 @@ class ObjectIdRing { |
| kExpired, // Entry was evicted during an insertion into a full ring. |
| }; |
| + enum IdPolicy { |
| + kNewId, // Always allocate a new object id. |
|
turnidge
2015/05/11 19:48:45
kAllocateId?
Cutch
2015/05/12 14:59:57
Done.
|
| + kExistingOrNewId, // If the object is already in the ring, reuse id. |
|
turnidge
2015/05/11 19:48:45
kReuseId?
Cutch
2015/05/12 14:59:57
Done.
|
| + // Otherwise allocate a new object id. |
| + kNumIdPolicy, |
| + }; |
| + |
| static const int32_t kMaxId = 0x3FFFFFFF; |
| static const int32_t kInvalidId = -1; |
| static const int32_t kDefaultCapacity = 1024; |
| @@ -36,21 +44,25 @@ class ObjectIdRing { |
| // Adds the argument to the ring and returns its id. Note we do not allow |
| // adding Object::null(). |
| - int32_t GetIdForObject(RawObject* raw_obj); |
| + int32_t GetIdForObject(RawObject* raw_obj, IdPolicy policy = kNewId); |
| // Returns Object::null() when the result is not kValid. |
| RawObject* GetObjectForId(int32_t id, LookupResult* kind); |
| void VisitPointers(ObjectPointerVisitor* visitor); |
| + void PrintGetObjectRequestsToJSON(JSONStream* js); |
| + |
| private: |
| friend class ObjectIdRingTestHelper; |
| void SetCapacityAndMaxSerial(int32_t capacity, int32_t max_serial); |
| + int32_t FindExistingIdForObject(RawObject* raw_obj); |
| ObjectIdRing(Isolate* isolate, int32_t capacity); |
| Isolate* isolate_; |
| RawObject** table_; |
| + int32_t* ids_; |
|
turnidge
2015/05/11 19:48:45
I think we may be able to drop the ids_ array. Le
|
| int32_t max_serial_; |
| int32_t capacity_; |
| int32_t serial_num_; |
| @@ -66,6 +78,7 @@ class ObjectIdRing { |
| int32_t NextSerial(); |
| int32_t AllocateNewId(RawObject* object); |
| int32_t IndexOfId(int32_t id); |
| + int32_t IdOfIndex(int32_t index); |
| bool IsValidContiguous(int32_t id); |
| bool IsValidId(int32_t id); |