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 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 if (FLAG_trace_fragmentation && | 716 if (FLAG_trace_fragmentation && |
717 max_evacuation_candidates >= kMaxMaxEvacuationCandidates) { | 717 max_evacuation_candidates >= kMaxMaxEvacuationCandidates) { |
718 PrintF("Hit max page compaction limit of %d pages\n", | 718 PrintF("Hit max page compaction limit of %d pages\n", |
719 kMaxMaxEvacuationCandidates); | 719 kMaxMaxEvacuationCandidates); |
720 } | 720 } |
721 max_evacuation_candidates = | 721 max_evacuation_candidates = |
722 Min(kMaxMaxEvacuationCandidates, max_evacuation_candidates); | 722 Min(kMaxMaxEvacuationCandidates, max_evacuation_candidates); |
723 | 723 |
724 int count = 0; | 724 int count = 0; |
725 int fragmentation = 0; | 725 int fragmentation = 0; |
| 726 int page_number = 0; |
726 Candidate* least = NULL; | 727 Candidate* least = NULL; |
727 | 728 |
728 PageIterator it(space); | 729 PageIterator it(space); |
729 while (it.has_next()) { | 730 while (it.has_next()) { |
730 Page* p = it.next(); | 731 Page* p = it.next(); |
731 if (p->NeverEvacuate()) continue; | 732 if (p->NeverEvacuate()) continue; |
732 | 733 |
733 // Invariant: Evacuation candidates are just created when marking is | 734 // Invariant: Evacuation candidates are just created when marking is |
734 // started. At the end of a GC all evacuation candidates are cleared and | 735 // started. At the end of a GC all evacuation candidates are cleared and |
735 // their slot buffers are released. | 736 // their slot buffers are released. |
736 CHECK(!p->IsEvacuationCandidate()); | 737 CHECK(!p->IsEvacuationCandidate()); |
737 CHECK(p->slots_buffer() == NULL); | 738 CHECK(p->slots_buffer() == NULL); |
738 | 739 |
739 if (FLAG_stress_compaction) { | 740 if (FLAG_stress_compaction) { |
740 unsigned int counter = space->heap()->ms_count(); | 741 if (FLAG_manual_evacuation_candidates_selection) { |
741 uintptr_t page_number = reinterpret_cast<uintptr_t>(p) >> kPageSizeBits; | 742 if (p->IsFlagSet(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING)) { |
742 if ((counter & 1) == (page_number & 1)) fragmentation = 1; | 743 p->ClearFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); |
| 744 fragmentation = 1; |
| 745 } |
| 746 } else { |
| 747 unsigned int counter = space->heap()->ms_count(); |
| 748 if ((counter & 1) == (page_number & 1)) fragmentation = 1; |
| 749 page_number++; |
| 750 } |
743 } else if (mode == REDUCE_MEMORY_FOOTPRINT && !FLAG_always_compact) { | 751 } else if (mode == REDUCE_MEMORY_FOOTPRINT && !FLAG_always_compact) { |
744 // Don't try to release too many pages. | 752 // Don't try to release too many pages. |
745 if (estimated_release >= over_reserved) { | 753 if (estimated_release >= over_reserved) { |
746 continue; | 754 continue; |
747 } | 755 } |
748 | 756 |
749 intptr_t free_bytes = 0; | 757 intptr_t free_bytes = 0; |
750 | 758 |
751 if (!p->WasSwept()) { | 759 if (!p->WasSwept()) { |
752 free_bytes = (p->area_size() - p->LiveBytes()); | 760 free_bytes = (p->area_size() - p->LiveBytes()); |
(...skipping 3876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4629 SlotsBuffer* buffer = *buffer_address; | 4637 SlotsBuffer* buffer = *buffer_address; |
4630 while (buffer != NULL) { | 4638 while (buffer != NULL) { |
4631 SlotsBuffer* next_buffer = buffer->next(); | 4639 SlotsBuffer* next_buffer = buffer->next(); |
4632 DeallocateBuffer(buffer); | 4640 DeallocateBuffer(buffer); |
4633 buffer = next_buffer; | 4641 buffer = next_buffer; |
4634 } | 4642 } |
4635 *buffer_address = NULL; | 4643 *buffer_address = NULL; |
4636 } | 4644 } |
4637 } | 4645 } |
4638 } // namespace v8::internal | 4646 } // namespace v8::internal |
OLD | NEW |