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

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

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