| 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 2273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2284 } | 2284 } |
| 2285 ProcessMarkingDeque(); | 2285 ProcessMarkingDeque(); |
| 2286 return; | 2286 return; |
| 2287 } | 2287 } |
| 2288 } | 2288 } |
| 2289 } | 2289 } |
| 2290 | 2290 |
| 2291 | 2291 |
| 2292 void MarkCompactCollector::MarkLiveObjects() { | 2292 void MarkCompactCollector::MarkLiveObjects() { |
| 2293 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_MARK); | 2293 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_MARK); |
| 2294 double start_time = 0.0; |
| 2295 if (FLAG_print_cumulative_gc_stat) { |
| 2296 start_time = base::OS::TimeCurrentMillis(); |
| 2297 } |
| 2294 // The recursive GC marker detects when it is nearing stack overflow, | 2298 // The recursive GC marker detects when it is nearing stack overflow, |
| 2295 // and switches to a different marking system. JS interrupts interfere | 2299 // and switches to a different marking system. JS interrupts interfere |
| 2296 // with the C stack limit check. | 2300 // with the C stack limit check. |
| 2297 PostponeInterruptsScope postpone(isolate()); | 2301 PostponeInterruptsScope postpone(isolate()); |
| 2298 | 2302 |
| 2299 bool incremental_marking_overflowed = false; | 2303 bool incremental_marking_overflowed = false; |
| 2300 IncrementalMarking* incremental_marking = heap_->incremental_marking(); | 2304 IncrementalMarking* incremental_marking = heap_->incremental_marking(); |
| 2301 if (was_marked_incrementally_) { | 2305 if (was_marked_incrementally_) { |
| 2302 // Finalize the incremental marking and check whether we had an overflow. | 2306 // Finalize the incremental marking and check whether we had an overflow. |
| 2303 // Both markers use grey color to mark overflowed objects so | 2307 // Both markers use grey color to mark overflowed objects so |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2388 while (marking_deque_.overflowed()) { | 2392 while (marking_deque_.overflowed()) { |
| 2389 RefillMarkingDeque(); | 2393 RefillMarkingDeque(); |
| 2390 EmptyMarkingDeque(); | 2394 EmptyMarkingDeque(); |
| 2391 } | 2395 } |
| 2392 | 2396 |
| 2393 // Repeat host application specific and Harmony weak maps marking to | 2397 // Repeat host application specific and Harmony weak maps marking to |
| 2394 // mark unmarked objects reachable from the weak roots. | 2398 // mark unmarked objects reachable from the weak roots. |
| 2395 ProcessEphemeralMarking(&root_visitor); | 2399 ProcessEphemeralMarking(&root_visitor); |
| 2396 | 2400 |
| 2397 AfterMarking(); | 2401 AfterMarking(); |
| 2402 |
| 2403 if (FLAG_print_cumulative_gc_stat) { |
| 2404 heap_->tracer()->AddMarkingTime(base::OS::TimeCurrentMillis() - start_time); |
| 2405 } |
| 2398 } | 2406 } |
| 2399 | 2407 |
| 2400 | 2408 |
| 2401 void MarkCompactCollector::AfterMarking() { | 2409 void MarkCompactCollector::AfterMarking() { |
| 2402 // Object literal map caches reference strings (cache keys) and maps | 2410 // Object literal map caches reference strings (cache keys) and maps |
| 2403 // (cache values). At this point still useful maps have already been | 2411 // (cache values). At this point still useful maps have already been |
| 2404 // marked. Mark the keys for the alive values before we process the | 2412 // marked. Mark the keys for the alive values before we process the |
| 2405 // string table. | 2413 // string table. |
| 2406 ProcessMapCaches(); | 2414 ProcessMapCaches(); |
| 2407 | 2415 |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3277 FreeList* free_list, | 3285 FreeList* free_list, |
| 3278 Page* p, | 3286 Page* p, |
| 3279 ObjectVisitor* v) { | 3287 ObjectVisitor* v) { |
| 3280 ASSERT(!p->IsEvacuationCandidate() && !p->WasSwept()); | 3288 ASSERT(!p->IsEvacuationCandidate() && !p->WasSwept()); |
| 3281 ASSERT_EQ(skip_list_mode == REBUILD_SKIP_LIST, | 3289 ASSERT_EQ(skip_list_mode == REBUILD_SKIP_LIST, |
| 3282 space->identity() == CODE_SPACE); | 3290 space->identity() == CODE_SPACE); |
| 3283 ASSERT((p->skip_list() == NULL) || (skip_list_mode == REBUILD_SKIP_LIST)); | 3291 ASSERT((p->skip_list() == NULL) || (skip_list_mode == REBUILD_SKIP_LIST)); |
| 3284 ASSERT(parallelism == MarkCompactCollector::SWEEP_ON_MAIN_THREAD || | 3292 ASSERT(parallelism == MarkCompactCollector::SWEEP_ON_MAIN_THREAD || |
| 3285 sweeping_mode == SWEEP_ONLY); | 3293 sweeping_mode == SWEEP_ONLY); |
| 3286 | 3294 |
| 3287 double start_time = 0.0; | |
| 3288 if (FLAG_print_cumulative_gc_stat) { | |
| 3289 start_time = base::OS::TimeCurrentMillis(); | |
| 3290 } | |
| 3291 | |
| 3292 Address free_start = p->area_start(); | 3295 Address free_start = p->area_start(); |
| 3293 ASSERT(reinterpret_cast<intptr_t>(free_start) % (32 * kPointerSize) == 0); | 3296 ASSERT(reinterpret_cast<intptr_t>(free_start) % (32 * kPointerSize) == 0); |
| 3294 int offsets[16]; | 3297 int offsets[16]; |
| 3295 | 3298 |
| 3296 SkipList* skip_list = p->skip_list(); | 3299 SkipList* skip_list = p->skip_list(); |
| 3297 int curr_region = -1; | 3300 int curr_region = -1; |
| 3298 if ((skip_list_mode == REBUILD_SKIP_LIST) && skip_list) { | 3301 if ((skip_list_mode == REBUILD_SKIP_LIST) && skip_list) { |
| 3299 skip_list->Clear(); | 3302 skip_list->Clear(); |
| 3300 } | 3303 } |
| 3301 | 3304 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3352 } | 3355 } |
| 3353 freed_bytes = Free<parallelism>(space, free_list, free_start, size); | 3356 freed_bytes = Free<parallelism>(space, free_list, free_start, size); |
| 3354 max_freed_bytes = Max(freed_bytes, max_freed_bytes); | 3357 max_freed_bytes = Max(freed_bytes, max_freed_bytes); |
| 3355 #ifdef ENABLE_GDB_JIT_INTERFACE | 3358 #ifdef ENABLE_GDB_JIT_INTERFACE |
| 3356 if (FLAG_gdbjit && space->identity() == CODE_SPACE) { | 3359 if (FLAG_gdbjit && space->identity() == CODE_SPACE) { |
| 3357 GDBJITInterface::RemoveCodeRange(free_start, p->area_end()); | 3360 GDBJITInterface::RemoveCodeRange(free_start, p->area_end()); |
| 3358 } | 3361 } |
| 3359 #endif | 3362 #endif |
| 3360 } | 3363 } |
| 3361 p->ResetLiveBytes(); | 3364 p->ResetLiveBytes(); |
| 3362 if (FLAG_print_cumulative_gc_stat) { | |
| 3363 space->heap()->AddSweepingTime(base::OS::TimeCurrentMillis() - start_time); | |
| 3364 } | |
| 3365 | 3365 |
| 3366 if (parallelism == MarkCompactCollector::SWEEP_IN_PARALLEL) { | 3366 if (parallelism == MarkCompactCollector::SWEEP_IN_PARALLEL) { |
| 3367 // When concurrent sweeping is active, the page will be marked after | 3367 // When concurrent sweeping is active, the page will be marked after |
| 3368 // sweeping by the main thread. | 3368 // sweeping by the main thread. |
| 3369 p->set_parallel_sweeping(MemoryChunk::SWEEPING_FINALIZE); | 3369 p->set_parallel_sweeping(MemoryChunk::SWEEPING_FINALIZE); |
| 3370 } else { | 3370 } else { |
| 3371 p->MarkSweptPrecisely(); | 3371 p->MarkSweptPrecisely(); |
| 3372 } | 3372 } |
| 3373 return FreeList::GuaranteedAllocatable(static_cast<int>(max_freed_bytes)); | 3373 return FreeList::GuaranteedAllocatable(static_cast<int>(max_freed_bytes)); |
| 3374 } | 3374 } |
| (...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4301 | 4301 |
| 4302 static bool ShouldWaitForSweeperThreads( | 4302 static bool ShouldWaitForSweeperThreads( |
| 4303 MarkCompactCollector::SweeperType type) { | 4303 MarkCompactCollector::SweeperType type) { |
| 4304 return type == MarkCompactCollector::PARALLEL_CONSERVATIVE || | 4304 return type == MarkCompactCollector::PARALLEL_CONSERVATIVE || |
| 4305 type == MarkCompactCollector::PARALLEL_PRECISE; | 4305 type == MarkCompactCollector::PARALLEL_PRECISE; |
| 4306 } | 4306 } |
| 4307 | 4307 |
| 4308 | 4308 |
| 4309 void MarkCompactCollector::SweepSpaces() { | 4309 void MarkCompactCollector::SweepSpaces() { |
| 4310 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_SWEEP); | 4310 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_SWEEP); |
| 4311 double start_time = 0.0; |
| 4312 if (FLAG_print_cumulative_gc_stat) { |
| 4313 start_time = base::OS::TimeCurrentMillis(); |
| 4314 } |
| 4315 |
| 4311 #ifdef DEBUG | 4316 #ifdef DEBUG |
| 4312 state_ = SWEEP_SPACES; | 4317 state_ = SWEEP_SPACES; |
| 4313 #endif | 4318 #endif |
| 4314 SweeperType how_to_sweep = CONCURRENT_CONSERVATIVE; | 4319 SweeperType how_to_sweep = CONCURRENT_CONSERVATIVE; |
| 4315 if (FLAG_parallel_sweeping) how_to_sweep = PARALLEL_CONSERVATIVE; | 4320 if (FLAG_parallel_sweeping) how_to_sweep = PARALLEL_CONSERVATIVE; |
| 4316 if (FLAG_concurrent_sweeping) how_to_sweep = CONCURRENT_CONSERVATIVE; | 4321 if (FLAG_concurrent_sweeping) how_to_sweep = CONCURRENT_CONSERVATIVE; |
| 4317 if (FLAG_always_precise_sweeping && FLAG_parallel_sweeping) { | 4322 if (FLAG_always_precise_sweeping && FLAG_parallel_sweeping) { |
| 4318 how_to_sweep = PARALLEL_PRECISE; | 4323 how_to_sweep = PARALLEL_PRECISE; |
| 4319 } | 4324 } |
| 4320 if (FLAG_always_precise_sweeping && FLAG_concurrent_sweeping) { | 4325 if (FLAG_always_precise_sweeping && FLAG_concurrent_sweeping) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4365 { GCTracer::Scope sweep_scope(heap()->tracer(), | 4370 { GCTracer::Scope sweep_scope(heap()->tracer(), |
| 4366 GCTracer::Scope::MC_SWEEP_MAP); | 4371 GCTracer::Scope::MC_SWEEP_MAP); |
| 4367 SweepSpace(heap()->map_space(), PRECISE); | 4372 SweepSpace(heap()->map_space(), PRECISE); |
| 4368 } | 4373 } |
| 4369 | 4374 |
| 4370 // Deallocate unmarked objects and clear marked bits for marked objects. | 4375 // Deallocate unmarked objects and clear marked bits for marked objects. |
| 4371 heap_->lo_space()->FreeUnmarkedObjects(); | 4376 heap_->lo_space()->FreeUnmarkedObjects(); |
| 4372 | 4377 |
| 4373 // Deallocate evacuated candidate pages. | 4378 // Deallocate evacuated candidate pages. |
| 4374 ReleaseEvacuationCandidates(); | 4379 ReleaseEvacuationCandidates(); |
| 4380 |
| 4381 if (FLAG_print_cumulative_gc_stat) { |
| 4382 heap_->tracer()->AddSweepingTime(base::OS::TimeCurrentMillis() - |
| 4383 start_time); |
| 4384 } |
| 4375 } | 4385 } |
| 4376 | 4386 |
| 4377 | 4387 |
| 4378 void MarkCompactCollector::ParallelSweepSpaceComplete(PagedSpace* space) { | 4388 void MarkCompactCollector::ParallelSweepSpaceComplete(PagedSpace* space) { |
| 4379 PageIterator it(space); | 4389 PageIterator it(space); |
| 4380 while (it.has_next()) { | 4390 while (it.has_next()) { |
| 4381 Page* p = it.next(); | 4391 Page* p = it.next(); |
| 4382 if (p->parallel_sweeping() == MemoryChunk::SWEEPING_FINALIZE) { | 4392 if (p->parallel_sweeping() == MemoryChunk::SWEEPING_FINALIZE) { |
| 4383 p->set_parallel_sweeping(MemoryChunk::SWEEPING_DONE); | 4393 p->set_parallel_sweeping(MemoryChunk::SWEEPING_DONE); |
| 4384 if (space->swept_precisely()) { | 4394 if (space->swept_precisely()) { |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4611 while (buffer != NULL) { | 4621 while (buffer != NULL) { |
| 4612 SlotsBuffer* next_buffer = buffer->next(); | 4622 SlotsBuffer* next_buffer = buffer->next(); |
| 4613 DeallocateBuffer(buffer); | 4623 DeallocateBuffer(buffer); |
| 4614 buffer = next_buffer; | 4624 buffer = next_buffer; |
| 4615 } | 4625 } |
| 4616 *buffer_address = NULL; | 4626 *buffer_address = NULL; |
| 4617 } | 4627 } |
| 4618 | 4628 |
| 4619 | 4629 |
| 4620 } } // namespace v8::internal | 4630 } } // namespace v8::internal |
| OLD | NEW |