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 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2196 s_postMarkingCallbackStack = new CallbackStack(); | 2196 s_postMarkingCallbackStack = new CallbackStack(); |
2197 s_weakCallbackStack = new CallbackStack(); | 2197 s_weakCallbackStack = new CallbackStack(); |
2198 s_ephemeronStack = new CallbackStack(); | 2198 s_ephemeronStack = new CallbackStack(); |
2199 s_heapDoesNotContainCache = new HeapDoesNotContainCache(); | 2199 s_heapDoesNotContainCache = new HeapDoesNotContainCache(); |
2200 s_markingVisitor = new MarkingVisitor<GlobalMarking>(); | 2200 s_markingVisitor = new MarkingVisitor<GlobalMarking>(); |
2201 s_freePagePool = new FreePagePool(); | 2201 s_freePagePool = new FreePagePool(); |
2202 s_orphanedPagePool = new OrphanedPagePool(); | 2202 s_orphanedPagePool = new OrphanedPagePool(); |
2203 s_allocatedObjectSize = 0; | 2203 s_allocatedObjectSize = 0; |
2204 s_allocatedSpace = 0; | 2204 s_allocatedSpace = 0; |
2205 s_markedObjectSize = 0; | 2205 s_markedObjectSize = 0; |
| 2206 s_markingTimeInLastGC = 0.0; |
2206 | 2207 |
2207 GCInfoTable::init(); | 2208 GCInfoTable::init(); |
2208 } | 2209 } |
2209 | 2210 |
2210 void Heap::shutdown() | 2211 void Heap::shutdown() |
2211 { | 2212 { |
2212 s_shutdownCalled = true; | 2213 s_shutdownCalled = true; |
2213 ThreadState::shutdownHeapIfNecessary(); | 2214 ThreadState::shutdownHeapIfNecessary(); |
2214 } | 2215 } |
2215 | 2216 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2517 // pointers to the orphaned pages. (If we have such dangling pointers, | 2518 // pointers to the orphaned pages. (If we have such dangling pointers, |
2518 // we should have crashed during marking before getting here.) | 2519 // we should have crashed during marking before getting here.) |
2519 orphanedPagePool()->decommitOrphanedPages(); | 2520 orphanedPagePool()->decommitOrphanedPages(); |
2520 | 2521 |
2521 postGC(gcType); | 2522 postGC(gcType); |
2522 | 2523 |
2523 #if ENABLE(GC_PROFILING) | 2524 #if ENABLE(GC_PROFILING) |
2524 static_cast<MarkingVisitor<GlobalMarking>*>(s_markingVisitor)->reportStats()
; | 2525 static_cast<MarkingVisitor<GlobalMarking>*>(s_markingVisitor)->reportStats()
; |
2525 #endif | 2526 #endif |
2526 | 2527 |
| 2528 double markingTimeInMilliseconds = WTF::currentTimeMS() - timeStamp; |
| 2529 s_markingTimeInLastGC = markingTimeInMilliseconds / 1000; |
| 2530 |
2527 if (Platform::current()) { | 2531 if (Platform::current()) { |
2528 Platform::current()->histogramCustomCounts("BlinkGC.CollectGarbage", WTF
::currentTimeMS() - timeStamp, 0, 10 * 1000, 50); | 2532 Platform::current()->histogramCustomCounts("BlinkGC.CollectGarbage", mar
kingTimeInMilliseconds, 0, 10 * 1000, 50); |
2529 Platform::current()->histogramCustomCounts("BlinkGC.TotalObjectSpace", H
eap::allocatedObjectSize() / 1024, 0, 4 * 1024 * 1024, 50); | 2533 Platform::current()->histogramCustomCounts("BlinkGC.TotalObjectSpace", H
eap::allocatedObjectSize() / 1024, 0, 4 * 1024 * 1024, 50); |
2530 Platform::current()->histogramCustomCounts("BlinkGC.TotalAllocatedSpace"
, Heap::allocatedSpace() / 1024, 0, 4 * 1024 * 1024, 50); | 2534 Platform::current()->histogramCustomCounts("BlinkGC.TotalAllocatedSpace"
, Heap::allocatedSpace() / 1024, 0, 4 * 1024 * 1024, 50); |
2531 Platform::current()->histogramEnumeration("BlinkGC.GCReason", reason, Nu
mberOfGCReasonForTracing); | 2535 Platform::current()->histogramEnumeration("BlinkGC.GCReason", reason, Nu
mberOfGCReasonForTracing); |
2532 } | 2536 } |
2533 | 2537 |
2534 if (state->isMainThread()) | 2538 if (state->isMainThread()) |
2535 ScriptForbiddenScope::exit(); | 2539 ScriptForbiddenScope::exit(); |
2536 } | 2540 } |
2537 | 2541 |
2538 void Heap::collectGarbageForTerminatingThread(ThreadState* state) | 2542 void Heap::collectGarbageForTerminatingThread(ThreadState* state) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2629 // should die. Unfortunately it is not the case for all objects | 2633 // should die. Unfortunately it is not the case for all objects |
2630 // because the hierarchy was not completely moved to the heap and | 2634 // because the hierarchy was not completely moved to the heap and |
2631 // some heap allocated objects own objects that contain persistents | 2635 // some heap allocated objects own objects that contain persistents |
2632 // pointing to other heap allocated objects. | 2636 // pointing to other heap allocated objects. |
2633 for (int i = 0; i < 5; ++i) | 2637 for (int i = 0; i < 5; ++i) |
2634 collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWithSw
eep, ForcedGCForTesting); | 2638 collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWithSw
eep, ForcedGCForTesting); |
2635 } | 2639 } |
2636 | 2640 |
2637 double Heap::estimatedMarkingTime() | 2641 double Heap::estimatedMarkingTime() |
2638 { | 2642 { |
2639 // FIXME: Implement heuristics | 2643 ASSERT(ThreadState::current()->isMainThread()); |
2640 return 0.0; | 2644 |
| 2645 // Marking algorithm takes O(N_live_objs), so the next marking time can be e
stimated as: |
| 2646 // ~ N_live_objs |
| 2647 // t_next = t_last * ------------------ |
| 2648 // N_last_live_objs |
| 2649 // By estimating N_{,last}_live_objs ratio using object size ratio, we get: |
| 2650 // ~ (Size_new_objs + Size_last_marked_objs) * Rate_alive |
| 2651 // t_next = t_last * ------------------------------------------------------ |
| 2652 // Size_last_marked_objs |
| 2653 |
| 2654 double estimatedObjectCountIncreaseRatio = 1.0; |
| 2655 if (Heap::markedObjectSize() > 0) |
| 2656 estimatedObjectCountIncreaseRatio = (Heap::allocatedObjectSize() + Heap:
:markedObjectSize()) * ThreadState::current()->collectionRate() / Heap::markedOb
jectSize(); |
| 2657 |
| 2658 return s_markingTimeInLastGC * estimatedObjectCountIncreaseRatio; |
2641 } | 2659 } |
2642 | 2660 |
2643 size_t Heap::objectPayloadSizeForTesting() | 2661 size_t Heap::objectPayloadSizeForTesting() |
2644 { | 2662 { |
2645 size_t objectPayloadSize = 0; | 2663 size_t objectPayloadSize = 0; |
2646 for (ThreadState* state : ThreadState::attachedThreads()) { | 2664 for (ThreadState* state : ThreadState::attachedThreads()) { |
2647 state->setGCState(ThreadState::GCRunning); | 2665 state->setGCState(ThreadState::GCRunning); |
2648 state->makeConsistentForSweeping(); | 2666 state->makeConsistentForSweeping(); |
2649 objectPayloadSize += state->objectPayloadSizeForTesting(); | 2667 objectPayloadSize += state->objectPayloadSizeForTesting(); |
2650 state->setGCState(ThreadState::EagerSweepScheduled); | 2668 state->setGCState(ThreadState::EagerSweepScheduled); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2892 FreePagePool* Heap::s_freePagePool; | 2910 FreePagePool* Heap::s_freePagePool; |
2893 OrphanedPagePool* Heap::s_orphanedPagePool; | 2911 OrphanedPagePool* Heap::s_orphanedPagePool; |
2894 Heap::RegionTree* Heap::s_regionTree = nullptr; | 2912 Heap::RegionTree* Heap::s_regionTree = nullptr; |
2895 size_t Heap::s_allocatedObjectSize = 0; | 2913 size_t Heap::s_allocatedObjectSize = 0; |
2896 size_t Heap::s_allocatedSpace = 0; | 2914 size_t Heap::s_allocatedSpace = 0; |
2897 size_t Heap::s_markedObjectSize = 0; | 2915 size_t Heap::s_markedObjectSize = 0; |
2898 | 2916 |
2899 size_t Heap::s_externallyAllocatedBytes = 0; | 2917 size_t Heap::s_externallyAllocatedBytes = 0; |
2900 size_t Heap::s_externallyAllocatedBytesAlive = 0; | 2918 size_t Heap::s_externallyAllocatedBytesAlive = 0; |
2901 unsigned Heap::s_requestedUrgentGC = false; | 2919 unsigned Heap::s_requestedUrgentGC = false; |
| 2920 double Heap::s_markingTimeInLastGC = 0.0; |
2902 | 2921 |
2903 } // namespace blink | 2922 } // namespace blink |
OLD | NEW |