Chromium Code Reviews| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 serial_num_++; | 79 serial_num_++; |
| 80 if (serial_num_ >= max_serial_) { | 80 if (serial_num_ >= max_serial_) { |
| 81 serial_num_ = 0; | 81 serial_num_ = 0; |
| 82 wrapped_ = true; | 82 wrapped_ = true; |
| 83 } | 83 } |
| 84 return r; | 84 return r; |
| 85 } | 85 } |
| 86 | 86 |
| 87 | 87 |
| 88 int32_t ObjectIdRing::AllocateNewId(RawObject* raw_obj) { | 88 int32_t ObjectIdRing::AllocateNewId(RawObject* raw_obj) { |
| 89 ASSERT(raw_obj->IsHeapObject()); | 89 // TODO(turnidge): Do not enter Smis into the ObjectIdRing. |
|
Ivan Posva
2013/11/22 22:58:36
I would actually leave the ASSERT in the code, jus
| |
| 90 int32_t id = NextSerial(); | 90 int32_t id = NextSerial(); |
| 91 ASSERT(id != kInvalidId); | 91 ASSERT(id != kInvalidId); |
| 92 int32_t cursor = IndexOfId(id); | 92 int32_t cursor = IndexOfId(id); |
| 93 ASSERT(cursor != kInvalidId); | 93 ASSERT(cursor != kInvalidId); |
| 94 if (table_[cursor] != Object::null()) { | 94 if (table_[cursor] != Object::null()) { |
| 95 // Free old handle. | 95 // Free old handle. |
| 96 table_[cursor] = Object::null(); | 96 table_[cursor] = Object::null(); |
| 97 } | 97 } |
| 98 ASSERT(table_[cursor] == Object::null()); | 98 ASSERT(table_[cursor] == Object::null()); |
| 99 table_[cursor] = raw_obj; | 99 table_[cursor] = raw_obj; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 const int32_t max_serial_num = max_serial_; | 158 const int32_t max_serial_num = max_serial_; |
| 159 const int32_t bottom = max_serial_num - (capacity_ - serial_num_); | 159 const int32_t bottom = max_serial_num - (capacity_ - serial_num_); |
| 160 return id >= bottom && bottom < max_serial_num; | 160 return id >= bottom && bottom < max_serial_num; |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 ASSERT(wrapped_ == false); | 163 ASSERT(wrapped_ == false); |
| 164 return IsValidContiguous(id); | 164 return IsValidContiguous(id); |
| 165 } | 165 } |
| 166 | 166 |
| 167 } // namespace dart | 167 } // namespace dart |
| OLD | NEW |