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

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

Issue 997423002: Use the incremental root marking visitor for overapproximating the weak closure (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 9 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
« no previous file with comments | « src/heap/mark-compact.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 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/v8.h" 5 #include "src/v8.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/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/compilation-cache.h" 10 #include "src/compilation-cache.h"
(...skipping 1967 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 MarkStringTable(visitor); 1978 MarkStringTable(visitor);
1979 1979
1980 // There may be overflowed objects in the heap. Visit them now. 1980 // There may be overflowed objects in the heap. Visit them now.
1981 while (marking_deque_.overflowed()) { 1981 while (marking_deque_.overflowed()) {
1982 RefillMarkingDeque(); 1982 RefillMarkingDeque();
1983 EmptyMarkingDeque(); 1983 EmptyMarkingDeque();
1984 } 1984 }
1985 } 1985 }
1986 1986
1987 1987
1988 void MarkCompactCollector::MarkImplicitRefGroups() { 1988 void MarkCompactCollector::MarkImplicitRefGroups(
1989 MarkObjectFunction mark_object) {
1989 List<ImplicitRefGroup*>* ref_groups = 1990 List<ImplicitRefGroup*>* ref_groups =
1990 isolate()->global_handles()->implicit_ref_groups(); 1991 isolate()->global_handles()->implicit_ref_groups();
1991 1992
1992 int last = 0; 1993 int last = 0;
1993 for (int i = 0; i < ref_groups->length(); i++) { 1994 for (int i = 0; i < ref_groups->length(); i++) {
1994 ImplicitRefGroup* entry = ref_groups->at(i); 1995 ImplicitRefGroup* entry = ref_groups->at(i);
1995 DCHECK(entry != NULL); 1996 DCHECK(entry != NULL);
1996 1997
1997 if (!IsMarked(*entry->parent)) { 1998 if (!IsMarked(*entry->parent)) {
1998 (*ref_groups)[last++] = entry; 1999 (*ref_groups)[last++] = entry;
1999 continue; 2000 continue;
2000 } 2001 }
2001 2002
2002 Object*** children = entry->children; 2003 Object*** children = entry->children;
2003 // A parent object is marked, so mark all child heap objects. 2004 // A parent object is marked, so mark all child heap objects.
2004 for (size_t j = 0; j < entry->length; ++j) { 2005 for (size_t j = 0; j < entry->length; ++j) {
2005 if ((*children[j])->IsHeapObject()) { 2006 if ((*children[j])->IsHeapObject()) {
2006 HeapObject* child = HeapObject::cast(*children[j]); 2007 mark_object(heap(), HeapObject::cast(*children[j]));
2007 MarkBit mark = Marking::MarkBitFrom(child);
2008 MarkObject(child, mark);
2009 } 2008 }
2010 } 2009 }
2011 2010
2012 // Once the entire group has been marked, dispose it because it's 2011 // Once the entire group has been marked, dispose it because it's
2013 // not needed anymore. 2012 // not needed anymore.
2014 delete entry; 2013 delete entry;
2015 } 2014 }
2016 ref_groups->Rewind(last); 2015 ref_groups->Rewind(last);
2017 } 2016 }
2018 2017
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 // Mark all objects reachable (transitively) from objects on the marking 2096 // Mark all objects reachable (transitively) from objects on the marking
2098 // stack including references only considered in the atomic marking pause. 2097 // stack including references only considered in the atomic marking pause.
2099 void MarkCompactCollector::ProcessEphemeralMarking( 2098 void MarkCompactCollector::ProcessEphemeralMarking(
2100 ObjectVisitor* visitor, bool only_process_harmony_weak_collections) { 2099 ObjectVisitor* visitor, bool only_process_harmony_weak_collections) {
2101 bool work_to_do = true; 2100 bool work_to_do = true;
2102 DCHECK(marking_deque_.IsEmpty() && !marking_deque_.overflowed()); 2101 DCHECK(marking_deque_.IsEmpty() && !marking_deque_.overflowed());
2103 while (work_to_do) { 2102 while (work_to_do) {
2104 if (!only_process_harmony_weak_collections) { 2103 if (!only_process_harmony_weak_collections) {
2105 isolate()->global_handles()->IterateObjectGroups( 2104 isolate()->global_handles()->IterateObjectGroups(
2106 visitor, &IsUnmarkedHeapObjectWithHeap); 2105 visitor, &IsUnmarkedHeapObjectWithHeap);
2107 MarkImplicitRefGroups(); 2106 MarkImplicitRefGroups(&MarkCompactMarkingVisitor::MarkObject);
2108 } 2107 }
2109 ProcessWeakCollections(); 2108 ProcessWeakCollections();
2110 work_to_do = !marking_deque_.IsEmpty(); 2109 work_to_do = !marking_deque_.IsEmpty();
2111 ProcessMarkingDeque(); 2110 ProcessMarkingDeque();
2112 } 2111 }
2113 } 2112 }
2114 2113
2115 2114
2116 void MarkCompactCollector::ProcessTopOptimizedFrame(ObjectVisitor* visitor) { 2115 void MarkCompactCollector::ProcessTopOptimizedFrame(ObjectVisitor* visitor) {
2117 for (StackFrameIterator it(isolate(), isolate()->thread_local_top()); 2116 for (StackFrameIterator it(isolate(), isolate()->thread_local_top());
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
2217 if (marking_deque_memory_committed_) { 2216 if (marking_deque_memory_committed_) {
2218 bool success = marking_deque_memory_->Uncommit( 2217 bool success = marking_deque_memory_->Uncommit(
2219 reinterpret_cast<Address>(marking_deque_memory_->address()), 2218 reinterpret_cast<Address>(marking_deque_memory_->address()),
2220 marking_deque_memory_->size()); 2219 marking_deque_memory_->size());
2221 CHECK(success); 2220 CHECK(success);
2222 marking_deque_memory_committed_ = false; 2221 marking_deque_memory_committed_ = false;
2223 } 2222 }
2224 } 2223 }
2225 2224
2226 2225
2227 void MarkCompactCollector::OverApproximateWeakClosure() {
2228 GCTracer::Scope gc_scope(heap()->tracer(),
2229 GCTracer::Scope::MC_INCREMENTAL_WEAKCLOSURE);
2230
2231 RootMarkingVisitor root_visitor(heap());
2232 isolate()->global_handles()->IterateObjectGroups(
2233 &root_visitor, &IsUnmarkedHeapObjectWithHeap);
2234 MarkImplicitRefGroups();
2235
2236 // Remove object groups after marking phase.
2237 heap()->isolate()->global_handles()->RemoveObjectGroups();
2238 heap()->isolate()->global_handles()->RemoveImplicitRefGroups();
2239 }
2240
2241
2242 void MarkCompactCollector::MarkLiveObjects() { 2226 void MarkCompactCollector::MarkLiveObjects() {
2243 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_MARK); 2227 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_MARK);
2244 double start_time = 0.0; 2228 double start_time = 0.0;
2245 if (FLAG_print_cumulative_gc_stat) { 2229 if (FLAG_print_cumulative_gc_stat) {
2246 start_time = base::OS::TimeCurrentMillis(); 2230 start_time = base::OS::TimeCurrentMillis();
2247 } 2231 }
2248 // The recursive GC marker detects when it is nearing stack overflow, 2232 // The recursive GC marker detects when it is nearing stack overflow,
2249 // and switches to a different marking system. JS interrupts interfere 2233 // and switches to a different marking system. JS interrupts interfere
2250 // with the C stack limit check. 2234 // with the C stack limit check.
2251 PostponeInterruptsScope postpone(isolate()); 2235 PostponeInterruptsScope postpone(isolate());
(...skipping 2404 matching lines...) Expand 10 before | Expand all | Expand 10 after
4656 SlotsBuffer* buffer = *buffer_address; 4640 SlotsBuffer* buffer = *buffer_address;
4657 while (buffer != NULL) { 4641 while (buffer != NULL) {
4658 SlotsBuffer* next_buffer = buffer->next(); 4642 SlotsBuffer* next_buffer = buffer->next();
4659 DeallocateBuffer(buffer); 4643 DeallocateBuffer(buffer);
4660 buffer = next_buffer; 4644 buffer = next_buffer;
4661 } 4645 }
4662 *buffer_address = NULL; 4646 *buffer_address = NULL;
4663 } 4647 }
4664 } 4648 }
4665 } // namespace v8::internal 4649 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/mark-compact.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698