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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 UNREACHABLE(); | 590 UNREACHABLE(); |
591 } | 591 } |
592 | 592 |
593 return NULL; | 593 return NULL; |
594 } | 594 } |
595 | 595 |
596 | 596 |
597 void MarkCompactCollector::ComputeEvacuationHeuristics( | 597 void MarkCompactCollector::ComputeEvacuationHeuristics( |
598 int area_size, int* target_fragmentation_percent, | 598 int area_size, int* target_fragmentation_percent, |
599 int* max_evacuated_bytes) { | 599 int* max_evacuated_bytes) { |
600 // For memory reducing mode we directly define both constants. | 600 // For memory reducing and optimize for memory mode we directly define both |
| 601 // constants. |
601 const int kTargetFragmentationPercentForReduceMemory = 20; | 602 const int kTargetFragmentationPercentForReduceMemory = 20; |
602 const int kMaxEvacuatedBytesForReduceMemory = 12 * Page::kPageSize; | 603 const int kMaxEvacuatedBytesForReduceMemory = 12 * Page::kPageSize; |
| 604 const int kTargetFragmentationPercentForOptimizeMemory = 20; |
| 605 const int kMaxEvacuatedBytesForOptimizeMemory = 6 * MB; |
603 | 606 |
604 // For regular mode (which is latency critical) we define less aggressive | 607 // For regular mode (which is latency critical) we define less aggressive |
605 // defaults to start and switch to a trace-based (using compaction speed) | 608 // defaults to start and switch to a trace-based (using compaction speed) |
606 // approach as soon as we have enough samples. | 609 // approach as soon as we have enough samples. |
607 const int kTargetFragmentationPercent = 70; | 610 const int kTargetFragmentationPercent = 70; |
608 const int kMaxEvacuatedBytes = 4 * Page::kPageSize; | 611 const int kMaxEvacuatedBytes = 4 * Page::kPageSize; |
609 // Time to take for a single area (=payload of page). Used as soon as there | 612 // Time to take for a single area (=payload of page). Used as soon as there |
610 // exist enough compaction speed samples. | 613 // exist enough compaction speed samples. |
611 const int kTargetMsPerArea = 1; | 614 const int kTargetMsPerArea = 1; |
612 | 615 |
613 if (heap()->ShouldReduceMemory()) { | 616 if (heap()->ShouldReduceMemory()) { |
614 *target_fragmentation_percent = kTargetFragmentationPercentForReduceMemory; | 617 *target_fragmentation_percent = kTargetFragmentationPercentForReduceMemory; |
615 *max_evacuated_bytes = kMaxEvacuatedBytesForReduceMemory; | 618 *max_evacuated_bytes = kMaxEvacuatedBytesForReduceMemory; |
| 619 } else if (heap()->ShouldOptimizeForMemoryUsage()) { |
| 620 *target_fragmentation_percent = |
| 621 kTargetFragmentationPercentForOptimizeMemory; |
| 622 *max_evacuated_bytes = kMaxEvacuatedBytesForOptimizeMemory; |
616 } else { | 623 } else { |
617 const double estimated_compaction_speed = | 624 const double estimated_compaction_speed = |
618 heap()->tracer()->CompactionSpeedInBytesPerMillisecond(); | 625 heap()->tracer()->CompactionSpeedInBytesPerMillisecond(); |
619 if (estimated_compaction_speed != 0) { | 626 if (estimated_compaction_speed != 0) { |
620 // Estimate the target fragmentation based on traced compaction speed | 627 // Estimate the target fragmentation based on traced compaction speed |
621 // and a goal for a single page. | 628 // and a goal for a single page. |
622 const double estimated_ms_per_area = | 629 const double estimated_ms_per_area = |
623 1 + area_size / estimated_compaction_speed; | 630 1 + area_size / estimated_compaction_speed; |
624 *target_fragmentation_percent = static_cast<int>( | 631 *target_fragmentation_percent = static_cast<int>( |
625 100 - 100 * kTargetMsPerArea / estimated_ms_per_area); | 632 100 - 100 * kTargetMsPerArea / estimated_ms_per_area); |
(...skipping 3395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4021 // The target is always in old space, we don't have to record the slot in | 4028 // The target is always in old space, we don't have to record the slot in |
4022 // the old-to-new remembered set. | 4029 // the old-to-new remembered set. |
4023 DCHECK(!heap()->InNewSpace(target)); | 4030 DCHECK(!heap()->InNewSpace(target)); |
4024 RecordRelocSlot(host, &rinfo, target); | 4031 RecordRelocSlot(host, &rinfo, target); |
4025 } | 4032 } |
4026 } | 4033 } |
4027 } | 4034 } |
4028 | 4035 |
4029 } // namespace internal | 4036 } // namespace internal |
4030 } // namespace v8 | 4037 } // namespace v8 |
OLD | NEW |