Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Unified Diff: runtime/vm/object_id_ring.h

Issue 1132323002: Add Service ID zones to service protocol (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/object_id_ring.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a936a8f0523e16132a89d391b604a252cf62d148 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 {
+ kAllocateId, // Always allocate a new object id.
+ kReuseId, // If the object is already in the ring, reuse id.
+ // 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,17 +44,20 @@ 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 = kAllocateId);
// Returns Object::null() when the result is not kValid.
RawObject* GetObjectForId(int32_t id, LookupResult* kind);
void VisitPointers(ObjectPointerVisitor* visitor);
+ void PrintJSON(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_;
@@ -66,6 +77,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);
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/object_id_ring.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698