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 "test/heap-unittests/heap-unittest.h" | 5 #include "test/heap-unittests/heap-unittest.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); | 100 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); |
101 } | 101 } |
102 | 102 |
103 | 103 |
104 TEST_F(GCIdleTimeHandlerTest, IncrementalMarking1) { | 104 TEST_F(GCIdleTimeHandlerTest, IncrementalMarking1) { |
105 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 105 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
106 size_t speed = heap_state.incremental_marking_speed_in_bytes_per_ms; | 106 size_t speed = heap_state.incremental_marking_speed_in_bytes_per_ms; |
107 int idle_time_ms = 10; | 107 int idle_time_ms = 10; |
108 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 108 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
109 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); | 109 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); |
110 EXPECT_GT(speed * idle_time_ms, action.parameter); | 110 EXPECT_GT(speed * static_cast<size_t>(idle_time_ms), |
| 111 static_cast<size_t>(action.parameter)); |
111 EXPECT_LT(0, action.parameter); | 112 EXPECT_LT(0, action.parameter); |
112 } | 113 } |
113 | 114 |
114 | 115 |
115 TEST_F(GCIdleTimeHandlerTest, IncrementalMarking2) { | 116 TEST_F(GCIdleTimeHandlerTest, IncrementalMarking2) { |
116 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 117 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
117 heap_state.incremental_marking_stopped = true; | 118 heap_state.incremental_marking_stopped = true; |
118 size_t speed = heap_state.incremental_marking_speed_in_bytes_per_ms; | 119 size_t speed = heap_state.incremental_marking_speed_in_bytes_per_ms; |
119 int idle_time_ms = 10; | 120 int idle_time_ms = 10; |
120 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 121 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
121 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); | 122 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); |
122 EXPECT_GT(speed * idle_time_ms, action.parameter); | 123 EXPECT_GT(speed * static_cast<size_t>(idle_time_ms), |
| 124 static_cast<size_t>(action.parameter)); |
123 EXPECT_LT(0, action.parameter); | 125 EXPECT_LT(0, action.parameter); |
124 } | 126 } |
125 | 127 |
126 | 128 |
127 TEST_F(GCIdleTimeHandlerTest, NotEnoughTime) { | 129 TEST_F(GCIdleTimeHandlerTest, NotEnoughTime) { |
128 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 130 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
129 heap_state.incremental_marking_stopped = true; | 131 heap_state.incremental_marking_stopped = true; |
130 heap_state.can_start_incremental_marking = false; | 132 heap_state.can_start_incremental_marking = false; |
131 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; | 133 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; |
132 int idle_time_ms = heap_state.size_of_objects / speed - 1; | 134 int idle_time_ms = heap_state.size_of_objects / speed - 1; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { | 203 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { |
202 handler()->NotifyScavenge(); | 204 handler()->NotifyScavenge(); |
203 } | 205 } |
204 action = handler()->Compute(idle_time_ms, heap_state); | 206 action = handler()->Compute(idle_time_ms, heap_state); |
205 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); | 207 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); |
206 } | 208 } |
207 | 209 |
208 | 210 |
209 } // namespace internal | 211 } // namespace internal |
210 } // namespace v8 | 212 } // namespace v8 |
OLD | NEW |