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

Side by Side Diff: src/heap/gc-idle-time-handler.cc

Issue 490943002: Use size_t in GCIdleTimeHandler to fix undefined behaviour. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap/gc-idle-time-handler.h ('k') | src/heap/heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 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 #include <climits>
5
6 #include "src/v8.h"
7 4
8 #include "src/heap/gc-idle-time-handler.h" 5 #include "src/heap/gc-idle-time-handler.h"
9 6
10 namespace v8 { 7 namespace v8 {
11 namespace internal { 8 namespace internal {
12 9
13 10
14 const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9; 11 const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9;
15 12
16 13
17 intptr_t GCIdleTimeHandler::EstimateMarkingStepSize( 14 size_t GCIdleTimeHandler::EstimateMarkingStepSize(
18 int idle_time_in_ms, intptr_t marking_speed_in_bytes_per_ms) { 15 size_t idle_time_in_ms, size_t marking_speed_in_bytes_per_ms) {
19 DCHECK(idle_time_in_ms > 0); 16 DCHECK(idle_time_in_ms > 0);
20 17
21 if (marking_speed_in_bytes_per_ms == 0) { 18 if (marking_speed_in_bytes_per_ms == 0) {
22 marking_speed_in_bytes_per_ms = 19 marking_speed_in_bytes_per_ms =
23 GCIdleTimeHandler::kInitialConservativeMarkingSpeed; 20 GCIdleTimeHandler::kInitialConservativeMarkingSpeed;
24 } 21 }
25 22
26 intptr_t marking_step_size = marking_speed_in_bytes_per_ms * idle_time_in_ms; 23 size_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) != 24 if (marking_step_size / marking_speed_in_bytes_per_ms != idle_time_in_ms) {
28 marking_speed_in_bytes_per_ms) {
29 // In the case of an overflow we return maximum marking step size. 25 // In the case of an overflow we return maximum marking step size.
30 return INT_MAX; 26 return GCIdleTimeHandler::kMaximumMarkingStepSize;
31 } 27 }
32 28
33 return static_cast<intptr_t>(marking_step_size * 29 if (marking_step_size > kMaximumMarkingStepSize)
34 GCIdleTimeHandler::kConservativeTimeRatio); 30 return kMaximumMarkingStepSize;
31
32 return static_cast<size_t>(marking_step_size *
33 GCIdleTimeHandler::kConservativeTimeRatio);
35 } 34 }
36 } 35 }
37 } 36 }
OLDNEW
« no previous file with comments | « src/heap/gc-idle-time-handler.h ('k') | src/heap/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698