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

Side by Side Diff: test/unittests/heap/gc-idle-time-handler-unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698