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

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 2070 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 EmptyMarkingDeque(); 2081 EmptyMarkingDeque();
2082 while (marking_deque_.overflowed()) { 2082 while (marking_deque_.overflowed()) {
2083 RefillMarkingDeque(); 2083 RefillMarkingDeque();
2084 EmptyMarkingDeque(); 2084 EmptyMarkingDeque();
2085 } 2085 }
2086 } 2086 }
2087 2087
2088 2088
2089 // Mark all objects reachable (transitively) from objects on the marking 2089 // Mark all objects reachable (transitively) from objects on the marking
2090 // stack including references only considered in the atomic marking pause. 2090 // stack including references only considered in the atomic marking pause.
2091 void MarkCompactCollector::ProcessEphemeralMarking(ObjectVisitor* visitor) { 2091 void MarkCompactCollector::ProcessEphemeralMarking(
2092 ObjectVisitor* visitor, bool only_process_harmony_weak_collections) {
2092 bool work_to_do = true; 2093 bool work_to_do = true;
2093 DCHECK(marking_deque_.IsEmpty()); 2094 DCHECK(marking_deque_.IsEmpty());
2094 while (work_to_do) { 2095 while (work_to_do) {
2095 isolate()->global_handles()->IterateObjectGroups( 2096 if (!only_process_harmony_weak_collections) {
2096 visitor, &IsUnmarkedHeapObjectWithHeap); 2097 isolate()->global_handles()->IterateObjectGroups(
2097 MarkImplicitRefGroups(); 2098 visitor, &IsUnmarkedHeapObjectWithHeap);
2099 MarkImplicitRefGroups();
2100 }
2098 ProcessWeakCollections(); 2101 ProcessWeakCollections();
2099 work_to_do = !marking_deque_.IsEmpty(); 2102 work_to_do = !marking_deque_.IsEmpty();
2100 ProcessMarkingDeque(); 2103 ProcessMarkingDeque();
2101 } 2104 }
2102 } 2105 }
2103 2106
2104 2107
2105 void MarkCompactCollector::ProcessTopOptimizedFrame(ObjectVisitor* visitor) { 2108 void MarkCompactCollector::ProcessTopOptimizedFrame(ObjectVisitor* visitor) {
2106 for (StackFrameIterator it(isolate(), isolate()->thread_local_top()); 2109 for (StackFrameIterator it(isolate(), isolate()->thread_local_top());
2107 !it.done(); it.Advance()) { 2110 !it.done(); it.Advance()) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2215 } 2218 }
2216 2219
2217 RootMarkingVisitor root_visitor(heap()); 2220 RootMarkingVisitor root_visitor(heap());
2218 MarkRoots(&root_visitor); 2221 MarkRoots(&root_visitor);
2219 2222
2220 ProcessTopOptimizedFrame(&root_visitor); 2223 ProcessTopOptimizedFrame(&root_visitor);
2221 2224
2222 // The objects reachable from the roots are marked, yet unreachable 2225 // The objects reachable from the roots are marked, yet unreachable
2223 // objects are unmarked. Mark objects reachable due to host 2226 // objects are unmarked. Mark objects reachable due to host
2224 // application specific logic or through Harmony weak maps. 2227 // application specific logic or through Harmony weak maps.
2225 ProcessEphemeralMarking(&root_visitor); 2228 ProcessEphemeralMarking(&root_visitor, false);
2226 2229
2227 // The objects reachable from the roots, weak maps or object groups 2230 // The objects reachable from the roots, weak maps or object groups
2228 // are marked, yet unreachable objects are unmarked. Mark objects 2231 // are marked. Objects pointed to only by weak global handles cannot be
2229 // reachable only from weak global handles. 2232 // immediately reclaimed. Instead, we have to mark them as pending and mark
2233 // objects reachable from them.
2230 // 2234 //
2231 // First we identify nonlive weak handles and mark them as pending 2235 // First we identify nonlive weak handles and mark them as pending
2232 // destruction. 2236 // destruction.
2233 heap()->isolate()->global_handles()->IdentifyWeakHandles( 2237 heap()->isolate()->global_handles()->IdentifyWeakHandles(
2234 &IsUnmarkedHeapObject); 2238 &IsUnmarkedHeapObject);
2235 // Then we mark the objects and process the transitive closure. 2239 // Then we mark the objects.
2236 heap()->isolate()->global_handles()->IterateWeakRoots(&root_visitor); 2240 heap()->isolate()->global_handles()->IterateWeakRoots(&root_visitor);
2237 while (marking_deque_.overflowed()) {
2238 RefillMarkingDeque();
2239 EmptyMarkingDeque();
2240 }
2241 2241
2242 // Repeat host application specific and Harmony weak maps marking to 2242 // Repeat Harmony weak maps marking to mark unmarked objects reachable from
2243 // mark unmarked objects reachable from the weak roots. 2243 // the weak roots we just marked as pending destruction.
2244 ProcessEphemeralMarking(&root_visitor); 2244 //
2245 // We only process harmony collections, as all object groups have been fully
2246 // processed and no weakly reachable node can discover new objects groups.
2247 ProcessEphemeralMarking(&root_visitor, true);
2245 2248
2246 AfterMarking(); 2249 AfterMarking();
2247 2250
2248 if (FLAG_print_cumulative_gc_stat) { 2251 if (FLAG_print_cumulative_gc_stat) {
2249 heap_->tracer()->AddMarkingTime(base::OS::TimeCurrentMillis() - start_time); 2252 heap_->tracer()->AddMarkingTime(base::OS::TimeCurrentMillis() - start_time);
2250 } 2253 }
2251 } 2254 }
2252 2255
2253 2256
2254 void MarkCompactCollector::AfterMarking() { 2257 void MarkCompactCollector::AfterMarking() {
(...skipping 2177 matching lines...) Expand 10 before | Expand all | Expand 10 after
4432 SlotsBuffer* buffer = *buffer_address; 4435 SlotsBuffer* buffer = *buffer_address;
4433 while (buffer != NULL) { 4436 while (buffer != NULL) {
4434 SlotsBuffer* next_buffer = buffer->next(); 4437 SlotsBuffer* next_buffer = buffer->next();
4435 DeallocateBuffer(buffer); 4438 DeallocateBuffer(buffer);
4436 buffer = next_buffer; 4439 buffer = next_buffer;
4437 } 4440 }
4438 *buffer_address = NULL; 4441 *buffer_address = NULL;
4439 } 4442 }
4440 } 4443 }
4441 } // namespace v8::internal 4444 } // 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