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

Side by Side Diff: runtime/vm/object_id_ring.h

Issue 501583007: Treat null like the object it is in the Observatory and Service. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_OBJECT_ID_RING_H_ 5 #ifndef VM_OBJECT_ID_RING_H_
6 #define VM_OBJECT_ID_RING_H_ 6 #define VM_OBJECT_ID_RING_H_
7 7
8 namespace dart { 8 namespace dart {
9 9
10 // Forward declarations. 10 // Forward declarations.
11 class RawObject; 11 class RawObject;
12 class Isolate; 12 class Isolate;
13 class ObjectPointerVisitor; 13 class ObjectPointerVisitor;
14 14
15 // A ring buffer of object pointers that have been given an id. An object 15 // A ring buffer of object pointers that have been given an id. An object
16 // may be pointed to by multiple ids. Objects contained in the ring will 16 // may be pointed to by multiple ids. Objects contained in the ring will
17 // be preserved across scavenges but not old space collections. 17 // be preserved across scavenges but not old space collections.
18 // When the ring buffer wraps around older objects will be replaced and their 18 // When the ring buffer wraps around older objects will be replaced and their
19 // ids will be invalidated. 19 // ids will be invalidated.
20 class ObjectIdRing { 20 class ObjectIdRing {
21 public: 21 public:
22 enum LookupResult {
rmacnak 2014/08/26 21:36:50 Not thrilled about this name.
turnidge 2014/08/27 16:13:56 Sure. I'm having trouble coming up with an improv
rmacnak 2014/08/27 18:09:59 Added one-liners.
23 kValid = 0,
24 kInvalid,
25 kCollected,
26 kExpired,
27 };
28
22 static const int32_t kMaxId = 0x3FFFFFFF; 29 static const int32_t kMaxId = 0x3FFFFFFF;
23 static const int32_t kInvalidId = -1; 30 static const int32_t kInvalidId = -1;
24 static const int32_t kDefaultCapacity = 1024; 31 static const int32_t kDefaultCapacity = 1024;
25 32
26 static void Init(Isolate* isolate, int32_t capacity = kDefaultCapacity); 33 static void Init(Isolate* isolate, int32_t capacity = kDefaultCapacity);
27 34
28 ~ObjectIdRing(); 35 ~ObjectIdRing();
29 36
30 int32_t GetIdForObject(RawObject* raw_obj); 37 int32_t GetIdForObject(RawObject* raw_obj);
31 38
32 // Returns Object::sentinel() when the id is not valid. 39 // Returns Object::sentinel() when the id is not valid.
turnidge 2014/08/27 16:13:56 This comment is now out of date with the code... b
rmacnak 2014/08/27 18:09:59 Updated to say we return Object::null() when !kVal
33 RawObject* GetObjectForId(int32_t id); 40 RawObject* GetObjectForId(int32_t id, LookupResult* kind);
34 41
35 void VisitPointers(ObjectPointerVisitor* visitor); 42 void VisitPointers(ObjectPointerVisitor* visitor);
36 43
37 private: 44 private:
38 friend class ObjectIdRingTestHelper; 45 friend class ObjectIdRingTestHelper;
39 46
40 void SetCapacityAndMaxSerial(int32_t capacity, int32_t max_serial); 47 void SetCapacityAndMaxSerial(int32_t capacity, int32_t max_serial);
41 48
42 ObjectIdRing(Isolate* isolate, int32_t capacity); 49 ObjectIdRing(Isolate* isolate, int32_t capacity);
43 Isolate* isolate_; 50 Isolate* isolate_;
(...skipping 15 matching lines...) Expand all
59 int32_t IndexOfId(int32_t id); 66 int32_t IndexOfId(int32_t id);
60 bool IsValidContiguous(int32_t id); 67 bool IsValidContiguous(int32_t id);
61 bool IsValidId(int32_t id); 68 bool IsValidId(int32_t id);
62 69
63 DISALLOW_COPY_AND_ASSIGN(ObjectIdRing); 70 DISALLOW_COPY_AND_ASSIGN(ObjectIdRing);
64 }; 71 };
65 72
66 } // namespace dart 73 } // namespace dart
67 74
68 #endif // VM_OBJECT_ID_RING_H_ 75 #endif // VM_OBJECT_ID_RING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698