OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/heap/spaces.h" | 5 #include "src/heap/spaces.h" |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
9 #include "src/full-codegen/full-codegen.h" | 9 #include "src/full-codegen/full-codegen.h" |
10 #include "src/heap/slots-buffer.h" | 10 #include "src/heap/slots-buffer.h" |
(...skipping 2244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2255 // are never performed on the same free lists at the same time in | 2255 // are never performed on the same free lists at the same time in |
2256 // reverse order. Furthermore, we only lock if the PagedSpace containing | 2256 // reverse order. Furthermore, we only lock if the PagedSpace containing |
2257 // the free list is know to be globally available, i.e., not local. | 2257 // the free list is know to be globally available, i.e., not local. |
2258 if (!owner()->is_local()) mutex_.Lock(); | 2258 if (!owner()->is_local()) mutex_.Lock(); |
2259 if (!other->owner()->is_local()) other->mutex()->Lock(); | 2259 if (!other->owner()->is_local()) other->mutex()->Lock(); |
2260 | 2260 |
2261 wasted_bytes = other->wasted_bytes_; | 2261 wasted_bytes = other->wasted_bytes_; |
2262 wasted_bytes_ += wasted_bytes; | 2262 wasted_bytes_ += wasted_bytes; |
2263 other->wasted_bytes_ = 0; | 2263 other->wasted_bytes_ = 0; |
2264 | 2264 |
2265 usable_bytes += small_list_.Concatenate(other->small_list()); | 2265 usable_bytes += small_list_.Concatenate(other->GetFreeListCategory(kSmall)); |
2266 usable_bytes += medium_list_.Concatenate(other->medium_list()); | 2266 usable_bytes += medium_list_.Concatenate(other->GetFreeListCategory(kMedium)); |
2267 usable_bytes += large_list_.Concatenate(other->large_list()); | 2267 usable_bytes += large_list_.Concatenate(other->GetFreeListCategory(kLarge)); |
2268 usable_bytes += huge_list_.Concatenate(other->huge_list()); | 2268 usable_bytes += huge_list_.Concatenate(other->GetFreeListCategory(kHuge)); |
2269 | 2269 |
2270 if (!other->owner()->is_local()) other->mutex()->Unlock(); | 2270 if (!other->owner()->is_local()) other->mutex()->Unlock(); |
2271 if (!owner()->is_local()) mutex_.Unlock(); | 2271 if (!owner()->is_local()) mutex_.Unlock(); |
2272 return usable_bytes + wasted_bytes; | 2272 return usable_bytes + wasted_bytes; |
2273 } | 2273 } |
2274 | 2274 |
2275 | 2275 |
2276 void FreeList::Reset() { | 2276 void FreeList::Reset() { |
2277 small_list_.Reset(); | 2277 small_list_.Reset(); |
2278 medium_list_.Reset(); | 2278 medium_list_.Reset(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2311 } else { | 2311 } else { |
2312 huge_list_.Free(free_space, size_in_bytes); | 2312 huge_list_.Free(free_space, size_in_bytes); |
2313 page->add_available_in_huge_free_list(size_in_bytes); | 2313 page->add_available_in_huge_free_list(size_in_bytes); |
2314 } | 2314 } |
2315 | 2315 |
2316 DCHECK(IsVeryLong() || available() == SumFreeLists()); | 2316 DCHECK(IsVeryLong() || available() == SumFreeLists()); |
2317 return 0; | 2317 return 0; |
2318 } | 2318 } |
2319 | 2319 |
2320 | 2320 |
2321 FreeSpace* FreeList::FindNodeIn(FreeListCategoryType category, int* node_size) { | |
Michael Lippautz
2015/10/08 14:45:01
FYI: This one will be used in a follow-up CL for f
| |
2322 FreeSpace* node = GetFreeListCategory(category)->PickNodeFromList(node_size); | |
2323 if (node != nullptr) { | |
2324 Page::FromAddress(node->address()) | |
2325 ->add_available_in_free_list(category, -(*node_size)); | |
2326 DCHECK(IsVeryLong() || available() == SumFreeLists()); | |
2327 } | |
2328 return node; | |
2329 } | |
2330 | |
2331 | |
2321 FreeSpace* FreeList::FindNodeFor(int size_in_bytes, int* node_size) { | 2332 FreeSpace* FreeList::FindNodeFor(int size_in_bytes, int* node_size) { |
2322 FreeSpace* node = NULL; | 2333 FreeSpace* node = NULL; |
2323 Page* page = NULL; | 2334 Page* page = NULL; |
2324 | 2335 |
2325 if (size_in_bytes <= kSmallAllocationMax) { | 2336 if (size_in_bytes <= kSmallAllocationMax) { |
2326 node = small_list_.PickNodeFromList(node_size); | 2337 node = FindNodeIn(kSmall, node_size); |
2327 if (node != NULL) { | 2338 if (node != NULL) { |
2328 DCHECK(size_in_bytes <= *node_size); | |
2329 page = Page::FromAddress(node->address()); | |
2330 page->add_available_in_small_free_list(-(*node_size)); | |
2331 DCHECK(IsVeryLong() || available() == SumFreeLists()); | 2339 DCHECK(IsVeryLong() || available() == SumFreeLists()); |
2332 return node; | 2340 return node; |
2333 } | 2341 } |
2334 } | 2342 } |
2335 | 2343 |
2336 if (size_in_bytes <= kMediumAllocationMax) { | 2344 if (size_in_bytes <= kMediumAllocationMax) { |
2337 node = medium_list_.PickNodeFromList(node_size); | 2345 node = FindNodeIn(kMedium, node_size); |
2338 if (node != NULL) { | 2346 if (node != NULL) { |
2339 DCHECK(size_in_bytes <= *node_size); | |
2340 page = Page::FromAddress(node->address()); | |
2341 page->add_available_in_medium_free_list(-(*node_size)); | |
2342 DCHECK(IsVeryLong() || available() == SumFreeLists()); | 2347 DCHECK(IsVeryLong() || available() == SumFreeLists()); |
2343 return node; | 2348 return node; |
2344 } | 2349 } |
2345 } | 2350 } |
2346 | 2351 |
2347 if (size_in_bytes <= kLargeAllocationMax) { | 2352 if (size_in_bytes <= kLargeAllocationMax) { |
2348 node = large_list_.PickNodeFromList(node_size); | 2353 node = FindNodeIn(kLarge, node_size); |
2349 if (node != NULL) { | 2354 if (node != NULL) { |
2350 DCHECK(size_in_bytes <= *node_size); | |
2351 page = Page::FromAddress(node->address()); | |
2352 page->add_available_in_large_free_list(-(*node_size)); | |
2353 DCHECK(IsVeryLong() || available() == SumFreeLists()); | 2355 DCHECK(IsVeryLong() || available() == SumFreeLists()); |
2354 return node; | 2356 return node; |
2355 } | 2357 } |
2356 } | 2358 } |
2357 | 2359 |
2358 node = huge_list_.SearchForNodeInList(size_in_bytes, node_size); | 2360 node = huge_list_.SearchForNodeInList(size_in_bytes, node_size); |
2359 | 2361 |
2360 if (node != NULL) { | 2362 if (node != NULL) { |
2361 DCHECK(IsVeryLong() || available() == SumFreeLists()); | 2363 DCHECK(IsVeryLong() || available() == SumFreeLists()); |
2362 return node; | 2364 return node; |
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3156 object->ShortPrint(); | 3158 object->ShortPrint(); |
3157 PrintF("\n"); | 3159 PrintF("\n"); |
3158 } | 3160 } |
3159 printf(" --------------------------------------\n"); | 3161 printf(" --------------------------------------\n"); |
3160 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3162 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3161 } | 3163 } |
3162 | 3164 |
3163 #endif // DEBUG | 3165 #endif // DEBUG |
3164 } // namespace internal | 3166 } // namespace internal |
3165 } // namespace v8 | 3167 } // namespace v8 |
OLD | NEW |