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

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

Issue 18259014: Object ID Ring with tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/object_id_ring.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #ifndef VM_OBJECT_ID_RING_H_
6 #define VM_OBJECT_ID_RING_H_
7
8 namespace dart {
9
10 // Forward declarations.
11 class RawObject;
12 class Isolate;
13 class ObjectPointerVisitor;
14
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
17 // be preserved across scavenges but not old space collections.
18 // When the ring buffer wraps around older objects will be replaced and their
19 // ids will be invalidated.
20 class ObjectIdRing {
21 public:
22 static const int32_t kMaxId = 0x3FFFFFFF;
23 static const int32_t kInvalidId = -1;
24 static const int32_t kDefaultCapacity = 1024;
25
26 static void Init(Isolate* isolate, int32_t capacity = kDefaultCapacity);
27
28 ~ObjectIdRing();
29
30 int32_t GetIdForObject(RawObject* raw_obj);
31 RawObject* GetObjectForId(int32_t id);
32
33 void VisitPointers(ObjectPointerVisitor* visitor);
34
35 private:
36 friend class ObjectIdRingTestHelper;
37
38 void SetCapacityAndMaxSerial(int32_t capacity, int32_t max_serial);
39
40 ObjectIdRing(Isolate* isolate, int32_t capacity);
41 Isolate* isolate_;
42 RawObject** table_;
43 int32_t max_serial_;
44 int32_t capacity_;
45 int32_t serial_num_;
46 bool wrapped_;
47
48 RawObject** table() {
49 return table_;
50 }
51 int32_t table_size() {
52 return capacity_;
53 }
54
55 int32_t NextSerial();
56 int32_t AllocateNewId(RawObject* object);
57 int32_t IndexOfId(int32_t id);
58 bool IsValidContiguous(int32_t id);
59 bool IsValidId(int32_t id);
60
61 DISALLOW_COPY_AND_ASSIGN(ObjectIdRing);
62 };
63
64 } // namespace dart
65
66 #endif // VM_OBJECT_ID_RING_H_
OLDNEW
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/object_id_ring.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698