void InspectorHeapAgent::didGarbageCollect(HeapOperation operation) { ASSERT(m_enabled); ASSERT(!std::isnan(m_gcStartTime)); // FIXME: Include number of bytes freed by collection. double startTime = m_gcStartTime; double endTime = m_environment.executionStopwatch()->elapsedTime(); // Dispatch the event asynchronously because this method may be // called between collection and sweeping and we don't want to // create unexpected JavaScript allocations that the Sweeper does // not expect to encounter. JavaScript allocations could happen // with WebKitLegacy's in process inspector which shares the same // VM as the inspected page. RunLoop::current().dispatch([this, startTime, endTime, operation]() { auto collection = Inspector::Protocol::Heap::GarbageCollection::create() .setType(protocolTypeForHeapOperation(operation)) .setStartTime(startTime) .setEndTime(endTime) .release(); m_frontendDispatcher->garbageCollected(WTFMove(collection)); }); m_gcStartTime = NAN; }
void InspectorHeapAgent::didGarbageCollect(CollectionScope scope) { if (!m_enabled) { m_gcStartTime = NAN; return; } if (std::isnan(m_gcStartTime)) { // We were not enabled when the GC began. return; } // FIXME: Include number of bytes freed by collection. // Dispatch the event asynchronously because this method may be // called between collection and sweeping and we don't want to // create unexpected JavaScript allocations that the Sweeper does // not expect to encounter. JavaScript allocations could happen // with WebKitLegacy's in process inspector which shares the same // VM as the inspected page. GarbageCollectionData data; data.type = protocolTypeForHeapOperation(scope); data.startTime = m_gcStartTime; data.endTime = m_environment.executionStopwatch()->elapsedTime(); m_sendGarbageCollectionEventsTask->addGarbageCollection(data); m_gcStartTime = NAN; }