| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 bottom = serial_num_ - capacity_; | 122 bottom = serial_num_ - capacity_; |
| 123 } | 123 } |
| 124 return id >= bottom; | 124 return id >= bottom; |
| 125 } | 125 } |
| 126 | 126 |
| 127 | 127 |
| 128 bool ObjectIdRing::IsValidId(int32_t id) { | 128 bool ObjectIdRing::IsValidId(int32_t id) { |
| 129 if (id == kInvalidId) { | 129 if (id == kInvalidId) { |
| 130 return false; | 130 return false; |
| 131 } | 131 } |
| 132 if (id < 0) { |
| 133 return false; |
| 134 } |
| 132 if (id >= max_serial_) { | 135 if (id >= max_serial_) { |
| 133 return false; | 136 return false; |
| 134 } | 137 } |
| 135 ASSERT((id >= 0) && (id < max_serial_)); | 138 ASSERT((id >= 0) && (id < max_serial_)); |
| 136 if (wrapped_) { | 139 if (wrapped_) { |
| 137 // Serial number has wrapped around to 0. | 140 // Serial number has wrapped around to 0. |
| 138 if (serial_num_ >= capacity_) { | 141 if (serial_num_ >= capacity_) { |
| 139 // Serial number is larger than capacity, the serial | 142 // Serial number is larger than capacity, the serial |
| 140 // numbers are contiguous again. | 143 // numbers are contiguous again. |
| 141 wrapped_ = false; | 144 wrapped_ = false; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 155 const int32_t max_serial_num = max_serial_; | 158 const int32_t max_serial_num = max_serial_; |
| 156 const int32_t bottom = max_serial_num - (capacity_ - serial_num_); | 159 const int32_t bottom = max_serial_num - (capacity_ - serial_num_); |
| 157 return id >= bottom && bottom < max_serial_num; | 160 return id >= bottom && bottom < max_serial_num; |
| 158 } | 161 } |
| 159 } | 162 } |
| 160 ASSERT(wrapped_ == false); | 163 ASSERT(wrapped_ == false); |
| 161 return IsValidContiguous(id); | 164 return IsValidContiguous(id); |
| 162 } | 165 } |
| 163 | 166 |
| 164 } // namespace dart | 167 } // namespace dart |
| OLD | NEW |