| 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 2273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2284 } | 2284 } |
| 2285 return false; | 2285 return false; |
| 2286 } | 2286 } |
| 2287 | 2287 |
| 2288 | 2288 |
| 2289 FreeSpace* FreeListCategory::PickNodeFromList(int* node_size) { | 2289 FreeSpace* FreeListCategory::PickNodeFromList(int* node_size) { |
| 2290 FreeSpace* node = top(); | 2290 FreeSpace* node = top(); |
| 2291 if (node == nullptr) return nullptr; | 2291 if (node == nullptr) return nullptr; |
| 2292 | 2292 |
| 2293 Page* page = Page::FromAddress(node->address()); | 2293 Page* page = Page::FromAddress(node->address()); |
| 2294 while ((node != nullptr) && page->IsEvacuationCandidate()) { | 2294 while ((node != nullptr) && !page->CanAllocate()) { |
| 2295 available_ -= node->size(); | 2295 available_ -= node->size(); |
| 2296 page->add_available_in_free_list(type_, -(node->Size())); | 2296 page->add_available_in_free_list(type_, -(node->Size())); |
| 2297 node = node->next(); | 2297 node = node->next(); |
| 2298 } | 2298 } |
| 2299 | 2299 |
| 2300 if (node != nullptr) { | 2300 if (node != nullptr) { |
| 2301 set_top(node->next()); | 2301 set_top(node->next()); |
| 2302 *node_size = node->Size(); | 2302 *node_size = node->Size(); |
| 2303 available_ -= *node_size; | 2303 available_ -= *node_size; |
| 2304 } else { | 2304 } else { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2326 | 2326 |
| 2327 | 2327 |
| 2328 FreeSpace* FreeListCategory::SearchForNodeInList(int size_in_bytes, | 2328 FreeSpace* FreeListCategory::SearchForNodeInList(int size_in_bytes, |
| 2329 int* node_size) { | 2329 int* node_size) { |
| 2330 FreeSpace* prev_non_evac_node = nullptr; | 2330 FreeSpace* prev_non_evac_node = nullptr; |
| 2331 for (FreeSpace* cur_node = top(); cur_node != nullptr; | 2331 for (FreeSpace* cur_node = top(); cur_node != nullptr; |
| 2332 cur_node = cur_node->next()) { | 2332 cur_node = cur_node->next()) { |
| 2333 int size = cur_node->size(); | 2333 int size = cur_node->size(); |
| 2334 Page* page_for_node = Page::FromAddress(cur_node->address()); | 2334 Page* page_for_node = Page::FromAddress(cur_node->address()); |
| 2335 | 2335 |
| 2336 if ((size >= size_in_bytes) || page_for_node->IsEvacuationCandidate()) { | 2336 if ((size >= size_in_bytes) || !page_for_node->CanAllocate()) { |
| 2337 // The node is either large enough or contained in an evacuation | 2337 // The node is either large enough or contained in an evacuation |
| 2338 // candidate. In both cases we need to unlink it from the list. | 2338 // candidate. In both cases we need to unlink it from the list. |
| 2339 available_ -= size; | 2339 available_ -= size; |
| 2340 if (cur_node == top()) { | 2340 if (cur_node == top()) { |
| 2341 set_top(cur_node->next()); | 2341 set_top(cur_node->next()); |
| 2342 } | 2342 } |
| 2343 if (cur_node == end()) { | 2343 if (cur_node == end()) { |
| 2344 set_end(prev_non_evac_node); | 2344 set_end(prev_non_evac_node); |
| 2345 } | 2345 } |
| 2346 if (prev_non_evac_node != nullptr) { | 2346 if (prev_non_evac_node != nullptr) { |
| 2347 prev_non_evac_node->set_next(cur_node->next()); | 2347 prev_non_evac_node->set_next(cur_node->next()); |
| 2348 } | 2348 } |
| 2349 // For evacuation candidates we continue. | 2349 // For evacuation candidates we continue. |
| 2350 if (page_for_node->IsEvacuationCandidate()) { | 2350 if (!page_for_node->CanAllocate()) { |
| 2351 page_for_node->add_available_in_free_list(type_, -size); | 2351 page_for_node->add_available_in_free_list(type_, -size); |
| 2352 continue; | 2352 continue; |
| 2353 } | 2353 } |
| 2354 // Otherwise we have a large enough node and can return. | 2354 // Otherwise we have a large enough node and can return. |
| 2355 *node_size = size; | 2355 *node_size = size; |
| 2356 return cur_node; | 2356 return cur_node; |
| 2357 } | 2357 } |
| 2358 | 2358 |
| 2359 prev_non_evac_node = cur_node; | 2359 prev_non_evac_node = cur_node; |
| 2360 } | 2360 } |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2751 if (size == 0) continue; | 2751 if (size == 0) continue; |
| 2752 Address address = page->OffsetToAddress(Page::kPageSize - size); | 2752 Address address = page->OffsetToAddress(Page::kPageSize - size); |
| 2753 heap()->CreateFillerObjectAt(address, size); | 2753 heap()->CreateFillerObjectAt(address, size); |
| 2754 } | 2754 } |
| 2755 } | 2755 } |
| 2756 | 2756 |
| 2757 | 2757 |
| 2758 void PagedSpace::EvictEvacuationCandidatesFromLinearAllocationArea() { | 2758 void PagedSpace::EvictEvacuationCandidatesFromLinearAllocationArea() { |
| 2759 if (allocation_info_.top() >= allocation_info_.limit()) return; | 2759 if (allocation_info_.top() >= allocation_info_.limit()) return; |
| 2760 | 2760 |
| 2761 if (Page::FromAllocationTop(allocation_info_.top()) | 2761 if (!Page::FromAllocationTop(allocation_info_.top())->CanAllocate()) { |
| 2762 ->IsEvacuationCandidate()) { | |
| 2763 // Create filler object to keep page iterable if it was iterable. | 2762 // Create filler object to keep page iterable if it was iterable. |
| 2764 int remaining = | 2763 int remaining = |
| 2765 static_cast<int>(allocation_info_.limit() - allocation_info_.top()); | 2764 static_cast<int>(allocation_info_.limit() - allocation_info_.top()); |
| 2766 heap()->CreateFillerObjectAt(allocation_info_.top(), remaining); | 2765 heap()->CreateFillerObjectAt(allocation_info_.top(), remaining); |
| 2767 | 2766 |
| 2768 allocation_info_.set_top(nullptr); | 2767 allocation_info_.set_top(nullptr); |
| 2769 allocation_info_.set_limit(nullptr); | 2768 allocation_info_.set_limit(nullptr); |
| 2770 } | 2769 } |
| 2771 } | 2770 } |
| 2772 | 2771 |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3324 object->ShortPrint(); | 3323 object->ShortPrint(); |
| 3325 PrintF("\n"); | 3324 PrintF("\n"); |
| 3326 } | 3325 } |
| 3327 printf(" --------------------------------------\n"); | 3326 printf(" --------------------------------------\n"); |
| 3328 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3327 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3329 } | 3328 } |
| 3330 | 3329 |
| 3331 #endif // DEBUG | 3330 #endif // DEBUG |
| 3332 } // namespace internal | 3331 } // namespace internal |
| 3333 } // namespace v8 | 3332 } // namespace v8 |
| OLD | NEW |