| OLD | NEW |
| 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 | 4 |
| 5 #include <climits> | 5 #include <limits> |
| 6 | 6 |
| 7 #include "src/heap/gc-idle-time-handler.h" | 7 #include "src/heap/gc-idle-time-handler.h" |
| 8 | 8 |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeInitial) { | 14 TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeInitial) { |
| 15 intptr_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(1, 0); | 15 size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(1, 0); |
| 16 EXPECT_EQ(static_cast<intptr_t>( | 16 EXPECT_EQ( |
| 17 GCIdleTimeHandler::kInitialConservativeMarkingSpeed * | 17 static_cast<size_t>(GCIdleTimeHandler::kInitialConservativeMarkingSpeed * |
| 18 GCIdleTimeHandler::kConservativeTimeRatio), | 18 GCIdleTimeHandler::kConservativeTimeRatio), |
| 19 step_size); | 19 step_size); |
| 20 } | 20 } |
| 21 | 21 |
| 22 | 22 |
| 23 TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeNonZero) { | 23 TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeNonZero) { |
| 24 intptr_t marking_speed_in_bytes_per_millisecond = 100; | 24 size_t marking_speed_in_bytes_per_millisecond = 100; |
| 25 intptr_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize( | 25 size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize( |
| 26 1, marking_speed_in_bytes_per_millisecond); | 26 1, marking_speed_in_bytes_per_millisecond); |
| 27 EXPECT_EQ(static_cast<intptr_t>(marking_speed_in_bytes_per_millisecond * | 27 EXPECT_EQ(static_cast<size_t>(marking_speed_in_bytes_per_millisecond * |
| 28 GCIdleTimeHandler::kConservativeTimeRatio), | 28 GCIdleTimeHandler::kConservativeTimeRatio), |
| 29 step_size); | 29 step_size); |
| 30 } | 30 } |
| 31 | 31 |
| 32 | 32 |
| 33 TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeOverflow1) { | 33 TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeOverflow1) { |
| 34 intptr_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(10, INT_MAX); | 34 size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize( |
| 35 EXPECT_EQ(INT_MAX, step_size); | 35 10, std::numeric_limits<size_t>::max()); |
| 36 EXPECT_EQ(static_cast<size_t>(GCIdleTimeHandler::kMaximumMarkingStepSize), |
| 37 step_size); |
| 36 } | 38 } |
| 37 | 39 |
| 38 | 40 |
| 39 TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeOverflow2) { | 41 TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeOverflow2) { |
| 40 intptr_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(INT_MAX, 10); | 42 size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize( |
| 41 EXPECT_EQ(INT_MAX, step_size); | 43 std::numeric_limits<size_t>::max(), 10); |
| 44 EXPECT_EQ(static_cast<size_t>(GCIdleTimeHandler::kMaximumMarkingStepSize), |
| 45 step_size); |
| 42 } | 46 } |
| 43 | 47 |
| 44 } // namespace internal | 48 } // namespace internal |
| 45 } // namespace v8 | 49 } // namespace v8 |
| OLD | NEW |