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

Side by Side 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: add new header files 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 unified diff | Download patch | Annotate | Revision Log
« runtime/platform/utils.h ('K') | « runtime/vm/bit_set.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "vm/bit_set.h" 7 #include "vm/bit_set.h"
8 #include "vm/object.h" 8 #include "vm/object.h"
9 #include "vm/raw_object.h" 9 #include "vm/raw_object.h"
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // Nothing to release. 47 // Nothing to release.
48 } 48 }
49 49
50 50
51 uword FreeList::TryAllocate(intptr_t size) { 51 uword FreeList::TryAllocate(intptr_t size) {
52 int index = IndexForSize(size); 52 int index = IndexForSize(size);
53 if ((index != kNumLists) && free_map_.Test(index)) { 53 if ((index != kNumLists) && free_map_.Test(index)) {
54 return reinterpret_cast<uword>(DequeueElement(index)); 54 return reinterpret_cast<uword>(DequeueElement(index));
55 } 55 }
56 56
57 if (index < kNumLists) { 57 if ((index + 1) < kNumLists) {
58 index++; 58 intptr_t next_index = free_map_.Next(index + 1);
59 while (index < kNumLists) { 59 if (next_index == kNumLists) {
60 if (free_map_.Test(index)) { 60 next_index = -1;
61 // Dequeue an element from the list, split and enqueue the remainder in 61 }
siva 2012/07/24 01:07:43 per offline discussion this check could go away if
62 // the appropriate list. 62 if (next_index != -1) {
63 FreeListElement* element = DequeueElement(index); 63 // Dequeue an element from the list, split and enqueue the remainder in
64 SplitElementAfterAndEnqueue(element, size); 64 // the appropriate list.
65 return reinterpret_cast<uword>(element); 65 FreeListElement* element = DequeueElement(next_index);
66 } 66 SplitElementAfterAndEnqueue(element, size);
67 index++; 67 return reinterpret_cast<uword>(element);
68 } 68 }
69 } 69 }
70 70
71 FreeListElement* previous = NULL; 71 FreeListElement* previous = NULL;
72 FreeListElement* current = free_lists_[kNumLists]; 72 FreeListElement* current = free_lists_[kNumLists];
73 while (current != NULL) { 73 while (current != NULL) {
74 if (current->Size() >= size) { 74 if (current->Size() >= size) {
75 // Found an element large enough to hold the requested size. Dequeue, 75 // Found an element large enough to hold the requested size. Dequeue,
76 // split and enqueue the remainder. 76 // split and enqueue the remainder.
77 if (previous == NULL) { 77 if (previous == NULL) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 intptr_t remainder_size = element->Size() - size; 177 intptr_t remainder_size = element->Size() - size;
178 if (remainder_size == 0) return; 178 if (remainder_size == 0) return;
179 179
180 element = FreeListElement::AsElement(reinterpret_cast<uword>(element) + size, 180 element = FreeListElement::AsElement(reinterpret_cast<uword>(element) + size,
181 remainder_size); 181 remainder_size);
182 intptr_t remainder_index = IndexForSize(remainder_size); 182 intptr_t remainder_index = IndexForSize(remainder_size);
183 EnqueueElement(element, remainder_index); 183 EnqueueElement(element, remainder_index);
184 } 184 }
185 185
186 } // namespace dart 186 } // namespace dart
OLDNEW
« runtime/platform/utils.h ('K') | « runtime/vm/bit_set.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698