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

Side by Side Diff: src/spaces.cc

Issue 9173001: Make heap size estimation more accurate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed more comments by Vyacheslav Egorov. Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/spaces.h ('k') | test/cctest/test-heap.cc » ('j') | 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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 // ----------------------------------------------------------------------------- 651 // -----------------------------------------------------------------------------
652 // PagedSpace implementation 652 // PagedSpace implementation
653 653
654 PagedSpace::PagedSpace(Heap* heap, 654 PagedSpace::PagedSpace(Heap* heap,
655 intptr_t max_capacity, 655 intptr_t max_capacity,
656 AllocationSpace id, 656 AllocationSpace id,
657 Executability executable) 657 Executability executable)
658 : Space(heap, id, executable), 658 : Space(heap, id, executable),
659 free_list_(this), 659 free_list_(this),
660 was_swept_conservatively_(false), 660 was_swept_conservatively_(false),
661 first_unswept_page_(Page::FromAddress(NULL)) { 661 first_unswept_page_(Page::FromAddress(NULL)),
662 unswept_free_bytes_(0) {
662 max_capacity_ = (RoundDown(max_capacity, Page::kPageSize) / Page::kPageSize) 663 max_capacity_ = (RoundDown(max_capacity, Page::kPageSize) / Page::kPageSize)
663 * Page::kObjectAreaSize; 664 * Page::kObjectAreaSize;
664 accounting_stats_.Clear(); 665 accounting_stats_.Clear();
665 666
666 allocation_info_.top = NULL; 667 allocation_info_.top = NULL;
667 allocation_info_.limit = NULL; 668 allocation_info_.limit = NULL;
668 669
669 anchor_.InitializeAsAnchor(this); 670 anchor_.InitializeAsAnchor(this);
670 } 671 }
671 672
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 Bitmap::Clear(p); 2056 Bitmap::Clear(p);
2056 if (FLAG_gc_verbose) { 2057 if (FLAG_gc_verbose) {
2057 PrintF("Sweeping 0x%" V8PRIxPTR " lazily abandoned.\n", 2058 PrintF("Sweeping 0x%" V8PRIxPTR " lazily abandoned.\n",
2058 reinterpret_cast<intptr_t>(p)); 2059 reinterpret_cast<intptr_t>(p));
2059 } 2060 }
2060 } 2061 }
2061 p = p->next_page(); 2062 p = p->next_page();
2062 } while (p != anchor()); 2063 } while (p != anchor());
2063 } 2064 }
2064 first_unswept_page_ = Page::FromAddress(NULL); 2065 first_unswept_page_ = Page::FromAddress(NULL);
2066 unswept_free_bytes_ = 0;
2065 2067
2066 // Clear the free list before a full GC---it will be rebuilt afterward. 2068 // Clear the free list before a full GC---it will be rebuilt afterward.
2067 free_list_.Reset(); 2069 free_list_.Reset();
2068 } 2070 }
2069 2071
2070 2072
2071 bool PagedSpace::ReserveSpace(int size_in_bytes) { 2073 bool PagedSpace::ReserveSpace(int size_in_bytes) {
2072 ASSERT(size_in_bytes <= Page::kMaxHeapObjectSize); 2074 ASSERT(size_in_bytes <= Page::kMaxHeapObjectSize);
2073 ASSERT(size_in_bytes == RoundSizeDownToObjectAlignment(size_in_bytes)); 2075 ASSERT(size_in_bytes == RoundSizeDownToObjectAlignment(size_in_bytes));
2074 Address current_top = allocation_info_.top; 2076 Address current_top = allocation_info_.top;
(...skipping 28 matching lines...) Expand all
2103 2105
2104 intptr_t freed_bytes = 0; 2106 intptr_t freed_bytes = 0;
2105 Page* p = first_unswept_page_; 2107 Page* p = first_unswept_page_;
2106 do { 2108 do {
2107 Page* next_page = p->next_page(); 2109 Page* next_page = p->next_page();
2108 if (ShouldBeSweptLazily(p)) { 2110 if (ShouldBeSweptLazily(p)) {
2109 if (FLAG_gc_verbose) { 2111 if (FLAG_gc_verbose) {
2110 PrintF("Sweeping 0x%" V8PRIxPTR " lazily advanced.\n", 2112 PrintF("Sweeping 0x%" V8PRIxPTR " lazily advanced.\n",
2111 reinterpret_cast<intptr_t>(p)); 2113 reinterpret_cast<intptr_t>(p));
2112 } 2114 }
2115 unswept_free_bytes_ -= (Page::kObjectAreaSize - p->LiveBytes());
2113 freed_bytes += MarkCompactCollector::SweepConservatively(this, p); 2116 freed_bytes += MarkCompactCollector::SweepConservatively(this, p);
2114 } 2117 }
2115 p = next_page; 2118 p = next_page;
2116 } while (p != anchor() && freed_bytes < bytes_to_sweep); 2119 } while (p != anchor() && freed_bytes < bytes_to_sweep);
2117 2120
2118 if (p == anchor()) { 2121 if (p == anchor()) {
2119 first_unswept_page_ = Page::FromAddress(NULL); 2122 first_unswept_page_ = Page::FromAddress(NULL);
2120 } else { 2123 } else {
2121 first_unswept_page_ = p; 2124 first_unswept_page_ = p;
2122 } 2125 }
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
2658 object->ShortPrint(); 2661 object->ShortPrint();
2659 PrintF("\n"); 2662 PrintF("\n");
2660 } 2663 }
2661 printf(" --------------------------------------\n"); 2664 printf(" --------------------------------------\n");
2662 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 2665 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
2663 } 2666 }
2664 2667
2665 #endif // DEBUG 2668 #endif // DEBUG
2666 2669
2667 } } // namespace v8::internal 2670 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/spaces.h ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698