| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 | 350 |
| 351 void Heap::collectGarbage(BlinkGC::StackState stackState, BlinkGC::GCType gcType
, BlinkGC::GCReason reason) | 351 void Heap::collectGarbage(BlinkGC::StackState stackState, BlinkGC::GCType gcType
, BlinkGC::GCReason reason) |
| 352 { | 352 { |
| 353 ASSERT(gcType != BlinkGC::ThreadTerminationGC); | 353 ASSERT(gcType != BlinkGC::ThreadTerminationGC); |
| 354 | 354 |
| 355 ThreadState* state = ThreadState::current(); | 355 ThreadState* state = ThreadState::current(); |
| 356 // Nested collectGarbage() invocations aren't supported. | 356 // Nested collectGarbage() invocations aren't supported. |
| 357 RELEASE_ASSERT(!state->isGCForbidden()); | 357 RELEASE_ASSERT(!state->isGCForbidden()); |
| 358 state->completeSweep(); | 358 state->completeSweep(); |
| 359 | 359 |
| 360 VisitorScope visitorScope(state, gcType); | 360 OwnPtr<Visitor> visitor = Visitor::create(state, gcType); |
| 361 | 361 |
| 362 SafePointScope safePointScope(stackState, state); | 362 SafePointScope safePointScope(stackState, state); |
| 363 | 363 |
| 364 // Resume all parked threads upon leaving this scope. | 364 // Resume all parked threads upon leaving this scope. |
| 365 ParkThreadsScope parkThreadsScope; | 365 ParkThreadsScope parkThreadsScope; |
| 366 | 366 |
| 367 // Try to park the other threads. If we're unable to, bail out of the GC. | 367 // Try to park the other threads. If we're unable to, bail out of the GC. |
| 368 if (!parkThreadsScope.parkThreads(state)) | 368 if (!parkThreadsScope.parkThreads(state)) |
| 369 return; | 369 return; |
| 370 | 370 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 385 | 385 |
| 386 preGC(); | 386 preGC(); |
| 387 | 387 |
| 388 StackFrameDepthScope stackDepthScope; | 388 StackFrameDepthScope stackDepthScope; |
| 389 | 389 |
| 390 size_t totalObjectSize = Heap::allocatedObjectSize() + Heap::markedObjectSiz
e(); | 390 size_t totalObjectSize = Heap::allocatedObjectSize() + Heap::markedObjectSiz
e(); |
| 391 if (gcType != BlinkGC::TakeSnapshot) | 391 if (gcType != BlinkGC::TakeSnapshot) |
| 392 Heap::resetHeapCounters(); | 392 Heap::resetHeapCounters(); |
| 393 | 393 |
| 394 // 1. Trace persistent roots. | 394 // 1. Trace persistent roots. |
| 395 ThreadState::visitPersistentRoots(visitorScope.visitor()); | 395 ThreadState::visitPersistentRoots(visitor.get()); |
| 396 | 396 |
| 397 // 2. Trace objects reachable from the stack. We do this independent of the | 397 // 2. Trace objects reachable from the stack. We do this independent of the |
| 398 // given stackState since other threads might have a different stack state. | 398 // given stackState since other threads might have a different stack state. |
| 399 ThreadState::visitStackRoots(visitorScope.visitor()); | 399 ThreadState::visitStackRoots(visitor.get()); |
| 400 | 400 |
| 401 // 3. Transitive closure to trace objects including ephemerons. | 401 // 3. Transitive closure to trace objects including ephemerons. |
| 402 processMarkingStack(visitorScope.visitor()); | 402 processMarkingStack(visitor.get()); |
| 403 | 403 |
| 404 postMarkingProcessing(visitorScope.visitor()); | 404 postMarkingProcessing(visitor.get()); |
| 405 globalWeakProcessing(visitorScope.visitor()); | 405 globalWeakProcessing(visitor.get()); |
| 406 | 406 |
| 407 // Now we can delete all orphaned pages because there are no dangling | 407 // Now we can delete all orphaned pages because there are no dangling |
| 408 // pointers to the orphaned pages. (If we have such dangling pointers, | 408 // pointers to the orphaned pages. (If we have such dangling pointers, |
| 409 // we should have crashed during marking before getting here.) | 409 // we should have crashed during marking before getting here.) |
| 410 orphanedPagePool()->decommitOrphanedPages(); | 410 orphanedPagePool()->decommitOrphanedPages(); |
| 411 | 411 |
| 412 double markingTimeInMilliseconds = WTF::currentTimeMS() - startTime; | 412 double markingTimeInMilliseconds = WTF::currentTimeMS() - startTime; |
| 413 s_estimatedMarkingTimePerByte = totalObjectSize ? (markingTimeInMilliseconds
/ 1000 / totalObjectSize) : 0; | 413 s_estimatedMarkingTimePerByte = totalObjectSize ? (markingTimeInMilliseconds
/ 1000 / totalObjectSize) : 0; |
| 414 | 414 |
| 415 #if PRINT_HEAP_STATS | 415 #if PRINT_HEAP_STATS |
| (...skipping 23 matching lines...) Expand all Loading... |
| 439 #endif | 439 #endif |
| 440 } | 440 } |
| 441 | 441 |
| 442 void Heap::collectGarbageForTerminatingThread(ThreadState* state) | 442 void Heap::collectGarbageForTerminatingThread(ThreadState* state) |
| 443 { | 443 { |
| 444 { | 444 { |
| 445 // A thread-specific termination GC must not allow other global GCs to g
o | 445 // A thread-specific termination GC must not allow other global GCs to g
o |
| 446 // ahead while it is running, hence the termination GC does not enter a | 446 // ahead while it is running, hence the termination GC does not enter a |
| 447 // safepoint. VisitorScope will not enter also a safepoint scope for | 447 // safepoint. VisitorScope will not enter also a safepoint scope for |
| 448 // ThreadTerminationGC. | 448 // ThreadTerminationGC. |
| 449 VisitorScope visitorScope(state, BlinkGC::ThreadTerminationGC); | 449 OwnPtr<Visitor> visitor = Visitor::create(state, BlinkGC::ThreadTerminat
ionGC); |
| 450 | 450 |
| 451 ThreadState::NoAllocationScope noAllocationScope(state); | 451 ThreadState::NoAllocationScope noAllocationScope(state); |
| 452 | 452 |
| 453 state->preGC(); | 453 state->preGC(); |
| 454 | 454 |
| 455 // 1. Trace the thread local persistent roots. For thread local GCs we | 455 // 1. Trace the thread local persistent roots. For thread local GCs we |
| 456 // don't trace the stack (ie. no conservative scanning) since this is | 456 // don't trace the stack (ie. no conservative scanning) since this is |
| 457 // only called during thread shutdown where there should be no objects | 457 // only called during thread shutdown where there should be no objects |
| 458 // on the stack. | 458 // on the stack. |
| 459 // We also assume that orphaned pages have no objects reachable from | 459 // We also assume that orphaned pages have no objects reachable from |
| 460 // persistent handles on other threads or CrossThreadPersistents. The | 460 // persistent handles on other threads or CrossThreadPersistents. The |
| 461 // only cases where this could happen is if a subsequent conservative | 461 // only cases where this could happen is if a subsequent conservative |
| 462 // global GC finds a "pointer" on the stack or due to a programming | 462 // global GC finds a "pointer" on the stack or due to a programming |
| 463 // error where an object has a dangling cross-thread pointer to an | 463 // error where an object has a dangling cross-thread pointer to an |
| 464 // object on this heap. | 464 // object on this heap. |
| 465 state->visitPersistents(visitorScope.visitor()); | 465 state->visitPersistents(visitor.get()); |
| 466 | 466 |
| 467 // 2. Trace objects reachable from the thread's persistent roots | 467 // 2. Trace objects reachable from the thread's persistent roots |
| 468 // including ephemerons. | 468 // including ephemerons. |
| 469 processMarkingStack(visitorScope.visitor()); | 469 processMarkingStack(visitor.get()); |
| 470 | 470 |
| 471 postMarkingProcessing(visitorScope.visitor()); | 471 postMarkingProcessing(visitor.get()); |
| 472 globalWeakProcessing(visitorScope.visitor()); | 472 globalWeakProcessing(visitor.get()); |
| 473 | 473 |
| 474 state->postGC(BlinkGC::GCWithSweep); | 474 state->postGC(BlinkGC::GCWithSweep); |
| 475 Heap::decommitCallbackStacks(); | 475 Heap::decommitCallbackStacks(); |
| 476 } | 476 } |
| 477 state->preSweep(); | 477 state->preSweep(); |
| 478 } | 478 } |
| 479 | 479 |
| 480 void Heap::processMarkingStack(Visitor* visitor) | 480 void Heap::processMarkingStack(Visitor* visitor) |
| 481 { | 481 { |
| 482 // Ephemeron fixed point loop. | 482 // Ephemeron fixed point loop. |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 size_t Heap::s_wrapperCountAtLastGC = 0; | 688 size_t Heap::s_wrapperCountAtLastGC = 0; |
| 689 size_t Heap::s_collectedWrapperCount = 0; | 689 size_t Heap::s_collectedWrapperCount = 0; |
| 690 size_t Heap::s_partitionAllocSizeAtLastGC = 0; | 690 size_t Heap::s_partitionAllocSizeAtLastGC = 0; |
| 691 double Heap::s_estimatedMarkingTimePerByte = 0.0; | 691 double Heap::s_estimatedMarkingTimePerByte = 0.0; |
| 692 bool Heap::s_isLowEndDevice = false; | 692 bool Heap::s_isLowEndDevice = false; |
| 693 #if ENABLE(ASSERT) | 693 #if ENABLE(ASSERT) |
| 694 uint16_t Heap::s_gcGeneration = 0; | 694 uint16_t Heap::s_gcGeneration = 0; |
| 695 #endif | 695 #endif |
| 696 | 696 |
| 697 } // namespace blink | 697 } // namespace blink |
| OLD | NEW |