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/heap/mark-compact.h" | 5 #include "src/heap/mark-compact.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/base/sys-info.h" | 9 #include "src/base/sys-info.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 pending_sweeper_tasks_semaphore_.Wait(); | 562 pending_sweeper_tasks_semaphore_.Wait(); |
563 pending_sweeper_tasks_semaphore_.Wait(); | 563 pending_sweeper_tasks_semaphore_.Wait(); |
564 pending_sweeper_tasks_semaphore_.Wait(); | 564 pending_sweeper_tasks_semaphore_.Wait(); |
565 } | 565 } |
566 | 566 |
567 ParallelSweepSpacesComplete(); | 567 ParallelSweepSpacesComplete(); |
568 sweeping_in_progress_ = false; | 568 sweeping_in_progress_ = false; |
569 RefillFreeList(heap()->paged_space(OLD_SPACE)); | 569 RefillFreeList(heap()->paged_space(OLD_SPACE)); |
570 RefillFreeList(heap()->paged_space(CODE_SPACE)); | 570 RefillFreeList(heap()->paged_space(CODE_SPACE)); |
571 RefillFreeList(heap()->paged_space(MAP_SPACE)); | 571 RefillFreeList(heap()->paged_space(MAP_SPACE)); |
572 heap()->paged_space(OLD_SPACE)->ResetUnsweptFreeBytes(); | |
573 heap()->paged_space(CODE_SPACE)->ResetUnsweptFreeBytes(); | |
574 heap()->paged_space(MAP_SPACE)->ResetUnsweptFreeBytes(); | |
575 | 572 |
576 #ifdef VERIFY_HEAP | 573 #ifdef VERIFY_HEAP |
577 if (FLAG_verify_heap && !evacuation()) { | 574 if (FLAG_verify_heap && !evacuation()) { |
578 VerifyEvacuation(heap_); | 575 VerifyEvacuation(heap_); |
579 } | 576 } |
580 #endif | 577 #endif |
581 } | 578 } |
582 | 579 |
583 | 580 |
584 bool MarkCompactCollector::IsSweepingCompleted() { | 581 bool MarkCompactCollector::IsSweepingCompleted() { |
(...skipping 14 matching lines...) Expand all Loading... |
599 } else if (space == heap()->code_space()) { | 596 } else if (space == heap()->code_space()) { |
600 free_list = free_list_code_space_.get(); | 597 free_list = free_list_code_space_.get(); |
601 } else if (space == heap()->map_space()) { | 598 } else if (space == heap()->map_space()) { |
602 free_list = free_list_map_space_.get(); | 599 free_list = free_list_map_space_.get(); |
603 } else { | 600 } else { |
604 // Any PagedSpace might invoke RefillFreeLists, so we need to make sure | 601 // Any PagedSpace might invoke RefillFreeLists, so we need to make sure |
605 // to only refill them for the old space. | 602 // to only refill them for the old space. |
606 return; | 603 return; |
607 } | 604 } |
608 | 605 |
609 intptr_t freed_bytes = space->free_list()->Concatenate(free_list); | 606 intptr_t added = space->free_list()->Concatenate(free_list); |
610 space->AddToAccountingStats(freed_bytes); | 607 space->accounting_stats_.IncreaseCapacity(added); |
611 space->DecrementUnsweptFreeBytes(freed_bytes); | |
612 } | 608 } |
613 | 609 |
614 | 610 |
615 void Marking::TransferMark(Heap* heap, Address old_start, Address new_start) { | 611 void Marking::TransferMark(Heap* heap, Address old_start, Address new_start) { |
616 // This is only used when resizing an object. | 612 // This is only used when resizing an object. |
617 DCHECK(MemoryChunk::FromAddress(old_start) == | 613 DCHECK(MemoryChunk::FromAddress(old_start) == |
618 MemoryChunk::FromAddress(new_start)); | 614 MemoryChunk::FromAddress(new_start)); |
619 | 615 |
620 if (!heap->incremental_marking()->IsMarking()) return; | 616 if (!heap->incremental_marking()->IsMarking()) return; |
621 | 617 |
(...skipping 3727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4349 continue; | 4345 continue; |
4350 } | 4346 } |
4351 | 4347 |
4352 // One unused page is kept, all further are released before sweeping them. | 4348 // One unused page is kept, all further are released before sweeping them. |
4353 if (p->LiveBytes() == 0) { | 4349 if (p->LiveBytes() == 0) { |
4354 if (unused_page_present) { | 4350 if (unused_page_present) { |
4355 if (FLAG_gc_verbose) { | 4351 if (FLAG_gc_verbose) { |
4356 PrintF("Sweeping 0x%" V8PRIxPTR " released page.\n", | 4352 PrintF("Sweeping 0x%" V8PRIxPTR " released page.\n", |
4357 reinterpret_cast<intptr_t>(p)); | 4353 reinterpret_cast<intptr_t>(p)); |
4358 } | 4354 } |
4359 // Adjust unswept free bytes because releasing a page expects said | 4355 // Adjust bytes allocated because releasing a page expects said |
4360 // counter to be accurate for unswept pages. | 4356 // counter to be accurate for unswept pages. |
4361 space->IncreaseUnsweptFreeBytes(p); | 4357 space->accounting_stats_.AllocateBytes(p->area_size()); |
4362 space->ReleasePage(p); | 4358 space->ReleasePage(p); |
4363 continue; | 4359 continue; |
4364 } | 4360 } |
4365 unused_page_present = true; | 4361 unused_page_present = true; |
4366 } | 4362 } |
4367 | 4363 |
4368 switch (sweeper) { | 4364 switch (sweeper) { |
4369 case CONCURRENT_SWEEPING: | 4365 case CONCURRENT_SWEEPING: |
4370 if (!parallel_sweeping_active) { | 4366 if (!parallel_sweeping_active) { |
4371 if (FLAG_gc_verbose) { | 4367 if (FLAG_gc_verbose) { |
(...skipping 13 matching lines...) Expand all Loading... |
4385 IGNORE_FREE_SPACE>(space, NULL, p, NULL); | 4381 IGNORE_FREE_SPACE>(space, NULL, p, NULL); |
4386 } | 4382 } |
4387 pages_swept++; | 4383 pages_swept++; |
4388 parallel_sweeping_active = true; | 4384 parallel_sweeping_active = true; |
4389 } else { | 4385 } else { |
4390 if (FLAG_gc_verbose) { | 4386 if (FLAG_gc_verbose) { |
4391 PrintF("Sweeping 0x%" V8PRIxPTR " in parallel.\n", | 4387 PrintF("Sweeping 0x%" V8PRIxPTR " in parallel.\n", |
4392 reinterpret_cast<intptr_t>(p)); | 4388 reinterpret_cast<intptr_t>(p)); |
4393 } | 4389 } |
4394 p->parallel_sweeping_state().SetValue(MemoryChunk::kSweepingPending); | 4390 p->parallel_sweeping_state().SetValue(MemoryChunk::kSweepingPending); |
4395 space->IncreaseUnsweptFreeBytes(p); | 4391 int to_sweep = p->area_size() - p->LiveBytes(); |
| 4392 space->accounting_stats_.ShrinkSpace(to_sweep); |
4396 } | 4393 } |
4397 space->set_end_of_unswept_pages(p); | 4394 space->set_end_of_unswept_pages(p); |
4398 break; | 4395 break; |
4399 case SEQUENTIAL_SWEEPING: { | 4396 case SEQUENTIAL_SWEEPING: { |
4400 if (FLAG_gc_verbose) { | 4397 if (FLAG_gc_verbose) { |
4401 PrintF("Sweeping 0x%" V8PRIxPTR ".\n", reinterpret_cast<intptr_t>(p)); | 4398 PrintF("Sweeping 0x%" V8PRIxPTR ".\n", reinterpret_cast<intptr_t>(p)); |
4402 } | 4399 } |
4403 if (space->identity() == CODE_SPACE) { | 4400 if (space->identity() == CODE_SPACE) { |
4404 if (FLAG_zap_code_space) { | 4401 if (FLAG_zap_code_space) { |
4405 Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, REBUILD_SKIP_LIST, | 4402 Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, REBUILD_SKIP_LIST, |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4601 MarkBit mark_bit = Marking::MarkBitFrom(host); | 4598 MarkBit mark_bit = Marking::MarkBitFrom(host); |
4602 if (Marking::IsBlack(mark_bit)) { | 4599 if (Marking::IsBlack(mark_bit)) { |
4603 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); | 4600 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); |
4604 RecordRelocSlot(&rinfo, target); | 4601 RecordRelocSlot(&rinfo, target); |
4605 } | 4602 } |
4606 } | 4603 } |
4607 } | 4604 } |
4608 | 4605 |
4609 } // namespace internal | 4606 } // namespace internal |
4610 } // namespace v8 | 4607 } // namespace v8 |
OLD | NEW |