Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/heap/mark-compact.cc

Issue 1073123002: Speculative fix for stack overflow in CollectEvacuationCandidates (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 PrintF( 757 PrintF(
758 "Estimated over reserved memory: %.1f / %.1f MB (threshold %d), " 758 "Estimated over reserved memory: %.1f / %.1f MB (threshold %d), "
759 "evacuation candidate limit: %d\n", 759 "evacuation candidate limit: %d\n",
760 static_cast<double>(over_reserved) / MB, 760 static_cast<double>(over_reserved) / MB,
761 static_cast<double>(reserved) / MB, 761 static_cast<double>(reserved) / MB,
762 static_cast<int>(kFreenessThreshold), max_evacuation_candidates); 762 static_cast<int>(kFreenessThreshold), max_evacuation_candidates);
763 } 763 }
764 764
765 intptr_t estimated_release = 0; 765 intptr_t estimated_release = 0;
766 766
767 Candidate candidates[kMaxMaxEvacuationCandidates];
768
769 if (FLAG_trace_fragmentation && 767 if (FLAG_trace_fragmentation &&
770 max_evacuation_candidates >= kMaxMaxEvacuationCandidates) { 768 max_evacuation_candidates >= kMaxMaxEvacuationCandidates) {
771 PrintF("Hit max page compaction limit of %d pages\n", 769 PrintF("Hit max page compaction limit of %d pages\n",
772 kMaxMaxEvacuationCandidates); 770 kMaxMaxEvacuationCandidates);
773 } 771 }
774 max_evacuation_candidates = 772 max_evacuation_candidates =
775 Min(kMaxMaxEvacuationCandidates, max_evacuation_candidates); 773 Min(kMaxMaxEvacuationCandidates, max_evacuation_candidates);
776 774
775 std::vector<Candidate> candidates(max_evacuation_candidates);
776
777 int count = 0; 777 int count = 0;
778 int fragmentation = 0; 778 int fragmentation = 0;
779 int page_number = 0; 779 int page_number = 0;
780 Candidate* least = NULL; 780 int least_index = -1;
781 781
782 PageIterator it(space); 782 PageIterator it(space);
783 while (it.has_next()) { 783 while (it.has_next()) {
784 Page* p = it.next(); 784 Page* p = it.next();
785 if (p->NeverEvacuate()) continue; 785 if (p->NeverEvacuate()) continue;
786 786
787 // Invariant: Evacuation candidates are just created when marking is 787 // Invariant: Evacuation candidates are just created when marking is
788 // started. At the end of a GC all evacuation candidates are cleared and 788 // started. At the end of a GC all evacuation candidates are cleared and
789 // their slot buffers are released. 789 // their slot buffers are released.
790 CHECK(!p->IsEvacuationCandidate()); 790 CHECK(!p->IsEvacuationCandidate());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 (fragmentation > 0) ? "[fragmented]" : ""); 834 (fragmentation > 0) ? "[fragmented]" : "");
835 } 835 }
836 } else { 836 } else {
837 fragmentation = FreeListFragmentation(space, p); 837 fragmentation = FreeListFragmentation(space, p);
838 } 838 }
839 839
840 if (fragmentation != 0) { 840 if (fragmentation != 0) {
841 if (count < max_evacuation_candidates) { 841 if (count < max_evacuation_candidates) {
842 candidates[count++] = Candidate(fragmentation, p); 842 candidates[count++] = Candidate(fragmentation, p);
843 } else { 843 } else {
844 if (least == NULL) { 844 if (least_index == -1) {
845 for (int i = 0; i < max_evacuation_candidates; i++) { 845 for (int i = 0; i < max_evacuation_candidates; i++) {
846 if (least == NULL || 846 if (least_index == -1 ||
847 candidates[i].fragmentation() < least->fragmentation()) { 847 candidates[i].fragmentation() <
848 least = candidates + i; 848 candidates[least_index].fragmentation()) {
849 least_index = i;
849 } 850 }
850 } 851 }
851 } 852 }
852 if (least->fragmentation() < fragmentation) { 853 if (candidates[least_index].fragmentation() < fragmentation) {
853 *least = Candidate(fragmentation, p); 854 candidates[least_index] = Candidate(fragmentation, p);
854 least = NULL; 855 least_index = -1;
855 } 856 }
856 } 857 }
857 } 858 }
858 } 859 }
859 860
860 for (int i = 0; i < count; i++) { 861 for (int i = 0; i < count; i++) {
861 AddEvacuationCandidate(candidates[i].page()); 862 AddEvacuationCandidate(candidates[i].page());
862 } 863 }
863 864
864 if (count > 0 && FLAG_trace_fragmentation) { 865 if (count > 0 && FLAG_trace_fragmentation) {
(...skipping 3899 matching lines...) Expand 10 before | Expand all | Expand 10 after
4764 SlotsBuffer* buffer = *buffer_address; 4765 SlotsBuffer* buffer = *buffer_address;
4765 while (buffer != NULL) { 4766 while (buffer != NULL) {
4766 SlotsBuffer* next_buffer = buffer->next(); 4767 SlotsBuffer* next_buffer = buffer->next();
4767 DeallocateBuffer(buffer); 4768 DeallocateBuffer(buffer);
4768 buffer = next_buffer; 4769 buffer = next_buffer;
4769 } 4770 }
4770 *buffer_address = NULL; 4771 *buffer_address = NULL;
4771 } 4772 }
4772 } 4773 }
4773 } // namespace v8::internal 4774 } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698