void ThreadProfile::FlushSamplesAndMarkers() { // This function is used to serialize the current buffer just before // JSRuntime destruction. MOZ_ASSERT(mPseudoStack->mRuntime); // Unlike StreamJSObject, do not surround the samples in brackets by calling // aWriter.{Start,End}BareList. The result string will be a comma-separated // list of JSON object literals that will prepended by StreamJSObject into // an existing array. // // Note that the UniqueStacks instance is persisted so that the frame-index // mapping is stable across JS shutdown. mUniqueStacks.emplace(mPseudoStack->mRuntime); { SpliceableChunkedJSONWriter b; b.StartBareList(); { mBuffer->StreamSamplesToJSON(b, mThreadId, /* aSinceTime = */ 0, mPseudoStack->mRuntime, *mUniqueStacks); } b.EndBareList(); mSavedStreamedSamples = b.WriteFunc()->CopyData(); } { SpliceableChunkedJSONWriter b; b.StartBareList(); { mBuffer->StreamMarkersToJSON(b, mThreadId, /* aSinceTime = */ 0, *mUniqueStacks); } b.EndBareList(); mSavedStreamedMarkers = b.WriteFunc()->CopyData(); } // Reset the buffer. Attempting to symbolicate JS samples after mRuntime has // gone away will crash. mBuffer->reset(); }
UniquePtr<char[]> GeckoSampler::ToJSON(double aSinceTime) { SpliceableChunkedJSONWriter b; StreamJSON(b, aSinceTime); return b.WriteFunc()->CopyData(); }
UniquePtr<char[]> TableTicker::ToJSON(float aSinceTime) { SpliceableChunkedJSONWriter b; StreamJSON(b, aSinceTime); return b.WriteFunc()->CopyData(); }