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

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

Issue 177473004: Handle collected objects and expired handles more gracefully. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: gen js Created 6 years, 9 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/object_id_ring.h ('k') | runtime/vm/service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/dart_api_state.h" 6 #include "vm/dart_api_state.h"
7 #include "vm/object_id_ring.h" 7 #include "vm/object_id_ring.h"
8 8
9 namespace dart { 9 namespace dart {
10 10
(...skipping 15 matching lines...) Expand all
26 26
27 27
28 int32_t ObjectIdRing::GetIdForObject(RawObject* object) { 28 int32_t ObjectIdRing::GetIdForObject(RawObject* object) {
29 return AllocateNewId(object); 29 return AllocateNewId(object);
30 } 30 }
31 31
32 32
33 RawObject* ObjectIdRing::GetObjectForId(int32_t id) { 33 RawObject* ObjectIdRing::GetObjectForId(int32_t id) {
34 int32_t index = IndexOfId(id); 34 int32_t index = IndexOfId(id);
35 if (index == kInvalidId) { 35 if (index == kInvalidId) {
36 return Object::null(); 36 // Return sentinel to allow caller to distinguish expired ids.
37 return Object::sentinel().raw();
37 } 38 }
38 ASSERT(index >= 0); 39 ASSERT(index >= 0);
39 ASSERT(index < capacity_); 40 ASSERT(index < capacity_);
40 return table_[index]; 41 return table_[index];
41 } 42 }
42 43
43 44
44 void ObjectIdRing::VisitPointers(ObjectPointerVisitor* visitor) { 45 void ObjectIdRing::VisitPointers(ObjectPointerVisitor* visitor) {
45 ASSERT(table_ != NULL); 46 ASSERT(table_ != NULL);
46 visitor->VisitPointers(table_, capacity_); 47 visitor->VisitPointers(table_, capacity_);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 const int32_t max_serial_num = max_serial_; 159 const int32_t max_serial_num = max_serial_;
159 const int32_t bottom = max_serial_num - (capacity_ - serial_num_); 160 const int32_t bottom = max_serial_num - (capacity_ - serial_num_);
160 return id >= bottom && bottom < max_serial_num; 161 return id >= bottom && bottom < max_serial_num;
161 } 162 }
162 } 163 }
163 ASSERT(wrapped_ == false); 164 ASSERT(wrapped_ == false);
164 return IsValidContiguous(id); 165 return IsValidContiguous(id);
165 } 166 }
166 167
167 } // namespace dart 168 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object_id_ring.h ('k') | runtime/vm/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698