OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1922 marking_deque->PushBlack(object); | 1922 marking_deque->PushBlack(object); |
1923 if (marking_deque->IsFull()) return; | 1923 if (marking_deque->IsFull()) return; |
1924 } | 1924 } |
1925 } | 1925 } |
1926 } | 1926 } |
1927 | 1927 |
1928 | 1928 |
1929 static inline int MarkWordToObjectStarts(uint32_t mark_bits, int* starts); | 1929 static inline int MarkWordToObjectStarts(uint32_t mark_bits, int* starts); |
1930 | 1930 |
1931 | 1931 |
1932 static void DiscoverGreyObjectsOnPage(MarkingDeque* marking_deque, Page* p) { | 1932 static void DiscoverGreyObjectsOnPage(MarkingDeque* marking_deque, |
| 1933 MemoryChunk* p) { |
1933 ASSERT(!marking_deque->IsFull()); | 1934 ASSERT(!marking_deque->IsFull()); |
1934 ASSERT(strcmp(Marking::kWhiteBitPattern, "00") == 0); | 1935 ASSERT(strcmp(Marking::kWhiteBitPattern, "00") == 0); |
1935 ASSERT(strcmp(Marking::kBlackBitPattern, "10") == 0); | 1936 ASSERT(strcmp(Marking::kBlackBitPattern, "10") == 0); |
1936 ASSERT(strcmp(Marking::kGreyBitPattern, "11") == 0); | 1937 ASSERT(strcmp(Marking::kGreyBitPattern, "11") == 0); |
1937 ASSERT(strcmp(Marking::kImpossibleBitPattern, "01") == 0); | 1938 ASSERT(strcmp(Marking::kImpossibleBitPattern, "01") == 0); |
1938 | 1939 |
1939 MarkBit::CellType* cells = p->markbits()->cells(); | 1940 MarkBit::CellType* cells = p->markbits()->cells(); |
1940 | 1941 |
1941 int last_cell_index = | 1942 int last_cell_index = |
1942 Bitmap::IndexToCell( | 1943 Bitmap::IndexToCell( |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1996 PageIterator it(space); | 1997 PageIterator it(space); |
1997 while (it.has_next()) { | 1998 while (it.has_next()) { |
1998 Page* p = it.next(); | 1999 Page* p = it.next(); |
1999 DiscoverGreyObjectsOnPage(marking_deque, p); | 2000 DiscoverGreyObjectsOnPage(marking_deque, p); |
2000 if (marking_deque->IsFull()) return; | 2001 if (marking_deque->IsFull()) return; |
2001 } | 2002 } |
2002 } | 2003 } |
2003 } | 2004 } |
2004 | 2005 |
2005 | 2006 |
| 2007 static void DiscoverGreyObjectsInNewSpace(Heap* heap, |
| 2008 MarkingDeque* marking_deque) { |
| 2009 NewSpace* space = heap->new_space(); |
| 2010 NewSpacePageIterator it(space->bottom(), space->top()); |
| 2011 while (it.has_next()) { |
| 2012 NewSpacePage* page = it.next(); |
| 2013 DiscoverGreyObjectsOnPage(marking_deque, page); |
| 2014 if (marking_deque->IsFull()) return; |
| 2015 } |
| 2016 } |
| 2017 |
| 2018 |
2006 bool MarkCompactCollector::IsUnmarkedHeapObject(Object** p) { | 2019 bool MarkCompactCollector::IsUnmarkedHeapObject(Object** p) { |
2007 Object* o = *p; | 2020 Object* o = *p; |
2008 if (!o->IsHeapObject()) return false; | 2021 if (!o->IsHeapObject()) return false; |
2009 HeapObject* heap_object = HeapObject::cast(o); | 2022 HeapObject* heap_object = HeapObject::cast(o); |
2010 MarkBit mark = Marking::MarkBitFrom(heap_object); | 2023 MarkBit mark = Marking::MarkBitFrom(heap_object); |
2011 return !mark.Get(); | 2024 return !mark.Get(); |
2012 } | 2025 } |
2013 | 2026 |
2014 | 2027 |
2015 bool MarkCompactCollector::IsUnmarkedHeapObjectWithHeap(Heap* heap, | 2028 bool MarkCompactCollector::IsUnmarkedHeapObjectWithHeap(Heap* heap, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2102 | 2115 |
2103 | 2116 |
2104 // Sweep the heap for overflowed objects, clear their overflow bits, and | 2117 // Sweep the heap for overflowed objects, clear their overflow bits, and |
2105 // push them on the marking stack. Stop early if the marking stack fills | 2118 // push them on the marking stack. Stop early if the marking stack fills |
2106 // before sweeping completes. If sweeping completes, there are no remaining | 2119 // before sweeping completes. If sweeping completes, there are no remaining |
2107 // overflowed objects in the heap so the overflow flag on the markings stack | 2120 // overflowed objects in the heap so the overflow flag on the markings stack |
2108 // is cleared. | 2121 // is cleared. |
2109 void MarkCompactCollector::RefillMarkingDeque() { | 2122 void MarkCompactCollector::RefillMarkingDeque() { |
2110 ASSERT(marking_deque_.overflowed()); | 2123 ASSERT(marking_deque_.overflowed()); |
2111 | 2124 |
2112 SemiSpaceIterator new_it(heap()->new_space()); | 2125 DiscoverGreyObjectsInNewSpace(heap(), &marking_deque_); |
2113 DiscoverGreyObjectsWithIterator(heap(), &marking_deque_, &new_it); | |
2114 if (marking_deque_.IsFull()) return; | 2126 if (marking_deque_.IsFull()) return; |
2115 | 2127 |
2116 DiscoverGreyObjectsInSpace(heap(), | 2128 DiscoverGreyObjectsInSpace(heap(), |
2117 &marking_deque_, | 2129 &marking_deque_, |
2118 heap()->old_pointer_space()); | 2130 heap()->old_pointer_space()); |
2119 if (marking_deque_.IsFull()) return; | 2131 if (marking_deque_.IsFull()) return; |
2120 | 2132 |
2121 DiscoverGreyObjectsInSpace(heap(), | 2133 DiscoverGreyObjectsInSpace(heap(), |
2122 &marking_deque_, | 2134 &marking_deque_, |
2123 heap()->old_data_space()); | 2135 heap()->old_data_space()); |
(...skipping 2193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4317 while (buffer != NULL) { | 4329 while (buffer != NULL) { |
4318 SlotsBuffer* next_buffer = buffer->next(); | 4330 SlotsBuffer* next_buffer = buffer->next(); |
4319 DeallocateBuffer(buffer); | 4331 DeallocateBuffer(buffer); |
4320 buffer = next_buffer; | 4332 buffer = next_buffer; |
4321 } | 4333 } |
4322 *buffer_address = NULL; | 4334 *buffer_address = NULL; |
4323 } | 4335 } |
4324 | 4336 |
4325 | 4337 |
4326 } } // namespace v8::internal | 4338 } } // namespace v8::internal |
OLD | NEW |