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 #ifndef V8_HEAP_SPACES_H_ | 5 #ifndef V8_HEAP_SPACES_H_ |
6 #define V8_HEAP_SPACES_H_ | 6 #define V8_HEAP_SPACES_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <memory> | 9 #include <memory> |
10 #include <unordered_set> | 10 #include <unordered_set> |
(...skipping 2422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2433 // Approximate amount of physical memory committed for this space. | 2433 // Approximate amount of physical memory committed for this space. |
2434 size_t CommittedPhysicalMemory() override; | 2434 size_t CommittedPhysicalMemory() override; |
2435 | 2435 |
2436 // Return the available bytes without growing. | 2436 // Return the available bytes without growing. |
2437 size_t Available() override { | 2437 size_t Available() override { |
2438 DCHECK_GE(Capacity(), Size()); | 2438 DCHECK_GE(Capacity(), Size()); |
2439 return Capacity() - Size(); | 2439 return Capacity() - Size(); |
2440 } | 2440 } |
2441 | 2441 |
2442 size_t AllocatedSinceLastGC() { | 2442 size_t AllocatedSinceLastGC() { |
2443 bool seen_age_mark = false; | 2443 const Address age_mark = to_space_.age_mark(); |
2444 Address age_mark = to_space_.age_mark(); | 2444 DCHECK_NOT_NULL(age_mark); |
2445 Page* current_page = to_space_.first_page(); | 2445 DCHECK_NOT_NULL(top()); |
2446 Page* age_mark_page = Page::FromAddress(age_mark); | 2446 Page* const age_mark_page = Page::FromAllocationAreaAddress(age_mark); |
2447 Page* last_page = Page::FromAddress(top() - kPointerSize); | 2447 Page* const last_page = Page::FromAllocationAreaAddress(top()); |
2448 if (age_mark_page == last_page) { | 2448 Page* current_page = age_mark_page; |
2449 if (top() - age_mark >= 0) { | 2449 size_t allocated = 0; |
2450 return top() - age_mark; | 2450 if (current_page != last_page) { |
2451 } | 2451 DCHECK_EQ(current_page, age_mark_page); |
2452 // Top was reset at some point, invalidating this metric. | 2452 DCHECK_GE(age_mark_page->area_end(), age_mark); |
2453 return 0; | 2453 allocated += age_mark_page->area_end() - age_mark; |
| 2454 current_page = current_page->next_page(); |
| 2455 } else { |
| 2456 DCHECK_GE(top(), age_mark); |
| 2457 return top() - age_mark; |
2454 } | 2458 } |
2455 while (current_page != last_page) { | 2459 while (current_page != last_page) { |
2456 if (current_page == age_mark_page) { | 2460 DCHECK_NE(current_page, age_mark_page); |
2457 seen_age_mark = true; | |
2458 break; | |
2459 } | |
2460 current_page = current_page->next_page(); | |
2461 } | |
2462 if (!seen_age_mark) { | |
2463 // Top was reset at some point, invalidating this metric. | |
2464 return 0; | |
2465 } | |
2466 DCHECK_GE(age_mark_page->area_end(), age_mark); | |
2467 size_t allocated = age_mark_page->area_end() - age_mark; | |
2468 DCHECK_EQ(current_page, age_mark_page); | |
2469 current_page = age_mark_page->next_page(); | |
2470 while (current_page != last_page) { | |
2471 allocated += Page::kAllocatableMemory; | 2461 allocated += Page::kAllocatableMemory; |
2472 current_page = current_page->next_page(); | 2462 current_page = current_page->next_page(); |
2473 } | 2463 } |
2474 DCHECK_GE(top(), current_page->area_start()); | 2464 DCHECK_GE(top(), current_page->area_start()); |
2475 allocated += top() - current_page->area_start(); | 2465 allocated += top() - current_page->area_start(); |
2476 DCHECK_LE(allocated, Size()); | 2466 DCHECK_LE(allocated, Size()); |
2477 return allocated; | 2467 return allocated; |
2478 } | 2468 } |
2479 | 2469 |
2480 void MovePageFromSpaceToSpace(Page* page) { | 2470 void MovePageFromSpaceToSpace(Page* page) { |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2907 PageIterator old_iterator_; | 2897 PageIterator old_iterator_; |
2908 PageIterator code_iterator_; | 2898 PageIterator code_iterator_; |
2909 PageIterator map_iterator_; | 2899 PageIterator map_iterator_; |
2910 LargePageIterator lo_iterator_; | 2900 LargePageIterator lo_iterator_; |
2911 }; | 2901 }; |
2912 | 2902 |
2913 } // namespace internal | 2903 } // namespace internal |
2914 } // namespace v8 | 2904 } // namespace v8 |
2915 | 2905 |
2916 #endif // V8_HEAP_SPACES_H_ | 2906 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |