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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/gc-idle-time-handler.h ('k') | src/heap/heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/gc-idle-time-handler.cc
diff --git a/src/heap/gc-idle-time-handler.cc b/src/heap/gc-idle-time-handler.cc
index 83e95acc0526f5c46740b1e8ddc4f32619577a14..5ff4017c233f071b742974b9fcf242609de03de3 100644
--- a/src/heap/gc-idle-time-handler.cc
+++ b/src/heap/gc-idle-time-handler.cc
@@ -1,9 +1,6 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <climits>
-
-#include "src/v8.h"
#include "src/heap/gc-idle-time-handler.h"
@@ -14,8 +11,8 @@ namespace internal {
const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9;
-intptr_t GCIdleTimeHandler::EstimateMarkingStepSize(
- int idle_time_in_ms, intptr_t marking_speed_in_bytes_per_ms) {
+size_t GCIdleTimeHandler::EstimateMarkingStepSize(
+ size_t idle_time_in_ms, size_t marking_speed_in_bytes_per_ms) {
DCHECK(idle_time_in_ms > 0);
if (marking_speed_in_bytes_per_ms == 0) {
@@ -23,15 +20,17 @@ intptr_t GCIdleTimeHandler::EstimateMarkingStepSize(
GCIdleTimeHandler::kInitialConservativeMarkingSpeed;
}
- intptr_t marking_step_size = marking_speed_in_bytes_per_ms * idle_time_in_ms;
- if (static_cast<intptr_t>(marking_step_size / idle_time_in_ms) !=
- marking_speed_in_bytes_per_ms) {
+ size_t marking_step_size = marking_speed_in_bytes_per_ms * idle_time_in_ms;
+ if (marking_step_size / marking_speed_in_bytes_per_ms != idle_time_in_ms) {
// In the case of an overflow we return maximum marking step size.
- return INT_MAX;
+ return GCIdleTimeHandler::kMaximumMarkingStepSize;
}
- return static_cast<intptr_t>(marking_step_size *
- GCIdleTimeHandler::kConservativeTimeRatio);
+ if (marking_step_size > kMaximumMarkingStepSize)
+ return kMaximumMarkingStepSize;
+
+ return static_cast<size_t>(marking_step_size *
+ GCIdleTimeHandler::kConservativeTimeRatio);
}
}
}
« 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