OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef V8_HEAP_SCAVENGE_JOB_H_ | 5 #ifndef V8_HEAP_SCAVENGE_JOB_H_ |
6 #define V8_HEAP_SCAVENGE_JOB_H_ | 6 #define V8_HEAP_SCAVENGE_JOB_H_ |
7 | 7 |
8 #include "src/cancelable-task.h" | 8 #include "src/cancelable-task.h" |
9 #include "src/heap/gc-tracer.h" | 9 #include "src/heap/gc-tracer.h" |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 // Posts an idle task ignoring the bytes allocated, but makes sure | 41 // Posts an idle task ignoring the bytes allocated, but makes sure |
42 // that the new idle task cannot reschedule again. | 42 // that the new idle task cannot reschedule again. |
43 // This prevents infinite rescheduling. | 43 // This prevents infinite rescheduling. |
44 void RescheduleIdleTask(Heap* heap); | 44 void RescheduleIdleTask(Heap* heap); |
45 | 45 |
46 bool IdleTaskPending() { return idle_task_pending_; } | 46 bool IdleTaskPending() { return idle_task_pending_; } |
47 void NotifyIdleTask() { idle_task_pending_ = false; } | 47 void NotifyIdleTask() { idle_task_pending_ = false; } |
48 bool IdleTaskRescheduled() { return idle_task_rescheduled_; } | 48 bool IdleTaskRescheduled() { return idle_task_rescheduled_; } |
49 | 49 |
50 static bool ReachedIdleAllocationLimit(size_t scavenge_speed_in_bytes_per_ms, | 50 static bool ReachedIdleAllocationLimit(double scavenge_speed_in_bytes_per_ms, |
51 size_t new_space_size, | 51 size_t new_space_size, |
52 size_t new_space_capacity); | 52 size_t new_space_capacity); |
53 | 53 |
54 static bool EnoughIdleTimeForScavenge(double idle_time_ms, | 54 static bool EnoughIdleTimeForScavenge(double idle_time_ms, |
55 size_t scavenge_speed_in_bytes_per_ms, | 55 double scavenge_speed_in_bytes_per_ms, |
56 size_t new_space_size); | 56 size_t new_space_size); |
57 | 57 |
58 // If we haven't recorded any scavenger events yet, we use a conservative | 58 // If we haven't recorded any scavenger events yet, we use a conservative |
59 // lower bound for the scavenger speed. | 59 // lower bound for the scavenger speed. |
60 static const int kInitialScavengeSpeedInBytesPerMs = 256 * KB; | 60 static const int kInitialScavengeSpeedInBytesPerMs = 256 * KB; |
61 // Estimate of the average idle time that an idle task gets. | 61 // Estimate of the average idle time that an idle task gets. |
62 static const int kAverageIdleTimeMs = 5; | 62 static const int kAverageIdleTimeMs = 5; |
63 // The number of bytes to be allocated in new space before the next idle | 63 // The number of bytes to be allocated in new space before the next idle |
64 // task is posted. | 64 // task is posted. |
65 static const size_t kBytesAllocatedBeforeNextIdleTask = 512 * KB; | 65 static const size_t kBytesAllocatedBeforeNextIdleTask = 512 * KB; |
66 // The minimum size of allocated new space objects to trigger a scavenge. | 66 // The minimum size of allocated new space objects to trigger a scavenge. |
67 static const size_t kMinAllocationLimit = 512 * KB; | 67 static const size_t kMinAllocationLimit = 512 * KB; |
68 // The allocation limit cannot exceed this fraction of the new space capacity. | 68 // The allocation limit cannot exceed this fraction of the new space capacity. |
69 static const double kMaxAllocationLimitAsFractionOfNewSpace; | 69 static const double kMaxAllocationLimitAsFractionOfNewSpace; |
70 | 70 |
71 private: | 71 private: |
72 void ScheduleIdleTask(Heap* heap); | 72 void ScheduleIdleTask(Heap* heap); |
73 bool idle_task_pending_; | 73 bool idle_task_pending_; |
74 bool idle_task_rescheduled_; | 74 bool idle_task_rescheduled_; |
75 int bytes_allocated_since_the_last_task_; | 75 int bytes_allocated_since_the_last_task_; |
76 }; | 76 }; |
77 } // namespace internal | 77 } // namespace internal |
78 } // namespace v8 | 78 } // namespace v8 |
79 | 79 |
80 #endif // V8_HEAP_SCAVENGE_JOB_H_ | 80 #endif // V8_HEAP_SCAVENGE_JOB_H_ |
OLD | NEW |