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

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

Issue 794583003: Retain maps for several garbage collections (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
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 2105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2116 if (!code->CanDeoptAt(it.frame()->pc())) { 2116 if (!code->CanDeoptAt(it.frame()->pc())) {
2117 code->CodeIterateBody(visitor); 2117 code->CodeIterateBody(visitor);
2118 } 2118 }
2119 ProcessMarkingDeque(); 2119 ProcessMarkingDeque();
2120 return; 2120 return;
2121 } 2121 }
2122 } 2122 }
2123 } 2123 }
2124 2124
2125 2125
2126 void MarkCompactCollector::RetainMaps(ObjectVisitor* visitor) {
2127 if (reduce_memory_footprint_ || abort_incremental_marking_ ||
Hannes Payer (out of office) 2014/12/16 17:15:35 Why do you bail out for abort_incremental_marking_
ulan 2014/12/17 11:13:34 The incremental marking is aborted for GC requeste
2128 FLAG_retain_maps_for_n_gc == 0) {
2129 return;
2130 }
2131
2132 HeapObjectIterator map_iterator(heap()->map_space());
2133 // The retaining counter goes from Map::kRetainingCounterStart
2134 // down to Map::kRetainingCounterStart. This range can be narrowed
Erik Corry 2014/12/16 16:16:32 Comment looks wrong.
ulan 2014/12/16 16:35:23 Thanks, that should be "down to Map::kRetainingCou
ulan 2014/12/17 11:13:34 Done.
2135 // by the FLAG_retain_maps_for_n_gc flag.
2136 int retaining_counter_end =
2137 Max(Map::kRetainingCounterEnd,
2138 Map::kRetainingCounterStart - FLAG_retain_maps_for_n_gc);
2139 for (HeapObject* obj = map_iterator.Next(); obj != NULL;
2140 obj = map_iterator.Next()) {
2141 Map* map = Map::cast(obj);
2142 MarkBit map_mark = Marking::MarkBitFrom(map);
2143 int counter = map->counter();
2144 if (!map_mark.Get()) {
2145 if (counter > Map::kRetainingCounterStart ||
2146 counter <= retaining_counter_end) {
2147 // The counter is outside of retaining range. Do not retain this map.
2148 continue;
2149 }
2150 HeapObject* constructor = HeapObject::cast(map->constructor());
2151 if (!Marking::MarkBitFrom(constructor).Get()) {
2152 // The constructor is dead, no new objects with this map can
2153 // be created. Do not retain this map.
2154 continue;
2155 }
2156 map->set_counter(counter - 1);
2157 SetMark(map, map_mark);
2158 MarkCompactMarkingVisitor::IterateBody(map->map(), map);
2159 ProcessMarkingDeque();
Erik Corry 2014/12/16 16:52:48 Can't we just process the marking deque at the end
ulan 2014/12/16 16:54:36 Good point, I will move it to the end.
ulan 2014/12/17 11:13:34 Done.
2160 } else {
2161 if (counter < Map::kRetainingCounterStart) {
Hannes Payer (out of office) 2014/12/16 17:15:35 else if
ulan 2014/12/17 11:13:34 Done.
2162 // Reset the counter for live maps.
2163 map->set_counter(Map::kRetainingCounterStart);
2164 }
2165 }
2166 }
2167 }
2168
2169
2126 void MarkCompactCollector::EnsureMarkingDequeIsCommittedAndInitialize() { 2170 void MarkCompactCollector::EnsureMarkingDequeIsCommittedAndInitialize() {
2127 if (marking_deque_memory_ == NULL) { 2171 if (marking_deque_memory_ == NULL) {
2128 marking_deque_memory_ = new base::VirtualMemory(4 * MB); 2172 marking_deque_memory_ = new base::VirtualMemory(4 * MB);
2129 } 2173 }
2130 if (!marking_deque_memory_committed_) { 2174 if (!marking_deque_memory_committed_) {
2131 bool success = marking_deque_memory_->Commit( 2175 bool success = marking_deque_memory_->Commit(
2132 reinterpret_cast<Address>(marking_deque_memory_->address()), 2176 reinterpret_cast<Address>(marking_deque_memory_->address()),
2133 marking_deque_memory_->size(), 2177 marking_deque_memory_->size(),
2134 false); // Not executable. 2178 false); // Not executable.
2135 CHECK(success); 2179 CHECK(success);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2215 } 2259 }
2216 } 2260 }
2217 } 2261 }
2218 } 2262 }
2219 2263
2220 RootMarkingVisitor root_visitor(heap()); 2264 RootMarkingVisitor root_visitor(heap());
2221 MarkRoots(&root_visitor); 2265 MarkRoots(&root_visitor);
2222 2266
2223 ProcessTopOptimizedFrame(&root_visitor); 2267 ProcessTopOptimizedFrame(&root_visitor);
2224 2268
2269 RetainMaps(&root_visitor);
Erik Corry 2014/12/16 16:16:33 This should be after the ephemeral stuff. Maps th
ulan 2014/12/16 16:35:23 It should not be after ephemeral marking, because
Erik Corry 2014/12/16 16:52:48 OK that makes sense in a sort of sad way.
Hannes Payer (out of office) 2014/12/16 17:15:35 Please write a comment about that somewhere.
ulan 2014/12/17 11:13:34 Done.
2270
2225 { 2271 {
2226 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_WEAKCLOSURE); 2272 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_WEAKCLOSURE);
2227 2273
2228 // The objects reachable from the roots are marked, yet unreachable 2274 // The objects reachable from the roots are marked, yet unreachable
2229 // objects are unmarked. Mark objects reachable due to host 2275 // objects are unmarked. Mark objects reachable due to host
2230 // application specific logic or through Harmony weak maps. 2276 // application specific logic or through Harmony weak maps.
2231 ProcessEphemeralMarking(&root_visitor, false); 2277 ProcessEphemeralMarking(&root_visitor, false);
2232 2278
2233 // The objects reachable from the roots, weak maps or object groups 2279 // The objects reachable from the roots, weak maps or object groups
2234 // are marked. Objects pointed to only by weak global handles cannot be 2280 // are marked. Objects pointed to only by weak global handles cannot be
(...skipping 2205 matching lines...) Expand 10 before | Expand all | Expand 10 after
4440 SlotsBuffer* buffer = *buffer_address; 4486 SlotsBuffer* buffer = *buffer_address;
4441 while (buffer != NULL) { 4487 while (buffer != NULL) {
4442 SlotsBuffer* next_buffer = buffer->next(); 4488 SlotsBuffer* next_buffer = buffer->next();
4443 DeallocateBuffer(buffer); 4489 DeallocateBuffer(buffer);
4444 buffer = next_buffer; 4490 buffer = next_buffer;
4445 } 4491 }
4446 *buffer_address = NULL; 4492 *buffer_address = NULL;
4447 } 4493 }
4448 } 4494 }
4449 } // namespace v8::internal 4495 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/mark-compact.h ('k') | test/cctest/test-api.cc » ('j') | test/cctest/test-heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698