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

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

Issue 761343004: After moving unreachable weak global handles only process harmony collections (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 6 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
« no previous file with comments | « src/heap/mark-compact.h ('k') | test/cctest/test-api.cc » ('j') | 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 2060 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 EmptyMarkingDeque(); 2071 EmptyMarkingDeque();
2072 while (marking_deque_.overflowed()) { 2072 while (marking_deque_.overflowed()) {
2073 RefillMarkingDeque(); 2073 RefillMarkingDeque();
2074 EmptyMarkingDeque(); 2074 EmptyMarkingDeque();
2075 } 2075 }
2076 } 2076 }
2077 2077
2078 2078
2079 // Mark all objects reachable (transitively) from objects on the marking 2079 // Mark all objects reachable (transitively) from objects on the marking
2080 // stack including references only considered in the atomic marking pause. 2080 // stack including references only considered in the atomic marking pause.
2081 void MarkCompactCollector::ProcessEphemeralMarking(ObjectVisitor* visitor) { 2081 void MarkCompactCollector::ProcessEphemeralMarking(
2082 ObjectVisitor* visitor, bool only_process_harmony_weak_collections) {
2082 bool work_to_do = true; 2083 bool work_to_do = true;
2083 DCHECK(marking_deque_.IsEmpty()); 2084 DCHECK(marking_deque_.IsEmpty());
2084 while (work_to_do) { 2085 while (work_to_do) {
2085 isolate()->global_handles()->IterateObjectGroups( 2086 if (!only_process_harmony_weak_collections) {
2086 visitor, &IsUnmarkedHeapObjectWithHeap); 2087 isolate()->global_handles()->IterateObjectGroups(
2087 MarkImplicitRefGroups(); 2088 visitor, &IsUnmarkedHeapObjectWithHeap);
2089 MarkImplicitRefGroups();
2090 }
2088 ProcessWeakCollections(); 2091 ProcessWeakCollections();
2089 work_to_do = !marking_deque_.IsEmpty(); 2092 work_to_do = !marking_deque_.IsEmpty();
2090 ProcessMarkingDeque(); 2093 ProcessMarkingDeque();
2091 } 2094 }
2092 } 2095 }
2093 2096
2094 2097
2095 void MarkCompactCollector::ProcessTopOptimizedFrame(ObjectVisitor* visitor) { 2098 void MarkCompactCollector::ProcessTopOptimizedFrame(ObjectVisitor* visitor) {
2096 for (StackFrameIterator it(isolate(), isolate()->thread_local_top()); 2099 for (StackFrameIterator it(isolate(), isolate()->thread_local_top());
2097 !it.done(); it.Advance()) { 2100 !it.done(); it.Advance()) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2189 } 2192 }
2190 2193
2191 RootMarkingVisitor root_visitor(heap()); 2194 RootMarkingVisitor root_visitor(heap());
2192 MarkRoots(&root_visitor); 2195 MarkRoots(&root_visitor);
2193 2196
2194 ProcessTopOptimizedFrame(&root_visitor); 2197 ProcessTopOptimizedFrame(&root_visitor);
2195 2198
2196 // The objects reachable from the roots are marked, yet unreachable 2199 // The objects reachable from the roots are marked, yet unreachable
2197 // objects are unmarked. Mark objects reachable due to host 2200 // objects are unmarked. Mark objects reachable due to host
2198 // application specific logic or through Harmony weak maps. 2201 // application specific logic or through Harmony weak maps.
2199 ProcessEphemeralMarking(&root_visitor); 2202 ProcessEphemeralMarking(&root_visitor, false);
2200 2203
2201 // The objects reachable from the roots, weak maps or object groups 2204 // The objects reachable from the roots, weak maps or object groups
2202 // are marked, yet unreachable objects are unmarked. Mark objects 2205 // are marked. Objects pointed to only by weak global handles cannot be
2206 // immediately reclaimed. Instead, we have to mark them as pending and mark
2207 // objects reachable from them.
2203 // reachable only from weak global handles. 2208 // reachable only from weak global handles.
Michael Starzinger 2014/12/02 10:22:42 nit: This dangling part of the sentence looks like
jochen (gone - plz use gerrit) 2014/12/02 10:37:18 done
2204 // 2209 //
2205 // First we identify nonlive weak handles and mark them as pending 2210 // First we identify nonlive weak handles and mark them as pending
2206 // destruction. 2211 // destruction.
2207 heap()->isolate()->global_handles()->IdentifyWeakHandles( 2212 heap()->isolate()->global_handles()->IdentifyWeakHandles(
2208 &IsUnmarkedHeapObject); 2213 &IsUnmarkedHeapObject);
2209 // Then we mark the objects and process the transitive closure. 2214 // Then we mark the objects.
2210 heap()->isolate()->global_handles()->IterateWeakRoots(&root_visitor); 2215 heap()->isolate()->global_handles()->IterateWeakRoots(&root_visitor);
2211 while (marking_deque_.overflowed()) {
2212 RefillMarkingDeque();
2213 EmptyMarkingDeque();
2214 }
2215 2216
2216 // Repeat host application specific and Harmony weak maps marking to 2217 // Repeat Harmony weak maps marking to mark unmarked objects reachable from
2217 // mark unmarked objects reachable from the weak roots. 2218 // the weak roots we just marked as pending destruction.
Michael Starzinger 2014/12/02 10:22:42 This requires more explanation as to why we can sk
jochen (gone - plz use gerrit) 2014/12/02 10:37:18 done
2218 ProcessEphemeralMarking(&root_visitor); 2219 ProcessEphemeralMarking(&root_visitor, true);
2219 2220
2220 AfterMarking(); 2221 AfterMarking();
2221 2222
2222 if (FLAG_print_cumulative_gc_stat) { 2223 if (FLAG_print_cumulative_gc_stat) {
2223 heap_->tracer()->AddMarkingTime(base::OS::TimeCurrentMillis() - start_time); 2224 heap_->tracer()->AddMarkingTime(base::OS::TimeCurrentMillis() - start_time);
2224 } 2225 }
2225 } 2226 }
2226 2227
2227 2228
2228 void MarkCompactCollector::AfterMarking() { 2229 void MarkCompactCollector::AfterMarking() {
(...skipping 2177 matching lines...) Expand 10 before | Expand all | Expand 10 after
4406 SlotsBuffer* buffer = *buffer_address; 4407 SlotsBuffer* buffer = *buffer_address;
4407 while (buffer != NULL) { 4408 while (buffer != NULL) {
4408 SlotsBuffer* next_buffer = buffer->next(); 4409 SlotsBuffer* next_buffer = buffer->next();
4409 DeallocateBuffer(buffer); 4410 DeallocateBuffer(buffer);
4410 buffer = next_buffer; 4411 buffer = next_buffer;
4411 } 4412 }
4412 *buffer_address = NULL; 4413 *buffer_address = NULL;
4413 } 4414 }
4414 } 4415 }
4415 } // namespace v8::internal 4416 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/mark-compact.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698