OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 #include <climits> |
| 5 |
| 6 #include "src/v8.h" |
| 7 |
| 8 #include "src/heap/gc-idle-time-handler.h" |
| 9 |
| 10 namespace v8 { |
| 11 namespace internal { |
| 12 |
| 13 |
| 14 const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9; |
| 15 |
| 16 |
| 17 intptr_t GCIdleTimeHandler::EstimateMarkingStepSize( |
| 18 int idle_time_in_ms, intptr_t marking_speed_in_bytes_per_ms) { |
| 19 DCHECK(idle_time_in_ms > 0); |
| 20 |
| 21 if (marking_speed_in_bytes_per_ms == 0) { |
| 22 marking_speed_in_bytes_per_ms = |
| 23 GCIdleTimeHandler::kInitialConservativeMarkingSpeed; |
| 24 } |
| 25 |
| 26 intptr_t marking_step_size = marking_speed_in_bytes_per_ms * idle_time_in_ms; |
| 27 if (static_cast<intptr_t>(marking_step_size / idle_time_in_ms) != |
| 28 marking_speed_in_bytes_per_ms) { |
| 29 // In the case of an overflow we return maximum marking step size. |
| 30 return INT_MAX; |
| 31 } |
| 32 |
| 33 return static_cast<intptr_t>(marking_step_size * |
| 34 GCIdleTimeHandler::kConservativeTimeRatio); |
| 35 } |
| 36 } |
| 37 } |
OLD | NEW |