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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index 1bbe0e11cc67a7fa923aae0509be776abaf48875..dec953065439827e8c3d60c7dbabb47daf1c0ec4 100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -764,8 +764,6 @@ void MarkCompactCollector::CollectEvacuationCandidates(PagedSpace* space) {
intptr_t estimated_release = 0;
- Candidate candidates[kMaxMaxEvacuationCandidates];
-
if (FLAG_trace_fragmentation &&
max_evacuation_candidates >= kMaxMaxEvacuationCandidates) {
PrintF("Hit max page compaction limit of %d pages\n",
@@ -774,10 +772,12 @@ void MarkCompactCollector::CollectEvacuationCandidates(PagedSpace* space) {
max_evacuation_candidates =
Min(kMaxMaxEvacuationCandidates, max_evacuation_candidates);
+ std::vector<Candidate> candidates(max_evacuation_candidates);
+
int count = 0;
int fragmentation = 0;
int page_number = 0;
- Candidate* least = NULL;
+ int least_index = -1;
PageIterator it(space);
while (it.has_next()) {
@@ -841,17 +841,18 @@ void MarkCompactCollector::CollectEvacuationCandidates(PagedSpace* space) {
if (count < max_evacuation_candidates) {
candidates[count++] = Candidate(fragmentation, p);
} else {
- if (least == NULL) {
+ if (least_index == -1) {
for (int i = 0; i < max_evacuation_candidates; i++) {
- if (least == NULL ||
- candidates[i].fragmentation() < least->fragmentation()) {
- least = candidates + i;
+ if (least_index == -1 ||
+ candidates[i].fragmentation() <
+ candidates[least_index].fragmentation()) {
+ least_index = i;
}
}
}
- if (least->fragmentation() < fragmentation) {
- *least = Candidate(fragmentation, p);
- least = NULL;
+ if (candidates[least_index].fragmentation() < fragmentation) {
+ candidates[least_index] = Candidate(fragmentation, p);
+ least_index = -1;
}
}
}
« 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