| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |