OLD | NEW |
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 Loading... |
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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 for (Page* p = first_page_; p->is_valid(); p = p->next_page()) { | 499 for (Page* p = first_page_; p->is_valid(); p = p->next_page()) { |
500 p->ClearRSet(); | 500 p->ClearRSet(); |
| 501 last_page_ = p; |
501 } | 502 } |
502 | 503 |
503 // Use first_page_ for allocation. | 504 // Use first_page_ for allocation. |
504 SetAllocationInfo(&allocation_info_, first_page_); | 505 SetAllocationInfo(&allocation_info_, first_page_); |
505 | 506 |
506 return true; | 507 return true; |
507 } | 508 } |
508 | 509 |
509 | 510 |
510 bool PagedSpace::HasBeenSetup() { | 511 bool PagedSpace::HasBeenSetup() { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 if (!p->is_valid()) return false; | 673 if (!p->is_valid()) return false; |
673 | 674 |
674 accounting_stats_.ExpandSpace(desired_pages * Page::kObjectAreaSize); | 675 accounting_stats_.ExpandSpace(desired_pages * Page::kObjectAreaSize); |
675 ASSERT(Capacity() <= max_capacity_); | 676 ASSERT(Capacity() <= max_capacity_); |
676 | 677 |
677 MemoryAllocator::SetNextPage(last_page, p); | 678 MemoryAllocator::SetNextPage(last_page, p); |
678 | 679 |
679 // Clear remembered set of new pages. | 680 // Clear remembered set of new pages. |
680 while (p->is_valid()) { | 681 while (p->is_valid()) { |
681 p->ClearRSet(); | 682 p->ClearRSet(); |
| 683 last_page_ = p; |
682 p = p->next_page(); | 684 p = p->next_page(); |
683 } | 685 } |
684 | 686 |
685 return true; | 687 return true; |
686 } | 688 } |
687 | 689 |
688 | 690 |
689 #ifdef DEBUG | 691 #ifdef DEBUG |
690 int PagedSpace::CountTotalPages() { | 692 int PagedSpace::CountTotalPages() { |
691 int count = 0; | 693 int count = 0; |
(...skipping 28 matching lines...) Expand all Loading... |
720 } | 722 } |
721 | 723 |
722 // Free pages after last_page_to_keep, and adjust the next_page link. | 724 // Free pages after last_page_to_keep, and adjust the next_page link. |
723 Page* p = MemoryAllocator::FreePages(last_page_to_keep->next_page()); | 725 Page* p = MemoryAllocator::FreePages(last_page_to_keep->next_page()); |
724 MemoryAllocator::SetNextPage(last_page_to_keep, p); | 726 MemoryAllocator::SetNextPage(last_page_to_keep, p); |
725 | 727 |
726 // Since pages are only freed in whole chunks, we may have kept more than | 728 // Since pages are only freed in whole chunks, we may have kept more than |
727 // pages_to_keep. | 729 // pages_to_keep. |
728 while (p->is_valid()) { | 730 while (p->is_valid()) { |
729 pages_to_keep++; | 731 pages_to_keep++; |
| 732 last_page_ = p; |
730 p = p->next_page(); | 733 p = p->next_page(); |
731 } | 734 } |
732 | 735 |
733 // The difference between free_pages and pages_to_keep is the number of | 736 // The difference between free_pages and pages_to_keep is the number of |
734 // pages actually freed. | 737 // pages actually freed. |
735 ASSERT(pages_to_keep <= free_pages); | 738 ASSERT(pages_to_keep <= free_pages); |
736 int bytes_freed = (free_pages - pages_to_keep) * Page::kObjectAreaSize; | 739 int bytes_freed = (free_pages - pages_to_keep) * Page::kObjectAreaSize; |
737 accounting_stats_.ShrinkSpace(bytes_freed); | 740 accounting_stats_.ShrinkSpace(bytes_freed); |
738 | 741 |
739 ASSERT(Capacity() == CountTotalPages() * Page::kObjectAreaSize); | 742 ASSERT(Capacity() == CountTotalPages() * Page::kObjectAreaSize); |
(...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2590 reinterpret_cast<Object**>(object->address() | 2593 reinterpret_cast<Object**>(object->address() |
2591 + Page::kObjectAreaSize), | 2594 + Page::kObjectAreaSize), |
2592 allocation_top); | 2595 allocation_top); |
2593 PrintF("\n"); | 2596 PrintF("\n"); |
2594 } | 2597 } |
2595 } | 2598 } |
2596 } | 2599 } |
2597 #endif // DEBUG | 2600 #endif // DEBUG |
2598 | 2601 |
2599 } } // namespace v8::internal | 2602 } } // namespace v8::internal |
OLD | NEW |