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 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 ASSERT(top_page->is_valid()); | 718 ASSERT(top_page->is_valid()); |
719 | 719 |
720 // Loop over the pages from the top page to the end of the space to count | 720 // Loop over the pages from the top page to the end of the space to count |
721 // the number of pages to keep and find the last page to keep. | 721 // the number of pages to keep and find the last page to keep. |
722 int free_pages = 0; | 722 int free_pages = 0; |
723 int pages_to_keep = 0; // Of the free pages. | 723 int pages_to_keep = 0; // Of the free pages. |
724 Page* last_page_to_keep = top_page; | 724 Page* last_page_to_keep = top_page; |
725 Page* current_page = top_page->next_page(); | 725 Page* current_page = top_page->next_page(); |
726 // Loop over the pages to the end of the space. | 726 // Loop over the pages to the end of the space. |
727 while (current_page->is_valid()) { | 727 while (current_page->is_valid()) { |
| 728 #if defined(ANDROID) |
| 729 // Free all chunks if possible |
| 730 #else |
728 // Advance last_page_to_keep every other step to end up at the midpoint. | 731 // Advance last_page_to_keep every other step to end up at the midpoint. |
729 if ((free_pages & 0x1) == 1) { | 732 if ((free_pages & 0x1) == 1) { |
730 pages_to_keep++; | 733 pages_to_keep++; |
731 last_page_to_keep = last_page_to_keep->next_page(); | 734 last_page_to_keep = last_page_to_keep->next_page(); |
732 } | 735 } |
| 736 #endif |
733 free_pages++; | 737 free_pages++; |
734 current_page = current_page->next_page(); | 738 current_page = current_page->next_page(); |
735 } | 739 } |
736 | 740 |
737 // Free pages after last_page_to_keep, and adjust the next_page link. | 741 // Free pages after last_page_to_keep, and adjust the next_page link. |
738 Page* p = MemoryAllocator::FreePages(last_page_to_keep->next_page()); | 742 Page* p = MemoryAllocator::FreePages(last_page_to_keep->next_page()); |
739 MemoryAllocator::SetNextPage(last_page_to_keep, p); | 743 MemoryAllocator::SetNextPage(last_page_to_keep, p); |
740 | 744 |
741 // Since pages are only freed in whole chunks, we may have kept more | 745 // Since pages are only freed in whole chunks, we may have kept more |
742 // than pages_to_keep. Count the extra pages and cache the new last | 746 // than pages_to_keep. Count the extra pages and cache the new last |
(...skipping 1848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2591 reinterpret_cast<Object**>(object->address() | 2595 reinterpret_cast<Object**>(object->address() |
2592 + Page::kObjectAreaSize), | 2596 + Page::kObjectAreaSize), |
2593 allocation_top); | 2597 allocation_top); |
2594 PrintF("\n"); | 2598 PrintF("\n"); |
2595 } | 2599 } |
2596 } | 2600 } |
2597 } | 2601 } |
2598 #endif // DEBUG | 2602 #endif // DEBUG |
2599 | 2603 |
2600 } } // namespace v8::internal | 2604 } } // namespace v8::internal |
OLD | NEW |