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

Side by Side Diff: src/mark-compact.cc

Issue 6745033: On store buffer overflow we mark individidual pages for... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 8 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
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 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 public: 1719 public:
1720 static inline void VisitPointer(Object** p) { 1720 static inline void VisitPointer(Object** p) {
1721 if (!(*p)->IsHeapObject()) return; 1721 if (!(*p)->IsHeapObject()) return;
1722 1722
1723 HeapObject* obj = HeapObject::cast(*p); 1723 HeapObject* obj = HeapObject::cast(*p);
1724 Address old_addr = obj->address(); 1724 Address old_addr = obj->address();
1725 1725
1726 if (Heap::new_space()->Contains(obj)) { 1726 if (Heap::new_space()->Contains(obj)) {
1727 ASSERT(Heap::InFromSpace(*p)); 1727 ASSERT(Heap::InFromSpace(*p));
1728 *p = HeapObject::FromAddress(Memory::Address_at(old_addr)); 1728 *p = HeapObject::FromAddress(Memory::Address_at(old_addr));
1729 StoreBuffer::EnterDirectlyIntoStoreBuffer(reinterpret_cast<Address>(p));
Vyacheslav Egorov (Chromium) 2011/03/28 15:13:19 This visitor is used to visit new space objects.
Erik Corry 2011/03/28 15:56:07 Good catch!
1729 } 1730 }
1730 } 1731 }
1731 }; 1732 };
1732 1733
1733 1734
1734 // Visitor for updating pointers from live objects in old spaces to new space. 1735 // Visitor for updating pointers from live objects in old spaces to new space.
1735 // It does not expect to encounter pointers to dead objects. 1736 // It does not expect to encounter pointers to dead objects.
1736 class PointersToNewGenUpdatingVisitor: public ObjectVisitor { 1737 class PointersToNewGenUpdatingVisitor: public ObjectVisitor {
1737 public: 1738 public:
1738 void VisitPointer(Object** p) { 1739 void VisitPointer(Object** p) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1839 1840
1840 // Flip the semispaces. After flipping, to space is empty, from space has 1841 // Flip the semispaces. After flipping, to space is empty, from space has
1841 // live objects. 1842 // live objects.
1842 space->Flip(); 1843 space->Flip();
1843 space->ResetAllocationInfo(); 1844 space->ResetAllocationInfo();
1844 1845
1845 int size = 0; 1846 int size = 0;
1846 int survivors_size = 0; 1847 int survivors_size = 0;
1847 1848
1848 // First pass: traverse all objects in inactive semispace, remove marks, 1849 // First pass: traverse all objects in inactive semispace, remove marks,
1849 // migrate live objects and write forwarding addresses. 1850 // migrate live objects and write forwarding addresses. This stage puts
1851 // new entries in the store buffer and may cause some pages to be marked
1852 // scan-on-scavenge.
1850 for (Address current = from_bottom; current < from_top; current += size) { 1853 for (Address current = from_bottom; current < from_top; current += size) {
1851 HeapObject* object = HeapObject::FromAddress(current); 1854 HeapObject* object = HeapObject::FromAddress(current);
1852 1855
1853 1856
1854 MarkBit mark_bit = Marking::MarkBitFromNewSpace(object); 1857 MarkBit mark_bit = Marking::MarkBitFromNewSpace(object);
1855 if (mark_bit.Get()) { 1858 if (mark_bit.Get()) {
1856 mark_bit.Clear(); 1859 mark_bit.Clear();
1857 MarkCompactCollector::tracer()->decrement_marked_count(); 1860 MarkCompactCollector::tracer()->decrement_marked_count();
1858 1861
1859 size = object->Size(); 1862 size = object->Size();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 current += 1895 current +=
1893 StaticPointersToNewGenUpdatingVisitor::IterateBody(object->map(), 1896 StaticPointersToNewGenUpdatingVisitor::IterateBody(object->map(),
1894 object); 1897 object);
1895 } 1898 }
1896 1899
1897 // Update roots. 1900 // Update roots.
1898 Heap::IterateRoots(&updating_visitor, VISIT_ALL_IN_SCAVENGE); 1901 Heap::IterateRoots(&updating_visitor, VISIT_ALL_IN_SCAVENGE);
1899 LiveObjectList::IterateElements(&updating_visitor); 1902 LiveObjectList::IterateElements(&updating_visitor);
1900 1903
1901 { 1904 {
1902 StoreBufferRebuildScope scope; 1905 StoreBufferRebuildScope scope(&Heap::ScavengeStoreBufferCallback);
1903 StoreBuffer::IteratePointersToNewSpace(&UpdatePointerToNewGen); 1906 StoreBuffer::IteratePointersToNewSpace(&UpdatePointerToNewGen);
1904 } 1907 }
1905 1908
1906 // Update pointers from cells. 1909 // Update pointers from cells.
1907 HeapObjectIterator cell_iterator(Heap::cell_space()); 1910 HeapObjectIterator cell_iterator(Heap::cell_space());
1908 for (HeapObject* cell = cell_iterator.Next(); 1911 for (HeapObject* cell = cell_iterator.Next();
1909 cell != NULL; 1912 cell != NULL;
1910 cell = cell_iterator.Next()) { 1913 cell = cell_iterator.Next()) {
1911 if (cell->IsJSGlobalPropertyCell()) { 1914 if (cell->IsJSGlobalPropertyCell()) {
1912 Address value_address = 1915 Address value_address =
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
2396 if (free_start != p->ObjectAreaEnd()) { 2399 if (free_start != p->ObjectAreaEnd()) {
2397 space->Free(free_start, p->ObjectAreaEnd() - free_start); 2400 space->Free(free_start, p->ObjectAreaEnd() - free_start);
2398 } 2401 }
2399 } 2402 }
2400 2403
2401 2404
2402 void MarkCompactCollector::SweepSpace(PagedSpace* space, 2405 void MarkCompactCollector::SweepSpace(PagedSpace* space,
2403 SweeperType sweeper) { 2406 SweeperType sweeper) {
2404 space->set_was_swept_conservatively(sweeper == CONSERVATIVE); 2407 space->set_was_swept_conservatively(sweeper == CONSERVATIVE);
2405 2408
2406 // We don't have a linear allocation area while sweeping. It will be restored
2407 // on the first allocation after the sweep.
2408 space->SetTop(NULL, NULL);
2409
2410 space->ClearStats(); 2409 space->ClearStats();
2411 2410
2412 PageIterator it(space); 2411 PageIterator it(space);
2413 2412
2414 // During sweeping of paged space we are trying to find longest sequences 2413 // During sweeping of paged space we are trying to find longest sequences
2415 // of pages without live objects and free them (instead of putting them on 2414 // of pages without live objects and free them (instead of putting them on
2416 // the free list). 2415 // the free list).
2417 2416
2418 // Page preceding current. 2417 // Page preceding current.
2419 Page* prev = Page::FromAddress(NULL); 2418 Page* prev = Page::FromAddress(NULL);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2536 } 2535 }
2537 2536
2538 2537
2539 void MarkCompactCollector::Initialize() { 2538 void MarkCompactCollector::Initialize() {
2540 StaticPointersToNewGenUpdatingVisitor::Initialize(); 2539 StaticPointersToNewGenUpdatingVisitor::Initialize();
2541 StaticMarkingVisitor::Initialize(); 2540 StaticMarkingVisitor::Initialize();
2542 } 2541 }
2543 2542
2544 2543
2545 } } // namespace v8::internal 2544 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698