Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Unified Diff: runtime/vm/freelist.cc

Issue 10806078: Improve the performance of bit set searches with a compiler intrinsic. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/freelist.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/freelist.cc
diff --git a/runtime/vm/freelist.cc b/runtime/vm/freelist.cc
index 391dd22bcde0decd7b8f4f013a7e948e66aed057..c2ce1855f17652fc76305df5afdc5f8e8e94bab2 100644
--- a/runtime/vm/freelist.cc
+++ b/runtime/vm/freelist.cc
@@ -54,17 +54,14 @@ uword FreeList::TryAllocate(intptr_t size) {
return reinterpret_cast<uword>(DequeueElement(index));
}
- if (index < kNumLists) {
- index++;
- while (index < kNumLists) {
- if (free_map_.Test(index)) {
- // Dequeue an element from the list, split and enqueue the remainder in
- // the appropriate list.
- FreeListElement* element = DequeueElement(index);
- SplitElementAfterAndEnqueue(element, size);
- return reinterpret_cast<uword>(element);
- }
- index++;
+ if ((index + 1) < kNumLists) {
+ intptr_t next_index = free_map_.Next(index + 1);
+ if (next_index != -1) {
+ // Dequeue an element from the list, split and enqueue the remainder in
+ // the appropriate list.
+ FreeListElement* element = DequeueElement(next_index);
+ SplitElementAfterAndEnqueue(element, size);
+ return reinterpret_cast<uword>(element);
}
}
@@ -118,7 +115,7 @@ intptr_t FreeList::IndexForSize(intptr_t size) {
void FreeList::EnqueueElement(FreeListElement* element, intptr_t index) {
FreeListElement* next = free_lists_[index];
- if (next == NULL) {
+ if (next == NULL && index != kNumLists) {
free_map_.Set(index, true);
}
element->set_next(next);
@@ -129,7 +126,7 @@ void FreeList::EnqueueElement(FreeListElement* element, intptr_t index) {
FreeListElement* FreeList::DequeueElement(intptr_t index) {
FreeListElement* result = free_lists_[index];
FreeListElement* next = result->next();
- if (next == NULL) {
+ if (next == NULL && index != kNumLists) {
free_map_.Set(index, false);
}
free_lists_[index] = next;
« no previous file with comments | « runtime/vm/freelist.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698