| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 { | 55 { |
| 56 DCHECK(m_client); | 56 DCHECK(m_client); |
| 57 } | 57 } |
| 58 | 58 |
| 59 ~WebLeakDetectorImpl() override {} | 59 ~WebLeakDetectorImpl() override {} |
| 60 | 60 |
| 61 void prepareForLeakDetection(WebFrame*) override; | 61 void prepareForLeakDetection(WebFrame*) override; |
| 62 void collectGarbageAndReport() override; | 62 void collectGarbageAndReport() override; |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 void delayedGCAndReport(Timer<WebLeakDetectorImpl>*); | 65 void delayedGCAndReport(TimerBase*); |
| 66 void delayedReport(Timer<WebLeakDetectorImpl>*); | 66 void delayedReport(TimerBase*); |
| 67 | 67 |
| 68 WebLeakDetectorClient* m_client; | 68 WebLeakDetectorClient* m_client; |
| 69 Timer<WebLeakDetectorImpl> m_delayedGCAndReportTimer; | 69 Timer<WebLeakDetectorImpl> m_delayedGCAndReportTimer; |
| 70 Timer<WebLeakDetectorImpl> m_delayedReportTimer; | 70 Timer<WebLeakDetectorImpl> m_delayedReportTimer; |
| 71 int m_numberOfGCNeeded; | 71 int m_numberOfGCNeeded; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 void WebLeakDetectorImpl::prepareForLeakDetection(WebFrame* frame) | 74 void WebLeakDetectorImpl::prepareForLeakDetection(WebFrame* frame) |
| 75 { | 75 { |
| 76 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 76 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // Note: Oilpan precise GC is scheduled at the end of the event loop. | 108 // Note: Oilpan precise GC is scheduled at the end of the event loop. |
| 109 | 109 |
| 110 // Task queue may contain delayed object destruction tasks. | 110 // Task queue may contain delayed object destruction tasks. |
| 111 // This method is called from navigation hook inside FrameLoader, | 111 // This method is called from navigation hook inside FrameLoader, |
| 112 // so previous document is still held by the loader until the next event loo
p. | 112 // so previous document is still held by the loader until the next event loo
p. |
| 113 // Complete all pending tasks before proceeding to gc. | 113 // Complete all pending tasks before proceeding to gc. |
| 114 m_numberOfGCNeeded = 2; | 114 m_numberOfGCNeeded = 2; |
| 115 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); | 115 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void WebLeakDetectorImpl::delayedGCAndReport(Timer<WebLeakDetectorImpl>*) | 118 void WebLeakDetectorImpl::delayedGCAndReport(TimerBase*) |
| 119 { | 119 { |
| 120 // We do a second and third GC here to address flakiness | 120 // We do a second and third GC here to address flakiness |
| 121 // The second GC is necessary as Resource GC may have postponed clean-up tas
ks to next event loop. | 121 // The second GC is necessary as Resource GC may have postponed clean-up tas
ks to next event loop. |
| 122 // The third GC is necessary for cleaning up Document after worker object di
ed. | 122 // The third GC is necessary for cleaning up Document after worker object di
ed. |
| 123 | 123 |
| 124 V8GCController::collectAllGarbageForTesting(V8PerIsolateData::mainThreadIsol
ate()); | 124 V8GCController::collectAllGarbageForTesting(V8PerIsolateData::mainThreadIsol
ate()); |
| 125 // Note: Oilpan precise GC is scheduled at the end of the event loop. | 125 // Note: Oilpan precise GC is scheduled at the end of the event loop. |
| 126 | 126 |
| 127 // Inspect counters on the next event loop. | 127 // Inspect counters on the next event loop. |
| 128 if (--m_numberOfGCNeeded > 0) { | 128 if (--m_numberOfGCNeeded > 0) { |
| 129 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); | 129 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); |
| 130 } else if (m_numberOfGCNeeded > -1 && InProcessWorkerMessagingProxy::proxyCo
unt()) { | 130 } else if (m_numberOfGCNeeded > -1 && InProcessWorkerMessagingProxy::proxyCo
unt()) { |
| 131 // It is possible that all posted tasks for finalizing in-process proxy
objects | 131 // It is possible that all posted tasks for finalizing in-process proxy
objects |
| 132 // will not have run before the final round of GCs started. If so, do ye
t | 132 // will not have run before the final round of GCs started. If so, do ye
t |
| 133 // another pass, letting these tasks run and then afterwards perform a G
C to tidy up. | 133 // another pass, letting these tasks run and then afterwards perform a G
C to tidy up. |
| 134 // | 134 // |
| 135 // TODO(sof): use proxyCount() to always decide if another GC needs to b
e scheduled. | 135 // TODO(sof): use proxyCount() to always decide if another GC needs to b
e scheduled. |
| 136 // Some debug bots running browser unit tests disagree (crbug.com/616714
) | 136 // Some debug bots running browser unit tests disagree (crbug.com/616714
) |
| 137 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); | 137 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); |
| 138 } else { | 138 } else { |
| 139 m_delayedReportTimer.startOneShot(0, BLINK_FROM_HERE); | 139 m_delayedReportTimer.startOneShot(0, BLINK_FROM_HERE); |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 | 142 |
| 143 void WebLeakDetectorImpl::delayedReport(Timer<WebLeakDetectorImpl>*) | 143 void WebLeakDetectorImpl::delayedReport(TimerBase*) |
| 144 { | 144 { |
| 145 DCHECK(m_client); | 145 DCHECK(m_client); |
| 146 | 146 |
| 147 WebLeakDetectorClient::Result result; | 147 WebLeakDetectorClient::Result result; |
| 148 result.numberOfLiveAudioNodes = InstanceCounters::counterValue(InstanceCount
ers::AudioHandlerCounter); | 148 result.numberOfLiveAudioNodes = InstanceCounters::counterValue(InstanceCount
ers::AudioHandlerCounter); |
| 149 result.numberOfLiveDocuments = InstanceCounters::counterValue(InstanceCounte
rs::DocumentCounter); | 149 result.numberOfLiveDocuments = InstanceCounters::counterValue(InstanceCounte
rs::DocumentCounter); |
| 150 result.numberOfLiveNodes = InstanceCounters::counterValue(InstanceCounters::
NodeCounter); | 150 result.numberOfLiveNodes = InstanceCounters::counterValue(InstanceCounters::
NodeCounter); |
| 151 result.numberOfLiveLayoutObjects = InstanceCounters::counterValue(InstanceCo
unters::LayoutObjectCounter); | 151 result.numberOfLiveLayoutObjects = InstanceCounters::counterValue(InstanceCo
unters::LayoutObjectCounter); |
| 152 result.numberOfLiveResources = InstanceCounters::counterValue(InstanceCounte
rs::ResourceCounter); | 152 result.numberOfLiveResources = InstanceCounters::counterValue(InstanceCounte
rs::ResourceCounter); |
| 153 result.numberOfLiveActiveDOMObjects = InstanceCounters::counterValue(Instanc
eCounters::ActiveDOMObjectCounter); | 153 result.numberOfLiveActiveDOMObjects = InstanceCounters::counterValue(Instanc
eCounters::ActiveDOMObjectCounter); |
| 154 result.numberOfLiveScriptPromises = InstanceCounters::counterValue(InstanceC
ounters::ScriptPromiseCounter); | 154 result.numberOfLiveScriptPromises = InstanceCounters::counterValue(InstanceC
ounters::ScriptPromiseCounter); |
| 155 result.numberOfLiveFrames = InstanceCounters::counterValue(InstanceCounters:
:FrameCounter); | 155 result.numberOfLiveFrames = InstanceCounters::counterValue(InstanceCounters:
:FrameCounter); |
| 156 result.numberOfLiveV8PerContextData = InstanceCounters::counterValue(Instanc
eCounters::V8PerContextDataCounter); | 156 result.numberOfLiveV8PerContextData = InstanceCounters::counterValue(Instanc
eCounters::V8PerContextDataCounter); |
| 157 | 157 |
| 158 m_client->onLeakDetectionComplete(result); | 158 m_client->onLeakDetectionComplete(result); |
| 159 | 159 |
| 160 #ifndef NDEBUG | 160 #ifndef NDEBUG |
| 161 showLiveDocumentInstances(); | 161 showLiveDocumentInstances(); |
| 162 #endif | 162 #endif |
| 163 } | 163 } |
| 164 | 164 |
| 165 } // namespace | 165 } // namespace |
| 166 | 166 |
| 167 WebLeakDetector* WebLeakDetector::create(WebLeakDetectorClient* client) | 167 WebLeakDetector* WebLeakDetector::create(WebLeakDetectorClient* client) |
| 168 { | 168 { |
| 169 return new WebLeakDetectorImpl(client); | 169 return new WebLeakDetectorImpl(client); |
| 170 } | 170 } |
| 171 | 171 |
| 172 } // namespace blink | 172 } // namespace blink |
| OLD | NEW |