OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/heap/mark-compact.h" | 5 #include "src/heap/mark-compact.h" |
6 | 6 |
7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/base/sys-info.h" | 9 #include "src/base/sys-info.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 | 1003 |
1004 candidate = next_candidate; | 1004 candidate = next_candidate; |
1005 } | 1005 } |
1006 | 1006 |
1007 shared_function_info_candidates_head_ = NULL; | 1007 shared_function_info_candidates_head_ = NULL; |
1008 } | 1008 } |
1009 | 1009 |
1010 | 1010 |
1011 void CodeFlusher::EvictCandidate(SharedFunctionInfo* shared_info) { | 1011 void CodeFlusher::EvictCandidate(SharedFunctionInfo* shared_info) { |
1012 // Make sure previous flushing decisions are revisited. | 1012 // Make sure previous flushing decisions are revisited. |
1013 isolate_->heap()->incremental_marking()->RecordWrites(shared_info); | 1013 isolate_->heap()->incremental_marking()->IterateBlackObject(shared_info); |
1014 | 1014 |
1015 if (FLAG_trace_code_flushing) { | 1015 if (FLAG_trace_code_flushing) { |
1016 PrintF("[code-flushing abandons function-info: "); | 1016 PrintF("[code-flushing abandons function-info: "); |
1017 shared_info->ShortPrint(); | 1017 shared_info->ShortPrint(); |
1018 PrintF("]\n"); | 1018 PrintF("]\n"); |
1019 } | 1019 } |
1020 | 1020 |
1021 SharedFunctionInfo* candidate = shared_function_info_candidates_head_; | 1021 SharedFunctionInfo* candidate = shared_function_info_candidates_head_; |
1022 SharedFunctionInfo* next_candidate; | 1022 SharedFunctionInfo* next_candidate; |
1023 if (candidate == shared_info) { | 1023 if (candidate == shared_info) { |
(...skipping 15 matching lines...) Expand all Loading... |
1039 } | 1039 } |
1040 } | 1040 } |
1041 } | 1041 } |
1042 | 1042 |
1043 | 1043 |
1044 void CodeFlusher::EvictCandidate(JSFunction* function) { | 1044 void CodeFlusher::EvictCandidate(JSFunction* function) { |
1045 DCHECK(!function->next_function_link()->IsUndefined()); | 1045 DCHECK(!function->next_function_link()->IsUndefined()); |
1046 Object* undefined = isolate_->heap()->undefined_value(); | 1046 Object* undefined = isolate_->heap()->undefined_value(); |
1047 | 1047 |
1048 // Make sure previous flushing decisions are revisited. | 1048 // Make sure previous flushing decisions are revisited. |
1049 isolate_->heap()->incremental_marking()->RecordWrites(function); | 1049 isolate_->heap()->incremental_marking()->IterateBlackObject(function); |
1050 isolate_->heap()->incremental_marking()->RecordWrites(function->shared()); | 1050 isolate_->heap()->incremental_marking()->IterateBlackObject( |
| 1051 function->shared()); |
1051 | 1052 |
1052 if (FLAG_trace_code_flushing) { | 1053 if (FLAG_trace_code_flushing) { |
1053 PrintF("[code-flushing abandons closure: "); | 1054 PrintF("[code-flushing abandons closure: "); |
1054 function->shared()->ShortPrint(); | 1055 function->shared()->ShortPrint(); |
1055 PrintF("]\n"); | 1056 PrintF("]\n"); |
1056 } | 1057 } |
1057 | 1058 |
1058 JSFunction* candidate = jsfunction_candidates_head_; | 1059 JSFunction* candidate = jsfunction_candidates_head_; |
1059 JSFunction* next_candidate; | 1060 JSFunction* next_candidate; |
1060 if (candidate == function) { | 1061 if (candidate == function) { |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 for (HeapObject* object = it->Next(); object != NULL; object = it->Next()) { | 1487 for (HeapObject* object = it->Next(); object != NULL; object = it->Next()) { |
1487 MarkBit markbit = Marking::MarkBitFrom(object); | 1488 MarkBit markbit = Marking::MarkBitFrom(object); |
1488 if ((object->map() != filler_map) && Marking::IsGrey(markbit)) { | 1489 if ((object->map() != filler_map) && Marking::IsGrey(markbit)) { |
1489 Marking::GreyToBlack(markbit); | 1490 Marking::GreyToBlack(markbit); |
1490 PushBlack(object); | 1491 PushBlack(object); |
1491 if (marking_deque()->IsFull()) return; | 1492 if (marking_deque()->IsFull()) return; |
1492 } | 1493 } |
1493 } | 1494 } |
1494 } | 1495 } |
1495 | 1496 |
1496 template <LiveObjectIterationMode T> | |
1497 void MarkCompactCollector::DiscoverGreyObjectsOnPage(MemoryChunk* p) { | 1497 void MarkCompactCollector::DiscoverGreyObjectsOnPage(MemoryChunk* p) { |
1498 DCHECK(!marking_deque()->IsFull()); | 1498 DCHECK(!marking_deque()->IsFull()); |
1499 DCHECK(T == kGreyObjects || T == kGreyObjectsOnBlackPage); | 1499 LiveObjectIterator<kGreyObjects> it(p); |
1500 LiveObjectIterator<T> it(p); | |
1501 HeapObject* object = NULL; | 1500 HeapObject* object = NULL; |
1502 while ((object = it.Next()) != NULL) { | 1501 while ((object = it.Next()) != NULL) { |
1503 MarkBit markbit = Marking::MarkBitFrom(object); | 1502 MarkBit markbit = Marking::MarkBitFrom(object); |
1504 DCHECK(Marking::IsGrey(markbit)); | 1503 DCHECK(Marking::IsGrey(markbit)); |
1505 Marking::GreyToBlack(markbit); | 1504 Marking::GreyToBlack(markbit); |
1506 PushBlack(object); | 1505 PushBlack(object); |
1507 if (marking_deque()->IsFull()) return; | 1506 if (marking_deque()->IsFull()) return; |
1508 } | 1507 } |
1509 } | 1508 } |
1510 | 1509 |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 } | 1769 } |
1771 return false; | 1770 return false; |
1772 } | 1771 } |
1773 }; | 1772 }; |
1774 | 1773 |
1775 | 1774 |
1776 void MarkCompactCollector::DiscoverGreyObjectsInSpace(PagedSpace* space) { | 1775 void MarkCompactCollector::DiscoverGreyObjectsInSpace(PagedSpace* space) { |
1777 PageIterator it(space); | 1776 PageIterator it(space); |
1778 while (it.has_next()) { | 1777 while (it.has_next()) { |
1779 Page* p = it.next(); | 1778 Page* p = it.next(); |
1780 if (p->IsFlagSet(Page::BLACK_PAGE)) { | 1779 if (!p->IsFlagSet(Page::BLACK_PAGE)) { |
1781 DiscoverGreyObjectsOnPage<kGreyObjectsOnBlackPage>(p); | 1780 DiscoverGreyObjectsOnPage(p); |
1782 } else { | |
1783 DiscoverGreyObjectsOnPage<kGreyObjects>(p); | |
1784 } | 1781 } |
1785 if (marking_deque()->IsFull()) return; | 1782 if (marking_deque()->IsFull()) return; |
1786 } | 1783 } |
1787 } | 1784 } |
1788 | 1785 |
1789 | 1786 |
1790 void MarkCompactCollector::DiscoverGreyObjectsInNewSpace() { | 1787 void MarkCompactCollector::DiscoverGreyObjectsInNewSpace() { |
1791 NewSpace* space = heap()->new_space(); | 1788 NewSpace* space = heap()->new_space(); |
1792 NewSpacePageIterator it(space->bottom(), space->top()); | 1789 NewSpacePageIterator it(space->bottom(), space->top()); |
1793 while (it.has_next()) { | 1790 while (it.has_next()) { |
1794 NewSpacePage* page = it.next(); | 1791 NewSpacePage* page = it.next(); |
1795 DiscoverGreyObjectsOnPage<kGreyObjects>(page); | 1792 DiscoverGreyObjectsOnPage(page); |
1796 if (marking_deque()->IsFull()) return; | 1793 if (marking_deque()->IsFull()) return; |
1797 } | 1794 } |
1798 } | 1795 } |
1799 | 1796 |
1800 | 1797 |
1801 bool MarkCompactCollector::IsUnmarkedHeapObject(Object** p) { | 1798 bool MarkCompactCollector::IsUnmarkedHeapObject(Object** p) { |
1802 Object* o = *p; | 1799 Object* o = *p; |
1803 if (!o->IsHeapObject()) return false; | 1800 if (!o->IsHeapObject()) return false; |
1804 HeapObject* heap_object = HeapObject::cast(o); | 1801 HeapObject* heap_object = HeapObject::cast(o); |
1805 MarkBit mark = Marking::MarkBitFrom(heap_object); | 1802 MarkBit mark = Marking::MarkBitFrom(heap_object); |
(...skipping 1985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3791 MarkBit mark_bit = Marking::MarkBitFrom(host); | 3788 MarkBit mark_bit = Marking::MarkBitFrom(host); |
3792 if (Marking::IsBlack(mark_bit)) { | 3789 if (Marking::IsBlack(mark_bit)) { |
3793 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); | 3790 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); |
3794 RecordRelocSlot(host, &rinfo, target); | 3791 RecordRelocSlot(host, &rinfo, target); |
3795 } | 3792 } |
3796 } | 3793 } |
3797 } | 3794 } |
3798 | 3795 |
3799 } // namespace internal | 3796 } // namespace internal |
3800 } // namespace v8 | 3797 } // namespace v8 |
OLD | NEW |