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 <limits> | 5 #include <limits> |
6 | 6 |
7 #include "src/heap/gc-idle-time-handler.h" | 7 #include "src/heap/gc-idle-time-handler.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 size_t idle_time_in_ms = 1; | 191 size_t idle_time_in_ms = 1; |
192 EXPECT_FALSE(GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact( | 192 EXPECT_FALSE(GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact( |
193 idle_time_in_ms, kSizeOfObjects, kMarkingSpeed)); | 193 idle_time_in_ms, kSizeOfObjects, kMarkingSpeed)); |
194 } | 194 } |
195 | 195 |
196 | 196 |
197 TEST_F(GCIdleTimeHandlerTest, ContextDisposeLowRate) { | 197 TEST_F(GCIdleTimeHandlerTest, ContextDisposeLowRate) { |
198 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 198 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
199 heap_state.contexts_disposed = 1; | 199 heap_state.contexts_disposed = 1; |
200 heap_state.incremental_marking_stopped = true; | 200 heap_state.incremental_marking_stopped = true; |
201 int idle_time_ms = 0; | 201 double idle_time_ms = 0; |
202 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 202 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
203 EXPECT_EQ(DO_NOTHING, action.type); | 203 EXPECT_EQ(DO_NOTHING, action.type); |
204 } | 204 } |
205 | 205 |
206 | 206 |
207 TEST_F(GCIdleTimeHandlerTest, ContextDisposeHighRate) { | 207 TEST_F(GCIdleTimeHandlerTest, ContextDisposeHighRate) { |
208 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 208 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
209 heap_state.contexts_disposed = 1; | 209 heap_state.contexts_disposed = 1; |
210 heap_state.contexts_disposal_rate = | 210 heap_state.contexts_disposal_rate = |
211 GCIdleTimeHandler::kHighContextDisposalRate - 1; | 211 GCIdleTimeHandler::kHighContextDisposalRate - 1; |
212 heap_state.incremental_marking_stopped = true; | 212 heap_state.incremental_marking_stopped = true; |
213 int idle_time_ms = 0; | 213 double idle_time_ms = 0; |
214 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 214 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
215 EXPECT_EQ(DO_FULL_GC, action.type); | 215 EXPECT_EQ(DO_FULL_GC, action.type); |
216 } | 216 } |
217 | 217 |
218 | 218 |
219 TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeLargeIdleTime) { | 219 TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeLargeIdleTime) { |
220 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 220 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
221 heap_state.contexts_disposed = 1; | 221 heap_state.contexts_disposed = 1; |
222 heap_state.contexts_disposal_rate = 1.0; | 222 heap_state.contexts_disposal_rate = 1.0; |
223 heap_state.incremental_marking_stopped = true; | 223 heap_state.incremental_marking_stopped = true; |
224 heap_state.can_start_incremental_marking = false; | 224 heap_state.can_start_incremental_marking = false; |
225 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; | 225 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; |
226 int idle_time_ms = | 226 double idle_time_ms = |
227 static_cast<int>((heap_state.size_of_objects + speed - 1) / speed); | 227 static_cast<double>((heap_state.size_of_objects + speed - 1) / speed); |
228 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 228 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
229 EXPECT_EQ(DO_FULL_GC, action.type); | 229 EXPECT_EQ(DO_FULL_GC, action.type); |
230 } | 230 } |
231 | 231 |
232 | 232 |
233 TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeZeroIdleTime) { | 233 TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeZeroIdleTime) { |
234 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 234 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
235 heap_state.contexts_disposed = 1; | 235 heap_state.contexts_disposed = 1; |
236 heap_state.contexts_disposal_rate = 1.0; | 236 heap_state.contexts_disposal_rate = 1.0; |
237 heap_state.incremental_marking_stopped = true; | 237 heap_state.incremental_marking_stopped = true; |
238 int idle_time_ms = 0; | 238 double idle_time_ms = 0; |
239 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 239 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
240 EXPECT_EQ(DO_FULL_GC, action.type); | 240 EXPECT_EQ(DO_FULL_GC, action.type); |
241 } | 241 } |
242 | 242 |
243 | 243 |
244 TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime1) { | 244 TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime1) { |
245 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 245 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
246 heap_state.contexts_disposed = 1; | 246 heap_state.contexts_disposed = 1; |
247 heap_state.contexts_disposal_rate = 1.0; | 247 heap_state.contexts_disposal_rate = 1.0; |
248 heap_state.incremental_marking_stopped = true; | 248 heap_state.incremental_marking_stopped = true; |
249 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; | 249 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; |
250 int idle_time_ms = static_cast<int>(heap_state.size_of_objects / speed - 1); | 250 double idle_time_ms = |
| 251 static_cast<double>(heap_state.size_of_objects / speed - 1); |
251 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 252 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
252 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); | 253 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); |
253 } | 254 } |
254 | 255 |
255 | 256 |
256 TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime2) { | 257 TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime2) { |
257 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 258 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
258 heap_state.contexts_disposed = 1; | 259 heap_state.contexts_disposed = 1; |
259 heap_state.contexts_disposal_rate = 1.0; | 260 heap_state.contexts_disposal_rate = 1.0; |
260 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; | 261 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; |
261 int idle_time_ms = static_cast<int>(heap_state.size_of_objects / speed - 1); | 262 double idle_time_ms = |
| 263 static_cast<double>(heap_state.size_of_objects / speed - 1); |
262 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 264 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
263 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); | 265 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); |
264 } | 266 } |
265 | 267 |
266 | 268 |
267 TEST_F(GCIdleTimeHandlerTest, IncrementalMarking1) { | 269 TEST_F(GCIdleTimeHandlerTest, IncrementalMarking1) { |
268 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 270 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
269 size_t speed = heap_state.incremental_marking_speed_in_bytes_per_ms; | 271 size_t speed = heap_state.incremental_marking_speed_in_bytes_per_ms; |
270 int idle_time_ms = 10; | 272 double idle_time_ms = 10; |
271 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 273 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
272 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); | 274 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); |
273 EXPECT_GT(speed * static_cast<size_t>(idle_time_ms), | 275 EXPECT_GT(speed * static_cast<size_t>(idle_time_ms), |
274 static_cast<size_t>(action.parameter)); | 276 static_cast<size_t>(action.parameter)); |
275 EXPECT_LT(0, action.parameter); | 277 EXPECT_LT(0, action.parameter); |
276 } | 278 } |
277 | 279 |
278 | 280 |
279 TEST_F(GCIdleTimeHandlerTest, IncrementalMarking2) { | 281 TEST_F(GCIdleTimeHandlerTest, IncrementalMarking2) { |
280 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 282 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
281 heap_state.incremental_marking_stopped = true; | 283 heap_state.incremental_marking_stopped = true; |
282 size_t speed = heap_state.incremental_marking_speed_in_bytes_per_ms; | 284 size_t speed = heap_state.incremental_marking_speed_in_bytes_per_ms; |
283 int idle_time_ms = 10; | 285 double idle_time_ms = 10; |
284 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 286 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
285 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); | 287 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); |
286 EXPECT_GT(speed * static_cast<size_t>(idle_time_ms), | 288 EXPECT_GT(speed * static_cast<size_t>(idle_time_ms), |
287 static_cast<size_t>(action.parameter)); | 289 static_cast<size_t>(action.parameter)); |
288 EXPECT_LT(0, action.parameter); | 290 EXPECT_LT(0, action.parameter); |
289 } | 291 } |
290 | 292 |
291 | 293 |
292 TEST_F(GCIdleTimeHandlerTest, NotEnoughTime) { | 294 TEST_F(GCIdleTimeHandlerTest, NotEnoughTime) { |
293 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 295 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
294 heap_state.incremental_marking_stopped = true; | 296 heap_state.incremental_marking_stopped = true; |
295 heap_state.can_start_incremental_marking = false; | 297 heap_state.can_start_incremental_marking = false; |
296 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; | 298 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; |
297 int idle_time_ms = static_cast<int>(heap_state.size_of_objects / speed - 1); | 299 double idle_time_ms = |
| 300 static_cast<double>(heap_state.size_of_objects / speed - 1); |
298 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 301 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
299 EXPECT_EQ(DO_NOTHING, action.type); | 302 EXPECT_EQ(DO_NOTHING, action.type); |
300 } | 303 } |
301 | 304 |
302 | 305 |
303 TEST_F(GCIdleTimeHandlerTest, StopEventually1) { | 306 TEST_F(GCIdleTimeHandlerTest, StopEventually1) { |
304 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 307 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
305 heap_state.incremental_marking_stopped = true; | 308 heap_state.incremental_marking_stopped = true; |
306 heap_state.can_start_incremental_marking = false; | 309 heap_state.can_start_incremental_marking = false; |
307 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; | 310 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; |
308 int idle_time_ms = static_cast<int>(heap_state.size_of_objects / speed + 1); | 311 double idle_time_ms = |
| 312 static_cast<double>(heap_state.size_of_objects / speed + 1); |
309 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { | 313 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { |
310 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 314 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
311 EXPECT_EQ(DO_FULL_GC, action.type); | 315 EXPECT_EQ(DO_FULL_GC, action.type); |
312 handler()->NotifyIdleMarkCompact(); | 316 handler()->NotifyIdleMarkCompact(); |
313 } | 317 } |
314 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 318 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
315 EXPECT_EQ(DONE, action.type); | 319 EXPECT_EQ(DONE, action.type); |
316 } | 320 } |
317 | 321 |
318 | 322 |
319 TEST_F(GCIdleTimeHandlerTest, StopEventually2) { | 323 TEST_F(GCIdleTimeHandlerTest, StopEventually2) { |
320 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 324 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
321 int idle_time_ms = 10; | 325 double idle_time_ms = 10; |
322 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { | 326 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { |
323 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 327 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
324 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); | 328 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); |
325 // In this case we emulate incremental marking steps that finish with a | 329 // In this case we emulate incremental marking steps that finish with a |
326 // full gc. | 330 // full gc. |
327 handler()->NotifyIdleMarkCompact(); | 331 handler()->NotifyIdleMarkCompact(); |
328 } | 332 } |
329 heap_state.can_start_incremental_marking = false; | 333 heap_state.can_start_incremental_marking = false; |
330 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 334 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
331 EXPECT_EQ(DONE, action.type); | 335 EXPECT_EQ(DONE, action.type); |
332 } | 336 } |
333 | 337 |
334 | 338 |
335 TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop1) { | 339 TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop1) { |
336 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 340 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
337 heap_state.incremental_marking_stopped = true; | 341 heap_state.incremental_marking_stopped = true; |
338 heap_state.can_start_incremental_marking = false; | 342 heap_state.can_start_incremental_marking = false; |
339 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; | 343 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; |
340 int idle_time_ms = static_cast<int>(heap_state.size_of_objects / speed + 1); | 344 double idle_time_ms = |
| 345 static_cast<double>(heap_state.size_of_objects / speed + 1); |
341 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { | 346 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { |
342 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 347 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
343 EXPECT_EQ(DO_FULL_GC, action.type); | 348 EXPECT_EQ(DO_FULL_GC, action.type); |
344 handler()->NotifyIdleMarkCompact(); | 349 handler()->NotifyIdleMarkCompact(); |
345 } | 350 } |
346 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 351 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
347 EXPECT_EQ(DONE, action.type); | 352 EXPECT_EQ(DONE, action.type); |
348 // Emulate mutator work. | 353 // Emulate mutator work. |
349 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { | 354 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { |
350 handler()->NotifyScavenge(); | 355 handler()->NotifyScavenge(); |
351 } | 356 } |
352 action = handler()->Compute(idle_time_ms, heap_state); | 357 action = handler()->Compute(idle_time_ms, heap_state); |
353 EXPECT_EQ(DO_FULL_GC, action.type); | 358 EXPECT_EQ(DO_FULL_GC, action.type); |
354 } | 359 } |
355 | 360 |
356 | 361 |
357 TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop2) { | 362 TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop2) { |
358 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 363 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
359 int idle_time_ms = 10; | 364 double idle_time_ms = 10; |
360 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { | 365 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { |
361 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 366 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
362 if (action.type == DONE) break; | 367 if (action.type == DONE) break; |
363 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); | 368 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); |
364 // In this case we try to emulate incremental marking steps the finish with | 369 // In this case we try to emulate incremental marking steps the finish with |
365 // a full gc. | 370 // a full gc. |
366 handler()->NotifyIdleMarkCompact(); | 371 handler()->NotifyIdleMarkCompact(); |
367 } | 372 } |
368 heap_state.can_start_incremental_marking = false; | 373 heap_state.can_start_incremental_marking = false; |
369 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 374 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
370 EXPECT_EQ(DONE, action.type); | 375 EXPECT_EQ(DONE, action.type); |
371 // Emulate mutator work. | 376 // Emulate mutator work. |
372 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { | 377 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { |
373 handler()->NotifyScavenge(); | 378 handler()->NotifyScavenge(); |
374 } | 379 } |
375 heap_state.can_start_incremental_marking = true; | 380 heap_state.can_start_incremental_marking = true; |
376 action = handler()->Compute(idle_time_ms, heap_state); | 381 action = handler()->Compute(idle_time_ms, heap_state); |
377 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); | 382 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); |
378 } | 383 } |
379 | 384 |
380 | 385 |
381 TEST_F(GCIdleTimeHandlerTest, Scavenge) { | 386 TEST_F(GCIdleTimeHandlerTest, Scavenge) { |
382 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 387 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
383 int idle_time_ms = 10; | 388 int idle_time_ms = 10; |
384 heap_state.used_new_space_size = | 389 heap_state.used_new_space_size = |
385 heap_state.new_space_capacity - | 390 heap_state.new_space_capacity - |
386 (kNewSpaceAllocationThroughput * idle_time_ms); | 391 (kNewSpaceAllocationThroughput * idle_time_ms); |
387 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 392 GCIdleTimeAction action = |
| 393 handler()->Compute(static_cast<double>(idle_time_ms), heap_state); |
388 EXPECT_EQ(DO_SCAVENGE, action.type); | 394 EXPECT_EQ(DO_SCAVENGE, action.type); |
389 } | 395 } |
390 | 396 |
391 | 397 |
392 TEST_F(GCIdleTimeHandlerTest, ScavengeAndDone) { | 398 TEST_F(GCIdleTimeHandlerTest, ScavengeAndDone) { |
393 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 399 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
394 int idle_time_ms = 10; | 400 int idle_time_ms = 10; |
395 heap_state.can_start_incremental_marking = false; | 401 heap_state.can_start_incremental_marking = false; |
396 heap_state.incremental_marking_stopped = true; | 402 heap_state.incremental_marking_stopped = true; |
397 heap_state.used_new_space_size = | 403 heap_state.used_new_space_size = |
398 heap_state.new_space_capacity - | 404 heap_state.new_space_capacity - |
399 (kNewSpaceAllocationThroughput * idle_time_ms); | 405 (kNewSpaceAllocationThroughput * idle_time_ms); |
400 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 406 GCIdleTimeAction action = |
| 407 handler()->Compute(static_cast<double>(idle_time_ms), heap_state); |
401 EXPECT_EQ(DO_SCAVENGE, action.type); | 408 EXPECT_EQ(DO_SCAVENGE, action.type); |
402 heap_state.used_new_space_size = 0; | 409 heap_state.used_new_space_size = 0; |
403 action = handler()->Compute(idle_time_ms, heap_state); | 410 action = handler()->Compute(static_cast<double>(idle_time_ms), heap_state); |
404 EXPECT_EQ(DO_NOTHING, action.type); | 411 EXPECT_EQ(DO_NOTHING, action.type); |
405 } | 412 } |
406 | 413 |
407 | 414 |
408 TEST_F(GCIdleTimeHandlerTest, ZeroIdleTimeNothingToDo) { | 415 TEST_F(GCIdleTimeHandlerTest, ZeroIdleTimeNothingToDo) { |
409 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 416 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
410 int idle_time_ms = 0; | 417 double idle_time_ms = 0; |
411 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 418 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
412 EXPECT_EQ(DO_NOTHING, action.type); | 419 EXPECT_EQ(DO_NOTHING, action.type); |
413 } | 420 } |
414 | 421 |
415 | 422 |
416 TEST_F(GCIdleTimeHandlerTest, ZeroIdleTimeDoNothingButStartIdleRound) { | 423 TEST_F(GCIdleTimeHandlerTest, ZeroIdleTimeDoNothingButStartIdleRound) { |
417 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 424 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
418 int idle_time_ms = 10; | 425 double idle_time_ms = 10; |
419 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { | 426 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { |
420 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 427 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
421 if (action.type == DONE) break; | 428 if (action.type == DONE) break; |
422 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); | 429 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); |
423 // In this case we try to emulate incremental marking steps the finish with | 430 // In this case we try to emulate incremental marking steps the finish with |
424 // a full gc. | 431 // a full gc. |
425 handler()->NotifyIdleMarkCompact(); | 432 handler()->NotifyIdleMarkCompact(); |
426 } | 433 } |
427 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 434 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
428 // Emulate mutator work. | 435 // Emulate mutator work. |
429 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { | 436 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { |
430 handler()->NotifyScavenge(); | 437 handler()->NotifyScavenge(); |
431 } | 438 } |
432 action = handler()->Compute(0, heap_state); | 439 action = handler()->Compute(0, heap_state); |
433 EXPECT_EQ(DO_NOTHING, action.type); | 440 EXPECT_EQ(DO_NOTHING, action.type); |
434 } | 441 } |
435 | 442 |
436 } // namespace internal | 443 } // namespace internal |
437 } // namespace v8 | 444 } // namespace v8 |
OLD | NEW |