| 191 | } |
| 192 | |
| 193 | void ThreadCache::ListTooLong(FreeList* list, size_t cl) { |
| 194 | const int batch_size = Static::sizemap()->num_objects_to_move(cl); |
| 195 | ReleaseToCentralCache(list, cl, batch_size); |
| 196 | |
| 197 | // If the list is too long, we need to transfer some number of |
| 198 | // objects to the central cache. Ideally, we would transfer |
| 199 | // num_objects_to_move, so the code below tries to make max_length |
| 200 | // converge on num_objects_to_move. |
| 201 | |
| 202 | if (list->max_length() < batch_size) { |
| 203 | // Slow start the max_length so we don't overreserve. |
| 204 | list->set_max_length(list->max_length() + 1); |
| 205 | } else if (list->max_length() > batch_size) { |
| 206 | // If we consistently go over max_length, shrink max_length. If we don't |
| 207 | // shrink it, some amount of memory will always stay in this freelist. |
| 208 | list->set_length_overages(list->length_overages() + 1); |
| 209 | if (list->length_overages() > kMaxOverages) { |
| 210 | ASSERT(list->max_length() > batch_size); |
| 211 | list->set_max_length(list->max_length() - batch_size); |
| 212 | list->set_length_overages(0); |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | // Remove some objects of class "cl" from thread heap and add to central cache |
| 218 | void ThreadCache::ReleaseToCentralCache(FreeList* src, size_t cl, int N) { |
nothing calls this directly
no test coverage detected