Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: src/heap/spaces.h

Issue 2674493002: [heap] Refactor AllocatedSinceLastGC (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698