| OLD | NEW |
| 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/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/compilation-cache.h" | 9 #include "src/compilation-cache.h" |
| 10 #include "src/cpu-profiler.h" | 10 #include "src/cpu-profiler.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 while (current < limit) { | 198 while (current < limit) { |
| 199 HeapObject* object = HeapObject::FromAddress(current); | 199 HeapObject* object = HeapObject::FromAddress(current); |
| 200 object->Iterate(&visitor); | 200 object->Iterate(&visitor); |
| 201 current += object->Size(); | 201 current += object->Size(); |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 | 206 |
| 207 static void VerifyEvacuation(PagedSpace* space) { | 207 static void VerifyEvacuation(PagedSpace* space) { |
| 208 // TODO(hpayer): Bring back VerifyEvacuation for parallel-concurrently | 208 // TODO(hpayer): Bring back VerifyEvacuation for concurrently swept pages. |
| 209 // swept pages. | 209 if (FLAG_concurrent_sweeping && !space->is_iterable()) return; |
| 210 if ((FLAG_concurrent_sweeping || FLAG_parallel_sweeping) && | |
| 211 !space->is_iterable()) return; | |
| 212 PageIterator it(space); | 210 PageIterator it(space); |
| 213 | 211 |
| 214 while (it.has_next()) { | 212 while (it.has_next()) { |
| 215 Page* p = it.next(); | 213 Page* p = it.next(); |
| 216 if (p->IsEvacuationCandidate()) continue; | 214 if (p->IsEvacuationCandidate()) continue; |
| 217 VerifyEvacuation(p->area_start(), p->area_end()); | 215 VerifyEvacuation(p->area_start(), p->area_end()); |
| 218 } | 216 } |
| 219 } | 217 } |
| 220 | 218 |
| 221 | 219 |
| (...skipping 3918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4140 // Adjust unswept free bytes because releasing a page expects said | 4138 // Adjust unswept free bytes because releasing a page expects said |
| 4141 // counter to be accurate for unswept pages. | 4139 // counter to be accurate for unswept pages. |
| 4142 space->IncreaseUnsweptFreeBytes(p); | 4140 space->IncreaseUnsweptFreeBytes(p); |
| 4143 space->ReleasePage(p); | 4141 space->ReleasePage(p); |
| 4144 continue; | 4142 continue; |
| 4145 } | 4143 } |
| 4146 unused_page_present = true; | 4144 unused_page_present = true; |
| 4147 } | 4145 } |
| 4148 | 4146 |
| 4149 switch (sweeper) { | 4147 switch (sweeper) { |
| 4150 case CONCURRENT_CONSERVATIVE: | 4148 case CONCURRENT_CONSERVATIVE: { |
| 4151 case PARALLEL_CONSERVATIVE: { | |
| 4152 if (!parallel_sweeping_active) { | 4149 if (!parallel_sweeping_active) { |
| 4153 if (FLAG_gc_verbose) { | 4150 if (FLAG_gc_verbose) { |
| 4154 PrintF("Sweeping 0x%" V8PRIxPTR " conservatively.\n", | 4151 PrintF("Sweeping 0x%" V8PRIxPTR " conservatively.\n", |
| 4155 reinterpret_cast<intptr_t>(p)); | 4152 reinterpret_cast<intptr_t>(p)); |
| 4156 } | 4153 } |
| 4157 SweepConservatively<SWEEP_ON_MAIN_THREAD>(space, NULL, p); | 4154 SweepConservatively<SWEEP_ON_MAIN_THREAD>(space, NULL, p); |
| 4158 pages_swept++; | 4155 pages_swept++; |
| 4159 parallel_sweeping_active = true; | 4156 parallel_sweeping_active = true; |
| 4160 } else { | 4157 } else { |
| 4161 if (FLAG_gc_verbose) { | 4158 if (FLAG_gc_verbose) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4202 heap()->FreeQueuedChunks(); | 4199 heap()->FreeQueuedChunks(); |
| 4203 } | 4200 } |
| 4204 | 4201 |
| 4205 | 4202 |
| 4206 void MarkCompactCollector::SweepSpaces() { | 4203 void MarkCompactCollector::SweepSpaces() { |
| 4207 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP); | 4204 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP); |
| 4208 #ifdef DEBUG | 4205 #ifdef DEBUG |
| 4209 state_ = SWEEP_SPACES; | 4206 state_ = SWEEP_SPACES; |
| 4210 #endif | 4207 #endif |
| 4211 SweeperType how_to_sweep = CONCURRENT_CONSERVATIVE; | 4208 SweeperType how_to_sweep = CONCURRENT_CONSERVATIVE; |
| 4212 if (FLAG_parallel_sweeping) how_to_sweep = PARALLEL_CONSERVATIVE; | |
| 4213 if (FLAG_concurrent_sweeping) how_to_sweep = CONCURRENT_CONSERVATIVE; | |
| 4214 | |
| 4215 if (sweep_precisely_) how_to_sweep = PRECISE; | 4209 if (sweep_precisely_) how_to_sweep = PRECISE; |
| 4216 | 4210 |
| 4217 MoveEvacuationCandidatesToEndOfPagesList(); | 4211 MoveEvacuationCandidatesToEndOfPagesList(); |
| 4218 | 4212 |
| 4219 // Noncompacting collections simply sweep the spaces to clear the mark | 4213 // Noncompacting collections simply sweep the spaces to clear the mark |
| 4220 // bits and free the nonlive blocks (for old and map spaces). We sweep | 4214 // bits and free the nonlive blocks (for old and map spaces). We sweep |
| 4221 // the map space last because freeing non-live maps overwrites them and | 4215 // the map space last because freeing non-live maps overwrites them and |
| 4222 // the other spaces rely on possibly non-live maps to get the sizes for | 4216 // the other spaces rely on possibly non-live maps to get the sizes for |
| 4223 // non-live objects. | 4217 // non-live objects. |
| 4224 { GCTracer::Scope sweep_scope(tracer_, GCTracer::Scope::MC_SWEEP_OLDSPACE); | 4218 { GCTracer::Scope sweep_scope(tracer_, GCTracer::Scope::MC_SWEEP_OLDSPACE); |
| 4225 { SequentialSweepingScope scope(this); | 4219 { SequentialSweepingScope scope(this); |
| 4226 SweepSpace(heap()->old_pointer_space(), how_to_sweep); | 4220 SweepSpace(heap()->old_pointer_space(), how_to_sweep); |
| 4227 SweepSpace(heap()->old_data_space(), how_to_sweep); | 4221 SweepSpace(heap()->old_data_space(), how_to_sweep); |
| 4228 } | 4222 } |
| 4229 | 4223 |
| 4230 if (how_to_sweep == PARALLEL_CONSERVATIVE || | 4224 if (how_to_sweep == CONCURRENT_CONSERVATIVE) { |
| 4231 how_to_sweep == CONCURRENT_CONSERVATIVE) { | |
| 4232 StartSweeperThreads(); | 4225 StartSweeperThreads(); |
| 4233 } | 4226 } |
| 4234 | |
| 4235 if (how_to_sweep == PARALLEL_CONSERVATIVE) { | |
| 4236 EnsureSweepingCompleted(); | |
| 4237 } | |
| 4238 } | 4227 } |
| 4239 RemoveDeadInvalidatedCode(); | 4228 RemoveDeadInvalidatedCode(); |
| 4240 | 4229 |
| 4241 { GCTracer::Scope sweep_scope(tracer_, GCTracer::Scope::MC_SWEEP_CODE); | 4230 { GCTracer::Scope sweep_scope(tracer_, GCTracer::Scope::MC_SWEEP_CODE); |
| 4242 SweepSpace(heap()->code_space(), PRECISE); | 4231 SweepSpace(heap()->code_space(), PRECISE); |
| 4243 } | 4232 } |
| 4244 | 4233 |
| 4245 { GCTracer::Scope sweep_scope(tracer_, GCTracer::Scope::MC_SWEEP_CELL); | 4234 { GCTracer::Scope sweep_scope(tracer_, GCTracer::Scope::MC_SWEEP_CELL); |
| 4246 SweepSpace(heap()->cell_space(), PRECISE); | 4235 SweepSpace(heap()->cell_space(), PRECISE); |
| 4247 SweepSpace(heap()->property_cell_space(), PRECISE); | 4236 SweepSpace(heap()->property_cell_space(), PRECISE); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4496 while (buffer != NULL) { | 4485 while (buffer != NULL) { |
| 4497 SlotsBuffer* next_buffer = buffer->next(); | 4486 SlotsBuffer* next_buffer = buffer->next(); |
| 4498 DeallocateBuffer(buffer); | 4487 DeallocateBuffer(buffer); |
| 4499 buffer = next_buffer; | 4488 buffer = next_buffer; |
| 4500 } | 4489 } |
| 4501 *buffer_address = NULL; | 4490 *buffer_address = NULL; |
| 4502 } | 4491 } |
| 4503 | 4492 |
| 4504 | 4493 |
| 4505 } } // namespace v8::internal | 4494 } } // namespace v8::internal |
| OLD | NEW |