Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 // Tell the tracer. | 75 // Tell the tracer. |
| 76 if (IsCompacting()) tracer_->set_is_compacting(); | 76 if (IsCompacting()) tracer_->set_is_compacting(); |
| 77 | 77 |
| 78 MarkLiveObjects(); | 78 MarkLiveObjects(); |
| 79 | 79 |
| 80 if (FLAG_collect_maps) ClearNonLiveTransitions(); | 80 if (FLAG_collect_maps) ClearNonLiveTransitions(); |
| 81 | 81 |
| 82 SweepLargeObjectSpace(); | 82 SweepLargeObjectSpace(); |
| 83 | 83 |
| 84 if (IsCompacting()) { | 84 if (IsCompacting()) { |
| 85 ASSERT(!FLAG_new_gc); | |
| 86 | |
| 85 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_COMPACT); | 87 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_COMPACT); |
| 86 EncodeForwardingAddresses(); | 88 EncodeForwardingAddresses(); |
| 87 | 89 |
| 88 Heap::MarkMapPointersAsEncoded(true); | 90 Heap::MarkMapPointersAsEncoded(true); |
| 89 UpdatePointers(); | 91 UpdatePointers(); |
| 90 Heap::MarkMapPointersAsEncoded(false); | 92 Heap::MarkMapPointersAsEncoded(false); |
| 91 PcToCodeCache::FlushPcToCodeCache(); | 93 PcToCodeCache::FlushPcToCodeCache(); |
| 92 | 94 |
| 93 RelocateObjects(); | 95 RelocateObjects(); |
| 94 } else { | 96 } else { |
| 95 SweepSpaces(); | 97 SweepSpaces(); |
| 96 PcToCodeCache::FlushPcToCodeCache(); | 98 PcToCodeCache::FlushPcToCodeCache(); |
| 97 } | 99 } |
| 98 | 100 |
| 99 Finish(); | 101 Finish(); |
| 100 | 102 |
| 101 // Save the count of marked objects remaining after the collection and | 103 // Save the count of marked objects remaining after the collection and |
| 102 // null out the GC tracer. | 104 // null out the GC tracer. |
| 103 previous_marked_count_ = tracer_->marked_count(); | 105 previous_marked_count_ = tracer_->marked_count(); |
| 104 ASSERT(previous_marked_count_ == 0); | 106 ASSERT(previous_marked_count_ == 0); |
| 105 tracer_ = NULL; | 107 tracer_ = NULL; |
| 106 } | 108 } |
| 107 | 109 |
| 108 | 110 |
| 109 void MarkCompactCollector::Prepare(GCTracer* tracer) { | 111 void MarkCompactCollector::Prepare(GCTracer* tracer) { |
| 112 if (FLAG_new_gc) { | |
| 113 FLAG_flush_code = false; | |
| 114 FLAG_always_compact = false; | |
| 115 FLAG_never_compact = true; | |
| 116 } | |
| 117 | |
| 110 // Rather than passing the tracer around we stash it in a static member | 118 // Rather than passing the tracer around we stash it in a static member |
| 111 // variable. | 119 // variable. |
| 112 tracer_ = tracer; | 120 tracer_ = tracer; |
| 113 | 121 |
| 114 #ifdef DEBUG | 122 #ifdef DEBUG |
| 115 ASSERT(state_ == IDLE); | 123 ASSERT(state_ == IDLE); |
| 116 state_ = PREPARE_GC; | 124 state_ = PREPARE_GC; |
| 117 #endif | 125 #endif |
| 118 ASSERT(!FLAG_always_compact || !FLAG_never_compact); | 126 ASSERT(!FLAG_always_compact || !FLAG_never_compact); |
| 119 | 127 |
| (...skipping 2220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2340 | 2348 |
| 2341 Heap::IterateDirtyRegions(Heap::map_space(), | 2349 Heap::IterateDirtyRegions(Heap::map_space(), |
| 2342 &Heap::IteratePointersInDirtyMapsRegion, | 2350 &Heap::IteratePointersInDirtyMapsRegion, |
| 2343 &UpdatePointerToNewGen, | 2351 &UpdatePointerToNewGen, |
| 2344 Heap::WATERMARK_SHOULD_BE_VALID); | 2352 Heap::WATERMARK_SHOULD_BE_VALID); |
| 2345 | 2353 |
| 2346 intptr_t live_maps_size = Heap::map_space()->Size(); | 2354 intptr_t live_maps_size = Heap::map_space()->Size(); |
| 2347 int live_maps = static_cast<int>(live_maps_size / Map::kSize); | 2355 int live_maps = static_cast<int>(live_maps_size / Map::kSize); |
| 2348 ASSERT(live_map_objects_size_ == live_maps_size); | 2356 ASSERT(live_map_objects_size_ == live_maps_size); |
| 2349 | 2357 |
| 2350 if (Heap::map_space()->NeedsCompaction(live_maps)) { | 2358 if (!FLAG_new_gc && Heap::map_space()->NeedsCompaction(live_maps)) { |
|
Erik Corry
2010/12/13 19:58:28
Shouldnt this be !FLAG_never_compact. Looks a lit
| |
| 2351 MapCompact map_compact(live_maps); | 2359 MapCompact map_compact(live_maps); |
| 2352 | 2360 |
| 2353 map_compact.CompactMaps(); | 2361 map_compact.CompactMaps(); |
| 2354 map_compact.UpdateMapPointersInRoots(); | 2362 map_compact.UpdateMapPointersInRoots(); |
| 2355 | 2363 |
| 2356 PagedSpaces spaces; | 2364 PagedSpaces spaces; |
| 2357 for (PagedSpace* space = spaces.next(); | 2365 for (PagedSpace* space = spaces.next(); |
| 2358 space != NULL; space = spaces.next()) { | 2366 space != NULL; space = spaces.next()) { |
| 2359 if (space == Heap::map_space()) continue; | 2367 if (space == Heap::map_space()) continue; |
| 2360 map_compact.UpdateMapPointersInPagedSpace(space); | 2368 map_compact.UpdateMapPointersInPagedSpace(space); |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2918 } | 2926 } |
| 2919 | 2927 |
| 2920 | 2928 |
| 2921 void MarkCompactCollector::Initialize() { | 2929 void MarkCompactCollector::Initialize() { |
| 2922 StaticPointersToNewGenUpdatingVisitor::Initialize(); | 2930 StaticPointersToNewGenUpdatingVisitor::Initialize(); |
| 2923 StaticMarkingVisitor::Initialize(); | 2931 StaticMarkingVisitor::Initialize(); |
| 2924 } | 2932 } |
| 2925 | 2933 |
| 2926 | 2934 |
| 2927 } } // namespace v8::internal | 2935 } } // namespace v8::internal |
| OLD | NEW |