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 712943002: MapCache simplification. It is now a FixedArray that maps number of properties to a WeakCell with... (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/heap/mark-compact.h ('k') | src/objects.h » ('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 2214 matching lines...) Expand 10 before | Expand all | Expand 10 after
2225 2225
2226 AfterMarking(); 2226 AfterMarking();
2227 2227
2228 if (FLAG_print_cumulative_gc_stat) { 2228 if (FLAG_print_cumulative_gc_stat) {
2229 heap_->tracer()->AddMarkingTime(base::OS::TimeCurrentMillis() - start_time); 2229 heap_->tracer()->AddMarkingTime(base::OS::TimeCurrentMillis() - start_time);
2230 } 2230 }
2231 } 2231 }
2232 2232
2233 2233
2234 void MarkCompactCollector::AfterMarking() { 2234 void MarkCompactCollector::AfterMarking() {
2235 // Object literal map caches reference strings (cache keys) and maps
2236 // (cache values). At this point still useful maps have already been
2237 // marked. Mark the keys for the alive values before we process the
2238 // string table.
2239 ProcessMapCaches();
2240
2241 // Prune the string table removing all strings only pointed to by the 2235 // Prune the string table removing all strings only pointed to by the
2242 // string table. Cannot use string_table() here because the string 2236 // string table. Cannot use string_table() here because the string
2243 // table is marked. 2237 // table is marked.
2244 StringTable* string_table = heap()->string_table(); 2238 StringTable* string_table = heap()->string_table();
2245 InternalizedStringTableCleaner internalized_visitor(heap()); 2239 InternalizedStringTableCleaner internalized_visitor(heap());
2246 string_table->IterateElements(&internalized_visitor); 2240 string_table->IterateElements(&internalized_visitor);
2247 string_table->ElementsRemoved(internalized_visitor.PointersRemoved()); 2241 string_table->ElementsRemoved(internalized_visitor.PointersRemoved());
2248 2242
2249 ExternalStringTableCleaner external_visitor(heap()); 2243 ExternalStringTableCleaner external_visitor(heap());
2250 heap()->external_string_table_.Iterate(&external_visitor); 2244 heap()->external_string_table_.Iterate(&external_visitor);
(...skipping 16 matching lines...) Expand all
2267 EnableCodeFlushing(false); 2261 EnableCodeFlushing(false);
2268 } 2262 }
2269 } 2263 }
2270 2264
2271 if (FLAG_track_gc_object_stats) { 2265 if (FLAG_track_gc_object_stats) {
2272 heap()->CheckpointObjectStats(); 2266 heap()->CheckpointObjectStats();
2273 } 2267 }
2274 } 2268 }
2275 2269
2276 2270
2277 void MarkCompactCollector::ProcessMapCaches() {
2278 Object* raw_context = heap()->native_contexts_list();
2279 while (raw_context != heap()->undefined_value()) {
2280 Context* context = reinterpret_cast<Context*>(raw_context);
2281 if (IsMarked(context)) {
2282 HeapObject* raw_map_cache =
2283 HeapObject::cast(context->get(Context::MAP_CACHE_INDEX));
2284 // A map cache may be reachable from the stack. In this case
2285 // it's already transitively marked and it's too late to clean
2286 // up its parts.
2287 if (!IsMarked(raw_map_cache) &&
2288 raw_map_cache != heap()->undefined_value()) {
2289 MapCache* map_cache = reinterpret_cast<MapCache*>(raw_map_cache);
2290 int existing_elements = map_cache->NumberOfElements();
2291 int used_elements = 0;
2292 for (int i = MapCache::kElementsStartIndex; i < map_cache->length();
2293 i += MapCache::kEntrySize) {
2294 Object* raw_key = map_cache->get(i);
2295 if (raw_key == heap()->undefined_value() ||
2296 raw_key == heap()->the_hole_value())
2297 continue;
2298 STATIC_ASSERT(MapCache::kEntrySize == 2);
2299 Object* raw_map = map_cache->get(i + 1);
2300 if (raw_map->IsHeapObject() && IsMarked(raw_map)) {
2301 ++used_elements;
2302 } else {
2303 // Delete useless entries with unmarked maps.
2304 DCHECK(raw_map->IsMap());
2305 map_cache->set_the_hole(i);
2306 map_cache->set_the_hole(i + 1);
2307 }
2308 }
2309 if (used_elements == 0) {
2310 context->set(Context::MAP_CACHE_INDEX, heap()->undefined_value());
2311 } else {
2312 // Note: we don't actually shrink the cache here to avoid
2313 // extra complexity during GC. We rely on subsequent cache
2314 // usages (EnsureCapacity) to do this.
2315 map_cache->ElementsRemoved(existing_elements - used_elements);
2316 MarkBit map_cache_markbit = Marking::MarkBitFrom(map_cache);
2317 MarkObject(map_cache, map_cache_markbit);
2318 }
2319 }
2320 }
2321 // Move to next element in the list.
2322 raw_context = context->get(Context::NEXT_CONTEXT_LINK);
2323 }
2324 ProcessMarkingDeque();
2325 }
2326
2327
2328 void MarkCompactCollector::ClearNonLiveReferences() { 2271 void MarkCompactCollector::ClearNonLiveReferences() {
2329 // Iterate over the map space, setting map transitions that go from 2272 // Iterate over the map space, setting map transitions that go from
2330 // a marked map to an unmarked map to null transitions. This action 2273 // a marked map to an unmarked map to null transitions. This action
2331 // is carried out only on maps of JSObjects and related subtypes. 2274 // is carried out only on maps of JSObjects and related subtypes.
2332 HeapObjectIterator map_iterator(heap()->map_space()); 2275 HeapObjectIterator map_iterator(heap()->map_space());
2333 for (HeapObject* obj = map_iterator.Next(); obj != NULL; 2276 for (HeapObject* obj = map_iterator.Next(); obj != NULL;
2334 obj = map_iterator.Next()) { 2277 obj = map_iterator.Next()) {
2335 Map* map = Map::cast(obj); 2278 Map* map = Map::cast(obj);
2336 2279
2337 if (!map->CanTransition()) continue; 2280 if (!map->CanTransition()) continue;
(...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after
4449 SlotsBuffer* buffer = *buffer_address; 4392 SlotsBuffer* buffer = *buffer_address;
4450 while (buffer != NULL) { 4393 while (buffer != NULL) {
4451 SlotsBuffer* next_buffer = buffer->next(); 4394 SlotsBuffer* next_buffer = buffer->next();
4452 DeallocateBuffer(buffer); 4395 DeallocateBuffer(buffer);
4453 buffer = next_buffer; 4396 buffer = next_buffer;
4454 } 4397 }
4455 *buffer_address = NULL; 4398 *buffer_address = NULL;
4456 } 4399 }
4457 } 4400 }
4458 } // namespace v8::internal 4401 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/mark-compact.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698