OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/freelist.h" | 5 #include "vm/freelist.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "vm/bit_set.h" | 9 #include "vm/bit_set.h" |
10 #include "vm/lockers.h" | 10 #include "vm/lockers.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 } | 224 } |
225 element->set_next(next); | 225 element->set_next(next); |
226 free_lists_[index] = element; | 226 free_lists_[index] = element; |
227 } | 227 } |
228 | 228 |
229 | 229 |
230 FreeListElement* FreeList::DequeueElement(intptr_t index) { | 230 FreeListElement* FreeList::DequeueElement(intptr_t index) { |
231 FreeListElement* result = free_lists_[index]; | 231 FreeListElement* result = free_lists_[index]; |
232 FreeListElement* next = result->next(); | 232 FreeListElement* next = result->next(); |
233 if (next == NULL && index != kNumLists) { | 233 if (next == NULL && index != kNumLists) { |
234 free_map_.Set(index, false); | |
235 intptr_t size = index << kObjectAlignmentLog2; | 234 intptr_t size = index << kObjectAlignmentLog2; |
236 if (size == last_free_small_size_) { | 235 if (size == last_free_small_size_) { |
237 // Note: Last() returns -1 if none are set; avoid shift of negative. | 236 // Note: This is -1 * kObjectAlignment if no other small sizes remain. |
238 last_free_small_size_ = free_map_.Last() * kObjectAlignment; | 237 last_free_small_size_ = |
239 // TODO(koda): Consider adding BitSet::Previous(i). | 238 free_map_.ClearLastAndFindPrevious(index) * kObjectAlignment; |
| 239 } else { |
| 240 free_map_.Set(index, false); |
240 } | 241 } |
241 } | 242 } |
242 free_lists_[index] = next; | 243 free_lists_[index] = next; |
243 return result; | 244 return result; |
244 } | 245 } |
245 | 246 |
246 | 247 |
247 intptr_t FreeList::LengthLocked(int index) const { | 248 intptr_t FreeList::LengthLocked(int index) const { |
248 DEBUG_ASSERT(mutex_->Owner() == Isolate::Current()); | 249 DEBUG_ASSERT(mutex_->Owner() == Isolate::Current()); |
249 ASSERT(index >= 0); | 250 ASSERT(index >= 0); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 if (next_index != -1) { | 394 if (next_index != -1) { |
394 FreeListElement* element = DequeueElement(next_index); | 395 FreeListElement* element = DequeueElement(next_index); |
395 SplitElementAfterAndEnqueue(element, size, false); | 396 SplitElementAfterAndEnqueue(element, size, false); |
396 return reinterpret_cast<uword>(element); | 397 return reinterpret_cast<uword>(element); |
397 } | 398 } |
398 } | 399 } |
399 return 0; | 400 return 0; |
400 } | 401 } |
401 | 402 |
402 } // namespace dart | 403 } // namespace dart |
OLD | NEW |