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

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

Issue 1411713004: [heap] Add detailed timers to --trace-gc-nvp MC marking phase. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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
« src/heap/gc-tracer.h ('K') | « src/heap/gc-tracer.cc ('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/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 2089 matching lines...) Expand 10 before | Expand all | Expand 10 after
2100 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_MARK); 2100 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_MARK);
2101 double start_time = 0.0; 2101 double start_time = 0.0;
2102 if (FLAG_print_cumulative_gc_stat) { 2102 if (FLAG_print_cumulative_gc_stat) {
2103 start_time = base::OS::TimeCurrentMillis(); 2103 start_time = base::OS::TimeCurrentMillis();
2104 } 2104 }
2105 // The recursive GC marker detects when it is nearing stack overflow, 2105 // The recursive GC marker detects when it is nearing stack overflow,
2106 // and switches to a different marking system. JS interrupts interfere 2106 // and switches to a different marking system. JS interrupts interfere
2107 // with the C stack limit check. 2107 // with the C stack limit check.
2108 PostponeInterruptsScope postpone(isolate()); 2108 PostponeInterruptsScope postpone(isolate());
2109 2109
2110 IncrementalMarking* incremental_marking = heap_->incremental_marking(); 2110 {
2111 if (was_marked_incrementally_) { 2111 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_MARK_INC);
2112 incremental_marking->Finalize(); 2112 IncrementalMarking* incremental_marking = heap_->incremental_marking();
2113 } else { 2113 if (was_marked_incrementally_) {
2114 // Abort any pending incremental activities e.g. incremental sweeping. 2114 incremental_marking->Finalize();
2115 incremental_marking->Stop(); 2115 } else {
2116 if (marking_deque_.in_use()) { 2116 // Abort any pending incremental activities e.g. incremental sweeping.
2117 marking_deque_.Uninitialize(true); 2117 incremental_marking->Stop();
2118 if (marking_deque_.in_use()) {
2119 marking_deque_.Uninitialize(true);
2120 }
2118 } 2121 }
2119 } 2122 }
2120 2123
2121 #ifdef DEBUG 2124 #ifdef DEBUG
2122 DCHECK(state_ == PREPARE_GC); 2125 DCHECK(state_ == PREPARE_GC);
2123 state_ = MARK_LIVE_OBJECTS; 2126 state_ = MARK_LIVE_OBJECTS;
2124 #endif 2127 #endif
2125 2128
2126 EnsureMarkingDequeIsCommittedAndInitialize( 2129 EnsureMarkingDequeIsCommittedAndInitialize(
2127 MarkCompactCollector::kMaxMarkingDequeSize); 2130 MarkCompactCollector::kMaxMarkingDequeSize);
2128 2131
2129 PrepareForCodeFlushing(); 2132 {
2133 GCTracer::Scope gc_scope(heap()->tracer(),
2134 GCTracer::Scope::MC_MARK_PREPCODEFLUSH);
2135 PrepareForCodeFlushing();
2136 }
2130 2137
2131 RootMarkingVisitor root_visitor(heap()); 2138 RootMarkingVisitor root_visitor(heap());
2132 MarkRoots(&root_visitor);
2133 2139
2134 ProcessTopOptimizedFrame(&root_visitor); 2140 {
2141 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_MARK_ROOT);
2142 MarkRoots(&root_visitor);
2143 }
2144
2145 {
2146 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_MARK_TOPOPT);
2147 ProcessTopOptimizedFrame(&root_visitor);
2148 }
2135 2149
2136 // Retaining dying maps should happen before or during ephemeral marking 2150 // Retaining dying maps should happen before or during ephemeral marking
2137 // because a map could keep the key of an ephemeron alive. Note that map 2151 // because a map could keep the key of an ephemeron alive. Note that map
2138 // aging is imprecise: maps that are kept alive only by ephemerons will age. 2152 // aging is imprecise: maps that are kept alive only by ephemerons will age.
2139 RetainMaps(); 2153 {
2154 GCTracer::Scope gc_scope(heap()->tracer(),
2155 GCTracer::Scope::MC_MARK_RETAINMAPS);
2156 RetainMaps();
2157 }
2140 2158
2141 { 2159 {
2142 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_WEAKCLOSURE); 2160 GCTracer::Scope gc_scope(heap()->tracer(),
2161 GCTracer::Scope::MC_MARK_WEAKCLOSURE);
2143 2162
2144 // The objects reachable from the roots are marked, yet unreachable 2163 // The objects reachable from the roots are marked, yet unreachable
2145 // objects are unmarked. Mark objects reachable due to host 2164 // objects are unmarked. Mark objects reachable due to host
2146 // application specific logic or through Harmony weak maps. 2165 // application specific logic or through Harmony weak maps.
2147 ProcessEphemeralMarking(&root_visitor, false); 2166 ProcessEphemeralMarking(&root_visitor, false);
2148 2167
2149 // The objects reachable from the roots, weak maps or object groups 2168 // The objects reachable from the roots, weak maps or object groups
2150 // are marked. Objects pointed to only by weak global handles cannot be 2169 // are marked. Objects pointed to only by weak global handles cannot be
2151 // immediately reclaimed. Instead, we have to mark them as pending and mark 2170 // immediately reclaimed. Instead, we have to mark them as pending and mark
2152 // objects reachable from them. 2171 // objects reachable from them.
(...skipping 16 matching lines...) Expand all
2169 2188
2170 AfterMarking(); 2189 AfterMarking();
2171 2190
2172 if (FLAG_print_cumulative_gc_stat) { 2191 if (FLAG_print_cumulative_gc_stat) {
2173 heap_->tracer()->AddMarkingTime(base::OS::TimeCurrentMillis() - start_time); 2192 heap_->tracer()->AddMarkingTime(base::OS::TimeCurrentMillis() - start_time);
2174 } 2193 }
2175 } 2194 }
2176 2195
2177 2196
2178 void MarkCompactCollector::AfterMarking() { 2197 void MarkCompactCollector::AfterMarking() {
2179 // Prune the string table removing all strings only pointed to by the 2198 {
2180 // string table. Cannot use string_table() here because the string 2199 GCTracer::Scope gc_scope(heap()->tracer(),
2181 // table is marked. 2200 GCTracer::Scope::MC_MARK_STRINGTABLE);
2182 StringTable* string_table = heap()->string_table();
2183 InternalizedStringTableCleaner internalized_visitor(heap());
2184 string_table->IterateElements(&internalized_visitor);
2185 string_table->ElementsRemoved(internalized_visitor.PointersRemoved());
2186 2201
2187 ExternalStringTableCleaner external_visitor(heap()); 2202 // Prune the string table removing all strings only pointed to by the
2188 heap()->external_string_table_.Iterate(&external_visitor); 2203 // string table. Cannot use string_table() here because the string
2189 heap()->external_string_table_.CleanUp(); 2204 // table is marked.
2205 StringTable* string_table = heap()->string_table();
2206 InternalizedStringTableCleaner internalized_visitor(heap());
2207 string_table->IterateElements(&internalized_visitor);
2208 string_table->ElementsRemoved(internalized_visitor.PointersRemoved());
2190 2209
2191 // Process the weak references. 2210 ExternalStringTableCleaner external_visitor(heap());
2192 MarkCompactWeakObjectRetainer mark_compact_object_retainer; 2211 heap()->external_string_table_.Iterate(&external_visitor);
2193 heap()->ProcessAllWeakReferences(&mark_compact_object_retainer); 2212 heap()->external_string_table_.CleanUp();
2213 }
2194 2214
2195 // Remove object groups after marking phase. 2215 {
2196 heap()->isolate()->global_handles()->RemoveObjectGroups(); 2216 GCTracer::Scope gc_scope(heap()->tracer(),
2197 heap()->isolate()->global_handles()->RemoveImplicitRefGroups(); 2217 GCTracer::Scope::MC_MARK_WEAKREFS);
2218
2219 // Process the weak references.
2220 MarkCompactWeakObjectRetainer mark_compact_object_retainer;
2221 heap()->ProcessAllWeakReferences(&mark_compact_object_retainer);
2222 }
2223
2224 {
2225 GCTracer::Scope gc_scope(heap()->tracer(),
2226 GCTracer::Scope::MC_MARK_GLOBALHANDLES);
2227
2228 // Remove object groups after marking phase.
2229 heap()->isolate()->global_handles()->RemoveObjectGroups();
2230 heap()->isolate()->global_handles()->RemoveImplicitRefGroups();
2231 }
2198 2232
2199 // Flush code from collected candidates. 2233 // Flush code from collected candidates.
2200 if (is_code_flushing_enabled()) { 2234 if (is_code_flushing_enabled()) {
2235 GCTracer::Scope gc_scope(heap()->tracer(),
2236 GCTracer::Scope::MC_MARK_CODEFLUSH);
2201 code_flusher_->ProcessCandidates(); 2237 code_flusher_->ProcessCandidates();
2202 } 2238 }
2203 2239
2204 if (FLAG_track_gc_object_stats) { 2240 if (FLAG_track_gc_object_stats) {
2205 if (FLAG_trace_gc_object_stats) { 2241 if (FLAG_trace_gc_object_stats) {
2206 heap()->object_stats_->TraceObjectStats(); 2242 heap()->object_stats_->TraceObjectStats();
2207 } 2243 }
2208 heap()->object_stats_->CheckpointObjectStats(); 2244 heap()->object_stats_->CheckpointObjectStats();
2209 } 2245 }
2210 } 2246 }
(...skipping 2391 matching lines...) Expand 10 before | Expand all | Expand 10 after
4602 MarkBit mark_bit = Marking::MarkBitFrom(host); 4638 MarkBit mark_bit = Marking::MarkBitFrom(host);
4603 if (Marking::IsBlack(mark_bit)) { 4639 if (Marking::IsBlack(mark_bit)) {
4604 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); 4640 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host);
4605 RecordRelocSlot(&rinfo, target); 4641 RecordRelocSlot(&rinfo, target);
4606 } 4642 }
4607 } 4643 }
4608 } 4644 }
4609 4645
4610 } // namespace internal 4646 } // namespace internal
4611 } // namespace v8 4647 } // namespace v8
OLDNEW
« src/heap/gc-tracer.h ('K') | « src/heap/gc-tracer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698