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

Side by Side Diff: src/spaces.cc

Issue 113267: Reapply r1900, r1897, r1895 with a fix.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 7 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') | src/spaces-inl.h » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 Page* p = Page::FromAllocationTop(cur_addr_); 104 Page* p = Page::FromAllocationTop(cur_addr_);
105 ASSERT(p == Page::FromAllocationTop(cur_limit_)); 105 ASSERT(p == Page::FromAllocationTop(cur_limit_));
106 ASSERT(p->Offset(cur_addr_) <= p->Offset(cur_limit_)); 106 ASSERT(p->Offset(cur_addr_) <= p->Offset(cur_limit_));
107 } 107 }
108 #endif 108 #endif
109 109
110 110
111 // ----------------------------------------------------------------------------- 111 // -----------------------------------------------------------------------------
112 // PageIterator 112 // PageIterator
113 113
114 PageIterator::PageIterator(PagedSpace* space, Mode mode) { 114 PageIterator::PageIterator(PagedSpace* space, Mode mode) : space_(space) {
115 cur_page_ = space->first_page_; 115 prev_page_ = NULL;
116 switch (mode) { 116 switch (mode) {
117 case PAGES_IN_USE: 117 case PAGES_IN_USE:
118 stop_page_ = space->AllocationTopPage()->next_page(); 118 stop_page_ = space->AllocationTopPage();
119 break; 119 break;
120 case PAGES_USED_BY_MC: 120 case PAGES_USED_BY_MC:
121 stop_page_ = space->MCRelocationTopPage()->next_page(); 121 stop_page_ = space->MCRelocationTopPage();
122 break; 122 break;
123 case ALL_PAGES: 123 case ALL_PAGES:
124 stop_page_ = Page::FromAddress(NULL); 124 stop_page_ = space->last_page_;
125 break; 125 break;
126 default: 126 default:
127 UNREACHABLE(); 127 UNREACHABLE();
128 } 128 }
129 } 129 }
130 130
131 131
132 // ----------------------------------------------------------------------------- 132 // -----------------------------------------------------------------------------
133 // Page 133 // Page
134 134
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 if (!first_page_->is_valid()) return false; 489 if (!first_page_->is_valid()) return false;
490 } 490 }
491 491
492 // We are sure that the first page is valid and that we have at least one 492 // We are sure that the first page is valid and that we have at least one
493 // page. 493 // page.
494 ASSERT(first_page_->is_valid()); 494 ASSERT(first_page_->is_valid());
495 ASSERT(num_pages > 0); 495 ASSERT(num_pages > 0);
496 accounting_stats_.ExpandSpace(num_pages * Page::kObjectAreaSize); 496 accounting_stats_.ExpandSpace(num_pages * Page::kObjectAreaSize);
497 ASSERT(Capacity() <= max_capacity_); 497 ASSERT(Capacity() <= max_capacity_);
498 498
499 // Sequentially initialize remembered sets in the newly allocated
500 // pages and cache the current last page in the space.
499 for (Page* p = first_page_; p->is_valid(); p = p->next_page()) { 501 for (Page* p = first_page_; p->is_valid(); p = p->next_page()) {
500 p->ClearRSet(); 502 p->ClearRSet();
503 last_page_ = p;
501 } 504 }
502 505
503 // Use first_page_ for allocation. 506 // Use first_page_ for allocation.
504 SetAllocationInfo(&allocation_info_, first_page_); 507 SetAllocationInfo(&allocation_info_, first_page_);
505 508
506 return true; 509 return true;
507 } 510 }
508 511
509 512
510 bool PagedSpace::HasBeenSetup() { 513 bool PagedSpace::HasBeenSetup() {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 672
670 int desired_pages = Min(available_pages, MemoryAllocator::kPagesPerChunk); 673 int desired_pages = Min(available_pages, MemoryAllocator::kPagesPerChunk);
671 Page* p = MemoryAllocator::AllocatePages(desired_pages, &desired_pages, this); 674 Page* p = MemoryAllocator::AllocatePages(desired_pages, &desired_pages, this);
672 if (!p->is_valid()) return false; 675 if (!p->is_valid()) return false;
673 676
674 accounting_stats_.ExpandSpace(desired_pages * Page::kObjectAreaSize); 677 accounting_stats_.ExpandSpace(desired_pages * Page::kObjectAreaSize);
675 ASSERT(Capacity() <= max_capacity_); 678 ASSERT(Capacity() <= max_capacity_);
676 679
677 MemoryAllocator::SetNextPage(last_page, p); 680 MemoryAllocator::SetNextPage(last_page, p);
678 681
679 // Clear remembered set of new pages. 682 // Sequentially clear remembered set of new pages and and cache the
683 // new last page in the space.
680 while (p->is_valid()) { 684 while (p->is_valid()) {
681 p->ClearRSet(); 685 p->ClearRSet();
686 last_page_ = p;
682 p = p->next_page(); 687 p = p->next_page();
683 } 688 }
684 689
685 return true; 690 return true;
686 } 691 }
687 692
688 693
689 #ifdef DEBUG 694 #ifdef DEBUG
690 int PagedSpace::CountTotalPages() { 695 int PagedSpace::CountTotalPages() {
691 int count = 0; 696 int count = 0;
(...skipping 24 matching lines...) Expand all
716 last_page_to_keep = last_page_to_keep->next_page(); 721 last_page_to_keep = last_page_to_keep->next_page();
717 } 722 }
718 free_pages++; 723 free_pages++;
719 current_page = current_page->next_page(); 724 current_page = current_page->next_page();
720 } 725 }
721 726
722 // Free pages after last_page_to_keep, and adjust the next_page link. 727 // Free pages after last_page_to_keep, and adjust the next_page link.
723 Page* p = MemoryAllocator::FreePages(last_page_to_keep->next_page()); 728 Page* p = MemoryAllocator::FreePages(last_page_to_keep->next_page());
724 MemoryAllocator::SetNextPage(last_page_to_keep, p); 729 MemoryAllocator::SetNextPage(last_page_to_keep, p);
725 730
726 // Since pages are only freed in whole chunks, we may have kept more than 731 // Since pages are only freed in whole chunks, we may have kept more
727 // pages_to_keep. 732 // than pages_to_keep. Count the extra pages and cache the new last
733 // page in the space.
734 last_page_ = last_page_to_keep;
728 while (p->is_valid()) { 735 while (p->is_valid()) {
729 pages_to_keep++; 736 pages_to_keep++;
737 last_page_ = p;
730 p = p->next_page(); 738 p = p->next_page();
731 } 739 }
732 740
733 // The difference between free_pages and pages_to_keep is the number of 741 // The difference between free_pages and pages_to_keep is the number of
734 // pages actually freed. 742 // pages actually freed.
735 ASSERT(pages_to_keep <= free_pages); 743 ASSERT(pages_to_keep <= free_pages);
736 int bytes_freed = (free_pages - pages_to_keep) * Page::kObjectAreaSize; 744 int bytes_freed = (free_pages - pages_to_keep) * Page::kObjectAreaSize;
737 accounting_stats_.ShrinkSpace(bytes_freed); 745 accounting_stats_.ShrinkSpace(bytes_freed);
738 746
739 ASSERT(Capacity() == CountTotalPages() * Page::kObjectAreaSize); 747 ASSERT(Capacity() == CountTotalPages() * Page::kObjectAreaSize);
(...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after
2590 reinterpret_cast<Object**>(object->address() 2598 reinterpret_cast<Object**>(object->address()
2591 + Page::kObjectAreaSize), 2599 + Page::kObjectAreaSize),
2592 allocation_top); 2600 allocation_top);
2593 PrintF("\n"); 2601 PrintF("\n");
2594 } 2602 }
2595 } 2603 }
2596 } 2604 }
2597 #endif // DEBUG 2605 #endif // DEBUG
2598 2606
2599 } } // namespace v8::internal 2607 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/spaces.h ('k') | src/spaces-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698