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

Side by Side Diff: src/spaces.cc

Issue 8692002: Only sweep one page eagerly unless we are running out of space. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years 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') | 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 // 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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 if (p == NULL) return false; 731 if (p == NULL) return false;
732 732
733 ASSERT(Capacity() <= max_capacity_); 733 ASSERT(Capacity() <= max_capacity_);
734 734
735 p->InsertAfter(anchor_.prev_page()); 735 p->InsertAfter(anchor_.prev_page());
736 736
737 return true; 737 return true;
738 } 738 }
739 739
740 740
741 #ifdef DEBUG
742 int PagedSpace::CountTotalPages() { 741 int PagedSpace::CountTotalPages() {
743 PageIterator it(this); 742 PageIterator it(this);
744 int count = 0; 743 int count = 0;
745 while (it.has_next()) { 744 while (it.has_next()) {
746 it.next(); 745 it.next();
747 count++; 746 count++;
748 } 747 }
749 return count; 748 return count;
750 } 749 }
751 #endif
752 750
753 751
754 void PagedSpace::ReleasePage(Page* page) { 752 void PagedSpace::ReleasePage(Page* page) {
755 ASSERT(page->LiveBytes() == 0); 753 ASSERT(page->LiveBytes() == 0);
756 754
757 // Adjust list of unswept pages if the page is it's head or tail. 755 // Adjust list of unswept pages if the page is it's head or tail.
758 if (first_unswept_page_ == page) { 756 if (first_unswept_page_ == page) {
759 first_unswept_page_ = page->next_page(); 757 first_unswept_page_ = page->next_page();
760 if (first_unswept_page_ == anchor()) { 758 if (first_unswept_page_ == anchor()) {
761 first_unswept_page_ = Page::FromAddress(NULL); 759 first_unswept_page_ = Page::FromAddress(NULL);
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 ASSERT(IsVeryLong() || available_ == SumFreeLists()); 1844 ASSERT(IsVeryLong() || available_ == SumFreeLists());
1847 1845
1848 int bytes_left = new_node_size - size_in_bytes; 1846 int bytes_left = new_node_size - size_in_bytes;
1849 ASSERT(bytes_left >= 0); 1847 ASSERT(bytes_left >= 0);
1850 1848
1851 int old_linear_size = static_cast<int>(owner_->limit() - owner_->top()); 1849 int old_linear_size = static_cast<int>(owner_->limit() - owner_->top());
1852 // Mark the old linear allocation area with a free space map so it can be 1850 // Mark the old linear allocation area with a free space map so it can be
1853 // skipped when scanning the heap. This also puts it back in the free list 1851 // skipped when scanning the heap. This also puts it back in the free list
1854 // if it is big enough. 1852 // if it is big enough.
1855 owner_->Free(owner_->top(), old_linear_size); 1853 owner_->Free(owner_->top(), old_linear_size);
1854
1855 #ifdef DEBUG
1856 for (int i = 0; i < size_in_bytes / kPointerSize; i++) {
1857 reinterpret_cast<Object**>(new_node)[i] = Smi::FromInt(0);
1858 }
1859 #endif
1860
1856 owner_->heap()->incremental_marking()->OldSpaceStep( 1861 owner_->heap()->incremental_marking()->OldSpaceStep(
1857 size_in_bytes - old_linear_size); 1862 size_in_bytes - old_linear_size);
1858 1863
1859 // The old-space-step might have finished sweeping and restarted marking. 1864 // The old-space-step might have finished sweeping and restarted marking.
1860 // Verify that it did not turn the page of the new node into an evacuation 1865 // Verify that it did not turn the page of the new node into an evacuation
1861 // candidate. 1866 // candidate.
1862 ASSERT(!MarkCompactCollector::IsOnEvacuationCandidate(new_node)); 1867 ASSERT(!MarkCompactCollector::IsOnEvacuationCandidate(new_node));
1863 1868
1864 const int kThreshold = IncrementalMarking::kAllocatedThreshold; 1869 const int kThreshold = IncrementalMarking::kAllocatedThreshold;
1865 1870
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
2436 AllocateLargePage(object_size, executable, this); 2441 AllocateLargePage(object_size, executable, this);
2437 if (page == NULL) return Failure::RetryAfterGC(identity()); 2442 if (page == NULL) return Failure::RetryAfterGC(identity());
2438 ASSERT(page->body_size() >= object_size); 2443 ASSERT(page->body_size() >= object_size);
2439 2444
2440 size_ += static_cast<int>(page->size()); 2445 size_ += static_cast<int>(page->size());
2441 objects_size_ += object_size; 2446 objects_size_ += object_size;
2442 page_count_++; 2447 page_count_++;
2443 page->set_next_page(first_page_); 2448 page->set_next_page(first_page_);
2444 first_page_ = page; 2449 first_page_ = page;
2445 2450
2451 HeapObject* object = page->GetObject();
2452
2453 #ifdef DEBUG
2454 // Make the object consistent so the heap can be vefified in OldSpaceStep.
2455 reinterpret_cast<Object**>(object->address())[0] =
2456 heap()->fixed_array_map();
2457 reinterpret_cast<Object**>(object->address())[1] = Smi::FromInt(0);
2458 #endif
2459
2446 heap()->incremental_marking()->OldSpaceStep(object_size); 2460 heap()->incremental_marking()->OldSpaceStep(object_size);
2447 return page->GetObject(); 2461 return object;
2448 } 2462 }
2449 2463
2450 2464
2451 // GC support 2465 // GC support
2452 MaybeObject* LargeObjectSpace::FindObject(Address a) { 2466 MaybeObject* LargeObjectSpace::FindObject(Address a) {
2453 for (LargePage* page = first_page_; 2467 for (LargePage* page = first_page_;
2454 page != NULL; 2468 page != NULL;
2455 page = page->next_page()) { 2469 page = page->next_page()) {
2456 Address page_address = page->address(); 2470 Address page_address = page->address();
2457 if (page_address <= a && a < page_address + page->size()) { 2471 if (page_address <= a && a < page_address + page->size()) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
2636 object->ShortPrint(); 2650 object->ShortPrint();
2637 PrintF("\n"); 2651 PrintF("\n");
2638 } 2652 }
2639 printf(" --------------------------------------\n"); 2653 printf(" --------------------------------------\n");
2640 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 2654 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
2641 } 2655 }
2642 2656
2643 #endif // DEBUG 2657 #endif // DEBUG
2644 2658
2645 } } // namespace v8::internal 2659 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/spaces.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698