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 3293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3304 } | 3304 } |
3305 p->ResetLiveBytes(); | 3305 p->ResetLiveBytes(); |
3306 return true; | 3306 return true; |
3307 } | 3307 } |
3308 | 3308 |
3309 | 3309 |
3310 int MarkCompactCollector::NumberOfParallelCompactionTasks() { | 3310 int MarkCompactCollector::NumberOfParallelCompactionTasks() { |
3311 if (!FLAG_parallel_compaction) return 1; | 3311 if (!FLAG_parallel_compaction) return 1; |
3312 // We cap the number of parallel compaction tasks by | 3312 // We cap the number of parallel compaction tasks by |
3313 // - (#cores - 1) | 3313 // - (#cores - 1) |
3314 // - a value depending on the list of evacuation candidates | 3314 // - a value depending on the live memory in evacuation candidates |
3315 // - a hard limit | 3315 // - a hard limit |
3316 const int kPagesPerCompactionTask = 4; | 3316 const int kLiveMemoryPerCompactionTask = 2 * Page::kPageSize; |
Hannes Payer (out of office)
2015/11/02 23:44:38
We could get a better bound here if we would use o
Michael Lippautz
2015/11/02 23:48:48
Done.
| |
3317 const int kMaxCompactionTasks = 8; | 3317 const int kMaxCompactionTasks = 8; |
3318 int live_bytes = 0; | |
3319 for (Page* page : evacuation_candidates_) { | |
3320 live_bytes += page->LiveBytes(); | |
3321 } | |
3318 return Min(kMaxCompactionTasks, | 3322 return Min(kMaxCompactionTasks, |
3319 Min(1 + evacuation_candidates_.length() / kPagesPerCompactionTask, | 3323 Min(1 + live_bytes / kLiveMemoryPerCompactionTask, |
3320 Max(1, base::SysInfo::NumberOfProcessors() - 1))); | 3324 Max(1, base::SysInfo::NumberOfProcessors() - 1))); |
3321 } | 3325 } |
3322 | 3326 |
3323 | 3327 |
3324 void MarkCompactCollector::EvacuatePagesInParallel() { | 3328 void MarkCompactCollector::EvacuatePagesInParallel() { |
3325 const int num_pages = evacuation_candidates_.length(); | 3329 const int num_pages = evacuation_candidates_.length(); |
3326 if (num_pages == 0) return; | 3330 if (num_pages == 0) return; |
3327 | 3331 |
3328 const int num_tasks = NumberOfParallelCompactionTasks(); | 3332 const int num_tasks = NumberOfParallelCompactionTasks(); |
3329 | 3333 |
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4592 MarkBit mark_bit = Marking::MarkBitFrom(host); | 4596 MarkBit mark_bit = Marking::MarkBitFrom(host); |
4593 if (Marking::IsBlack(mark_bit)) { | 4597 if (Marking::IsBlack(mark_bit)) { |
4594 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); | 4598 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); |
4595 RecordRelocSlot(&rinfo, target); | 4599 RecordRelocSlot(&rinfo, target); |
4596 } | 4600 } |
4597 } | 4601 } |
4598 } | 4602 } |
4599 | 4603 |
4600 } // namespace internal | 4604 } // namespace internal |
4601 } // namespace v8 | 4605 } // namespace v8 |
OLD | NEW |