Chromium Code Reviews| Index: runtime/vm/freelist.cc |
| =================================================================== |
| --- runtime/vm/freelist.cc (revision 39651) |
| +++ runtime/vm/freelist.cc (working copy) |
| @@ -235,8 +235,7 @@ |
| } |
| -intptr_t FreeList::Length(int index) const { |
| - MutexLocker ml(mutex_); |
| +intptr_t FreeList::LengthLocked(int index) const { |
| ASSERT(index >= 0); |
|
Ivan Posva
2014/08/29 00:07:12
Please add
DEBUG_ASSERT(mutex_->Owner() == Isolate
koda
2014/08/29 00:52:20
Done.
|
| ASSERT(index < kNumLists); |
| intptr_t result = 0; |
| @@ -258,7 +257,7 @@ |
| continue; |
| } |
| small_sizes += 1; |
| - intptr_t list_length = Length(i); |
| + intptr_t list_length = LengthLocked(i); |
| small_objects += list_length; |
| intptr_t list_bytes = list_length * i * kObjectAlignment; |
| small_bytes += list_bytes; |
| @@ -341,4 +340,26 @@ |
| } |
| } |
| + |
| +FreeListElement* FreeList::TryAllocateLarge(intptr_t minimum_size) { |
| + MutexLocker ml(mutex_); |
| + FreeListElement* previous = NULL; |
| + FreeListElement* current = free_lists_[kNumLists]; |
| + // TODO(koda): Find largest. |
| + while (current != NULL) { |
| + FreeListElement* next = current->next(); |
| + if (current->Size() >= minimum_size) { |
| + if (previous == NULL) { |
| + free_lists_[kNumLists] = next; |
| + } else { |
| + previous->set_next(next); |
| + } |
| + return current; |
| + } |
| + previous = current; |
| + current = next; |
| + } |
| + return NULL; |
| +} |
| + |
| } // namespace dart |