OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #ifndef RUNTIME_VM_FREELIST_H_ | 5 #ifndef RUNTIME_VM_FREELIST_H_ |
6 #define RUNTIME_VM_FREELIST_H_ | 6 #define RUNTIME_VM_FREELIST_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
10 #include "vm/bit_set.h" | 10 #include "vm/bit_set.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // Returns a large element, at least 'minimum_size', or NULL if none exists. | 91 // Returns a large element, at least 'minimum_size', or NULL if none exists. |
92 FreeListElement* TryAllocateLarge(intptr_t minimum_size); | 92 FreeListElement* TryAllocateLarge(intptr_t minimum_size); |
93 FreeListElement* TryAllocateLargeLocked(intptr_t minimum_size); | 93 FreeListElement* TryAllocateLargeLocked(intptr_t minimum_size); |
94 | 94 |
95 // Allocates locked and unprotected memory, but only from small elements | 95 // Allocates locked and unprotected memory, but only from small elements |
96 // (i.e., fixed size lists). | 96 // (i.e., fixed size lists). |
97 uword TryAllocateSmallLocked(intptr_t size); | 97 uword TryAllocateSmallLocked(intptr_t size); |
98 | 98 |
99 private: | 99 private: |
100 static const int kNumLists = 128; | 100 static const int kNumLists = 128; |
| 101 static const intptr_t kInitialFreeListSearchBudget = 1000; |
101 | 102 |
102 static intptr_t IndexForSize(intptr_t size); | 103 static intptr_t IndexForSize(intptr_t size); |
103 | 104 |
104 intptr_t LengthLocked(int index) const; | 105 intptr_t LengthLocked(int index) const; |
105 | 106 |
106 void EnqueueElement(FreeListElement* element, intptr_t index); | 107 void EnqueueElement(FreeListElement* element, intptr_t index); |
107 FreeListElement* DequeueElement(intptr_t index); | 108 FreeListElement* DequeueElement(intptr_t index); |
108 | 109 |
109 void SplitElementAfterAndEnqueue(FreeListElement* element, | 110 void SplitElementAfterAndEnqueue(FreeListElement* element, |
110 intptr_t size, | 111 intptr_t size, |
111 bool is_protected); | 112 bool is_protected); |
112 | 113 |
113 void PrintSmall() const; | 114 void PrintSmall() const; |
114 void PrintLarge() const; | 115 void PrintLarge() const; |
115 | 116 |
116 // Lock protecting the free list data structures. | 117 // Lock protecting the free list data structures. |
117 Mutex* mutex_; | 118 Mutex* mutex_; |
118 | 119 |
119 BitSet<kNumLists> free_map_; | 120 BitSet<kNumLists> free_map_; |
120 | 121 |
121 FreeListElement* free_lists_[kNumLists + 1]; | 122 FreeListElement* free_lists_[kNumLists + 1]; |
122 | 123 |
| 124 intptr_t freelist_search_budget_; |
| 125 |
123 // The largest available small size in bytes, or negative if there is none. | 126 // The largest available small size in bytes, or negative if there is none. |
124 intptr_t last_free_small_size_; | 127 intptr_t last_free_small_size_; |
125 | 128 |
126 DISALLOW_COPY_AND_ASSIGN(FreeList); | 129 DISALLOW_COPY_AND_ASSIGN(FreeList); |
127 }; | 130 }; |
128 | 131 |
129 } // namespace dart | 132 } // namespace dart |
130 | 133 |
131 #endif // RUNTIME_VM_FREELIST_H_ | 134 #endif // RUNTIME_VM_FREELIST_H_ |
OLD | NEW |