| 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 26 matching lines...) Expand all Loading... |
| 37 #include "platform/heap/CallbackStack.h" | 37 #include "platform/heap/CallbackStack.h" |
| 38 #include "platform/heap/MarkingVisitor.h" | 38 #include "platform/heap/MarkingVisitor.h" |
| 39 #include "platform/heap/SafePoint.h" | 39 #include "platform/heap/SafePoint.h" |
| 40 #include "platform/heap/ThreadState.h" | 40 #include "platform/heap/ThreadState.h" |
| 41 #include "public/platform/Platform.h" | 41 #include "public/platform/Platform.h" |
| 42 #include "wtf/Assertions.h" | 42 #include "wtf/Assertions.h" |
| 43 #include "wtf/ContainerAnnotations.h" | 43 #include "wtf/ContainerAnnotations.h" |
| 44 #include "wtf/LeakAnnotations.h" | 44 #include "wtf/LeakAnnotations.h" |
| 45 #include "wtf/MainThread.h" | 45 #include "wtf/MainThread.h" |
| 46 #include "wtf/PageAllocator.h" | 46 #include "wtf/PageAllocator.h" |
| 47 #include "wtf/Partitions.h" |
| 47 #include "wtf/PassOwnPtr.h" | 48 #include "wtf/PassOwnPtr.h" |
| 48 #if ENABLE(GC_PROFILING) | 49 #if ENABLE(GC_PROFILING) |
| 49 #include "platform/TracedValue.h" | 50 #include "platform/TracedValue.h" |
| 50 #include "wtf/HashMap.h" | 51 #include "wtf/HashMap.h" |
| 51 #include "wtf/HashSet.h" | 52 #include "wtf/HashSet.h" |
| 52 #include "wtf/text/StringBuilder.h" | 53 #include "wtf/text/StringBuilder.h" |
| 53 #include "wtf/text/StringHash.h" | 54 #include "wtf/text/StringHash.h" |
| 54 #include <stdio.h> | 55 #include <stdio.h> |
| 55 #include <utility> | 56 #include <utility> |
| 56 #endif | 57 #endif |
| (...skipping 2228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2285 #endif | 2286 #endif |
| 2286 | 2287 |
| 2287 double markingTimeInMilliseconds = WTF::currentTimeMS() - timeStamp; | 2288 double markingTimeInMilliseconds = WTF::currentTimeMS() - timeStamp; |
| 2288 s_estimatedMarkingTimePerByte = totalObjectSize ? (markingTimeInMilliseconds
/ 1000 / totalObjectSize) : 0; | 2289 s_estimatedMarkingTimePerByte = totalObjectSize ? (markingTimeInMilliseconds
/ 1000 / totalObjectSize) : 0; |
| 2289 | 2290 |
| 2290 if (Platform::current()) { | 2291 if (Platform::current()) { |
| 2291 Platform::current()->histogramCustomCounts("BlinkGC.CollectGarbage", mar
kingTimeInMilliseconds, 0, 10 * 1000, 50); | 2292 Platform::current()->histogramCustomCounts("BlinkGC.CollectGarbage", mar
kingTimeInMilliseconds, 0, 10 * 1000, 50); |
| 2292 Platform::current()->histogramCustomCounts("BlinkGC.TotalObjectSpace", H
eap::allocatedObjectSize() / 1024, 0, 4 * 1024 * 1024, 50); | 2293 Platform::current()->histogramCustomCounts("BlinkGC.TotalObjectSpace", H
eap::allocatedObjectSize() / 1024, 0, 4 * 1024 * 1024, 50); |
| 2293 Platform::current()->histogramCustomCounts("BlinkGC.TotalAllocatedSpace"
, Heap::allocatedSpace() / 1024, 0, 4 * 1024 * 1024, 50); | 2294 Platform::current()->histogramCustomCounts("BlinkGC.TotalAllocatedSpace"
, Heap::allocatedSpace() / 1024, 0, 4 * 1024 * 1024, 50); |
| 2294 Platform::current()->histogramEnumeration("BlinkGC.GCReason", reason, Nu
mberOfGCReason); | 2295 Platform::current()->histogramEnumeration("BlinkGC.GCReason", reason, Nu
mberOfGCReason); |
| 2296 Heap::reportMemoryUsageHistogram(); |
| 2297 WTF::Partitions::reportMemoryUsageHistogram(); |
| 2295 } | 2298 } |
| 2296 | 2299 |
| 2297 if (state->isMainThread()) | 2300 if (state->isMainThread()) |
| 2298 ScriptForbiddenScope::exit(); | 2301 ScriptForbiddenScope::exit(); |
| 2299 } | 2302 } |
| 2300 | 2303 |
| 2301 void Heap::collectGarbageForTerminatingThread(ThreadState* state) | 2304 void Heap::collectGarbageForTerminatingThread(ThreadState* state) |
| 2302 { | 2305 { |
| 2303 // We explicitly do not enter a safepoint while doing thread specific | 2306 // We explicitly do not enter a safepoint while doing thread specific |
| 2304 // garbage collection since we don't want to allow a global GC at the | 2307 // garbage collection since we don't want to allow a global GC at the |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2405 // 8 ms is long enough for low-end mobile devices to mark common | 2408 // 8 ms is long enough for low-end mobile devices to mark common |
| 2406 // real-world object graphs. | 2409 // real-world object graphs. |
| 2407 if (s_estimatedMarkingTimePerByte == 0) | 2410 if (s_estimatedMarkingTimePerByte == 0) |
| 2408 return 0.008; | 2411 return 0.008; |
| 2409 | 2412 |
| 2410 // Assuming that the collection rate of this GC will be mostly equal to | 2413 // Assuming that the collection rate of this GC will be mostly equal to |
| 2411 // the collection rate of the last GC, estimate the marking time of this GC. | 2414 // the collection rate of the last GC, estimate the marking time of this GC. |
| 2412 return s_estimatedMarkingTimePerByte * (Heap::allocatedObjectSize() + Heap::
markedObjectSize()); | 2415 return s_estimatedMarkingTimePerByte * (Heap::allocatedObjectSize() + Heap::
markedObjectSize()); |
| 2413 } | 2416 } |
| 2414 | 2417 |
| 2415 void Heap::reportMemoryUsage() | 2418 void Heap::reportMemoryUsageHistogram() |
| 2416 { | 2419 { |
| 2417 static size_t supportedMaxSizeInMB = 4 * 1024; | 2420 static size_t supportedMaxSizeInMB = 4 * 1024; |
| 2418 static size_t observedMaxSizeInMB = 0; | 2421 static size_t observedMaxSizeInMB = 0; |
| 2419 | 2422 |
| 2420 // We only report the memory in the main thread. | 2423 // We only report the memory in the main thread. |
| 2421 if (!isMainThread()) | 2424 if (!isMainThread()) |
| 2422 return; | 2425 return; |
| 2423 // +1 is for rounding up the sizeInMB. | 2426 // +1 is for rounding up the sizeInMB. |
| 2424 size_t sizeInMB = Heap::allocatedSpace() / 1024 / 1024 + 1; | 2427 size_t sizeInMB = Heap::allocatedSpace() / 1024 / 1024 + 1; |
| 2425 if (sizeInMB >= supportedMaxSizeInMB) | 2428 if (sizeInMB >= supportedMaxSizeInMB) |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2691 // We don't want to use 0 KB for the initial value because it may end up | 2694 // We don't want to use 0 KB for the initial value because it may end up |
| 2692 // triggering the first GC of some thread too prematurely. | 2695 // triggering the first GC of some thread too prematurely. |
| 2693 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; | 2696 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; |
| 2694 | 2697 |
| 2695 size_t Heap::s_externallyAllocatedBytes = 0; | 2698 size_t Heap::s_externallyAllocatedBytes = 0; |
| 2696 size_t Heap::s_externallyAllocatedBytesAlive = 0; | 2699 size_t Heap::s_externallyAllocatedBytesAlive = 0; |
| 2697 unsigned Heap::s_requestedUrgentGC = false; | 2700 unsigned Heap::s_requestedUrgentGC = false; |
| 2698 double Heap::s_estimatedMarkingTimePerByte = 0.0; | 2701 double Heap::s_estimatedMarkingTimePerByte = 0.0; |
| 2699 | 2702 |
| 2700 } // namespace blink | 2703 } // namespace blink |
| OLD | NEW |