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/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 4149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4160 // counter to be accurate for unswept pages. | 4160 // counter to be accurate for unswept pages. |
4161 space->IncreaseUnsweptFreeBytes(p); | 4161 space->IncreaseUnsweptFreeBytes(p); |
4162 space->ReleasePage(p); | 4162 space->ReleasePage(p); |
4163 continue; | 4163 continue; |
4164 } | 4164 } |
4165 unused_page_present = true; | 4165 unused_page_present = true; |
4166 } | 4166 } |
4167 | 4167 |
4168 switch (sweeper) { | 4168 switch (sweeper) { |
4169 case CONCURRENT_SWEEPING: | 4169 case CONCURRENT_SWEEPING: |
4170 case PARALLEL_SWEEPING: | |
4171 if (!parallel_sweeping_active) { | 4170 if (!parallel_sweeping_active) { |
4172 if (FLAG_gc_verbose) { | 4171 if (FLAG_gc_verbose) { |
4173 PrintF("Sweeping 0x%" V8PRIxPTR ".\n", | 4172 PrintF("Sweeping 0x%" V8PRIxPTR ".\n", |
4174 reinterpret_cast<intptr_t>(p)); | 4173 reinterpret_cast<intptr_t>(p)); |
4175 } | 4174 } |
4176 Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, IGNORE_SKIP_LIST, | 4175 Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, IGNORE_SKIP_LIST, |
4177 IGNORE_FREE_SPACE>(space, NULL, p, NULL); | 4176 IGNORE_FREE_SPACE>(space, NULL, p, NULL); |
4178 pages_swept++; | 4177 pages_swept++; |
4179 parallel_sweeping_active = true; | 4178 parallel_sweeping_active = true; |
4180 } else { | 4179 } else { |
(...skipping 30 matching lines...) Expand all Loading... |
4211 if (FLAG_gc_verbose) { | 4210 if (FLAG_gc_verbose) { |
4212 PrintF("SweepSpace: %s (%d pages swept)\n", | 4211 PrintF("SweepSpace: %s (%d pages swept)\n", |
4213 AllocationSpaceName(space->identity()), pages_swept); | 4212 AllocationSpaceName(space->identity()), pages_swept); |
4214 } | 4213 } |
4215 | 4214 |
4216 // Give pages that are queued to be freed back to the OS. | 4215 // Give pages that are queued to be freed back to the OS. |
4217 heap()->FreeQueuedChunks(); | 4216 heap()->FreeQueuedChunks(); |
4218 } | 4217 } |
4219 | 4218 |
4220 | 4219 |
4221 static bool ShouldStartSweeperThreads(MarkCompactCollector::SweeperType type) { | |
4222 return (type == MarkCompactCollector::PARALLEL_SWEEPING || | |
4223 type == MarkCompactCollector::CONCURRENT_SWEEPING) && | |
4224 !FLAG_predictable; | |
4225 } | |
4226 | |
4227 | |
4228 static bool ShouldWaitForSweeperThreads( | |
4229 MarkCompactCollector::SweeperType type) { | |
4230 return type == MarkCompactCollector::PARALLEL_SWEEPING; | |
4231 } | |
4232 | |
4233 | |
4234 void MarkCompactCollector::SweepSpaces() { | 4220 void MarkCompactCollector::SweepSpaces() { |
4235 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_SWEEP); | 4221 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_SWEEP); |
4236 double start_time = 0.0; | 4222 double start_time = 0.0; |
4237 if (FLAG_print_cumulative_gc_stat) { | 4223 if (FLAG_print_cumulative_gc_stat) { |
4238 start_time = base::OS::TimeCurrentMillis(); | 4224 start_time = base::OS::TimeCurrentMillis(); |
4239 } | 4225 } |
4240 | 4226 |
4241 #ifdef DEBUG | 4227 #ifdef DEBUG |
4242 state_ = SWEEP_SPACES; | 4228 state_ = SWEEP_SPACES; |
4243 #endif | 4229 #endif |
4244 SweeperType how_to_sweep = CONCURRENT_SWEEPING; | |
4245 if (FLAG_parallel_sweeping) how_to_sweep = PARALLEL_SWEEPING; | |
4246 if (FLAG_concurrent_sweeping) how_to_sweep = CONCURRENT_SWEEPING; | |
4247 | |
4248 MoveEvacuationCandidatesToEndOfPagesList(); | 4230 MoveEvacuationCandidatesToEndOfPagesList(); |
4249 | 4231 |
4250 // Noncompacting collections simply sweep the spaces to clear the mark | 4232 // Noncompacting collections simply sweep the spaces to clear the mark |
4251 // bits and free the nonlive blocks (for old and map spaces). We sweep | 4233 // bits and free the nonlive blocks (for old and map spaces). We sweep |
4252 // the map space last because freeing non-live maps overwrites them and | 4234 // the map space last because freeing non-live maps overwrites them and |
4253 // the other spaces rely on possibly non-live maps to get the sizes for | 4235 // the other spaces rely on possibly non-live maps to get the sizes for |
4254 // non-live objects. | 4236 // non-live objects. |
4255 { | 4237 { |
4256 GCTracer::Scope sweep_scope(heap()->tracer(), | 4238 GCTracer::Scope sweep_scope(heap()->tracer(), |
4257 GCTracer::Scope::MC_SWEEP_OLDSPACE); | 4239 GCTracer::Scope::MC_SWEEP_OLDSPACE); |
4258 { | 4240 { |
4259 SequentialSweepingScope scope(this); | 4241 SequentialSweepingScope scope(this); |
4260 SweepSpace(heap()->old_pointer_space(), how_to_sweep); | 4242 SweepSpace(heap()->old_pointer_space(), CONCURRENT_SWEEPING); |
4261 SweepSpace(heap()->old_data_space(), how_to_sweep); | 4243 SweepSpace(heap()->old_data_space(), CONCURRENT_SWEEPING); |
4262 } | 4244 } |
4263 | 4245 |
4264 if (ShouldStartSweeperThreads(how_to_sweep)) { | 4246 if (!FLAG_predictable) { |
4265 StartSweeperThreads(); | 4247 StartSweeperThreads(); |
4266 } | 4248 } |
4267 | |
4268 if (ShouldWaitForSweeperThreads(how_to_sweep)) { | |
4269 EnsureSweepingCompleted(); | |
4270 } | |
4271 } | 4249 } |
4272 RemoveDeadInvalidatedCode(); | 4250 RemoveDeadInvalidatedCode(); |
4273 | 4251 |
4274 { | 4252 { |
4275 GCTracer::Scope sweep_scope(heap()->tracer(), | 4253 GCTracer::Scope sweep_scope(heap()->tracer(), |
4276 GCTracer::Scope::MC_SWEEP_CODE); | 4254 GCTracer::Scope::MC_SWEEP_CODE); |
4277 SweepSpace(heap()->code_space(), SEQUENTIAL_SWEEPING); | 4255 SweepSpace(heap()->code_space(), SEQUENTIAL_SWEEPING); |
4278 } | 4256 } |
4279 | 4257 |
4280 { | 4258 { |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4527 SlotsBuffer* buffer = *buffer_address; | 4505 SlotsBuffer* buffer = *buffer_address; |
4528 while (buffer != NULL) { | 4506 while (buffer != NULL) { |
4529 SlotsBuffer* next_buffer = buffer->next(); | 4507 SlotsBuffer* next_buffer = buffer->next(); |
4530 DeallocateBuffer(buffer); | 4508 DeallocateBuffer(buffer); |
4531 buffer = next_buffer; | 4509 buffer = next_buffer; |
4532 } | 4510 } |
4533 *buffer_address = NULL; | 4511 *buffer_address = NULL; |
4534 } | 4512 } |
4535 } | 4513 } |
4536 } // namespace v8::internal | 4514 } // namespace v8::internal |
OLD | NEW |