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

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: Rebase 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 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_ ||
2128 FLAG_retain_maps_for_n_gc == 0) {
2129 // Do not retain dead maps if flag disables it or there is
2130 // - memory pressure (reduce_memory_footprint_),
2131 // - GC is requested by tests or dev-tools (abort_incremental_marking_).
2132 return;
2133 }
2134
2135 HeapObjectIterator map_iterator(heap()->map_space());
2136 // The retaining counter goes from Map::kRetainingCounterStart
2137 // down to Map::kRetainingCounterEnd. This range can be narrowed
2138 // by the FLAG_retain_maps_for_n_gc flag.
2139 int retaining_counter_end =
2140 Max(Map::kRetainingCounterEnd,
2141 Map::kRetainingCounterStart - FLAG_retain_maps_for_n_gc);
2142 for (HeapObject* obj = map_iterator.Next(); obj != NULL;
2143 obj = map_iterator.Next()) {
2144 Map* map = Map::cast(obj);
2145 MarkBit map_mark = Marking::MarkBitFrom(map);
2146 int counter = map->counter();
2147 if (!map_mark.Get()) {
2148 if (counter > Map::kRetainingCounterStart ||
2149 counter <= retaining_counter_end) {
2150 // The counter is outside of retaining range. Do not retain this map.
2151 continue;
2152 }
2153 Object* constructor = map->constructor();
2154 if (!constructor->IsHeapObject() ||
2155 !Marking::MarkBitFrom(HeapObject::cast(constructor)).Get()) {
2156 // The constructor is dead, no new objects with this map can
2157 // be created. Do not retain this map.
2158 continue;
2159 }
2160 map->set_counter(counter - 1);
2161 SetMark(map, map_mark);
2162 MarkCompactMarkingVisitor::IterateBody(map->map(), map);
2163 } else if (counter < Map::kRetainingCounterStart) {
2164 // Reset the counter for live maps.
2165 map->set_counter(Map::kRetainingCounterStart);
2166 }
2167 }
2168 ProcessMarkingDeque();
2169 }
2170
2171
2126 void MarkCompactCollector::EnsureMarkingDequeIsCommittedAndInitialize() { 2172 void MarkCompactCollector::EnsureMarkingDequeIsCommittedAndInitialize() {
2127 if (marking_deque_memory_ == NULL) { 2173 if (marking_deque_memory_ == NULL) {
2128 marking_deque_memory_ = new base::VirtualMemory(4 * MB); 2174 marking_deque_memory_ = new base::VirtualMemory(4 * MB);
2129 } 2175 }
2130 if (!marking_deque_memory_committed_) { 2176 if (!marking_deque_memory_committed_) {
2131 bool success = marking_deque_memory_->Commit( 2177 bool success = marking_deque_memory_->Commit(
2132 reinterpret_cast<Address>(marking_deque_memory_->address()), 2178 reinterpret_cast<Address>(marking_deque_memory_->address()),
2133 marking_deque_memory_->size(), 2179 marking_deque_memory_->size(),
2134 false); // Not executable. 2180 false); // Not executable.
2135 CHECK(success); 2181 CHECK(success);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2215 } 2261 }
2216 } 2262 }
2217 } 2263 }
2218 } 2264 }
2219 2265
2220 RootMarkingVisitor root_visitor(heap()); 2266 RootMarkingVisitor root_visitor(heap());
2221 MarkRoots(&root_visitor); 2267 MarkRoots(&root_visitor);
2222 2268
2223 ProcessTopOptimizedFrame(&root_visitor); 2269 ProcessTopOptimizedFrame(&root_visitor);
2224 2270
2271 // Retaining dying maps should happen before or during ephemeral marking
2272 // because a map could keep the key of an ephemeron alive. Note that map
2273 // aging is imprecise: maps that are kept alive only by ephemerons will age.
2274 RetainMaps(&root_visitor);
2275
2225 { 2276 {
2226 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_WEAKCLOSURE); 2277 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_WEAKCLOSURE);
2227 2278
2228 // The objects reachable from the roots are marked, yet unreachable 2279 // The objects reachable from the roots are marked, yet unreachable
2229 // objects are unmarked. Mark objects reachable due to host 2280 // objects are unmarked. Mark objects reachable due to host
2230 // application specific logic or through Harmony weak maps. 2281 // application specific logic or through Harmony weak maps.
2231 ProcessEphemeralMarking(&root_visitor, false); 2282 ProcessEphemeralMarking(&root_visitor, false);
2232 2283
2233 // The objects reachable from the roots, weak maps or object groups 2284 // The objects reachable from the roots, weak maps or object groups
2234 // are marked. Objects pointed to only by weak global handles cannot be 2285 // 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; 4491 SlotsBuffer* buffer = *buffer_address;
4441 while (buffer != NULL) { 4492 while (buffer != NULL) {
4442 SlotsBuffer* next_buffer = buffer->next(); 4493 SlotsBuffer* next_buffer = buffer->next();
4443 DeallocateBuffer(buffer); 4494 DeallocateBuffer(buffer);
4444 buffer = next_buffer; 4495 buffer = next_buffer;
4445 } 4496 }
4446 *buffer_address = NULL; 4497 *buffer_address = NULL;
4447 } 4498 }
4448 } 4499 }
4449 } // namespace v8::internal 4500 } // 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