diff options
Diffstat (limited to 'deps/v8/src/inspector/v8-heap-profiler-agent-impl.cc')
-rw-r--r-- | deps/v8/src/inspector/v8-heap-profiler-agent-impl.cc | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/deps/v8/src/inspector/v8-heap-profiler-agent-impl.cc b/deps/v8/src/inspector/v8-heap-profiler-agent-impl.cc index b3e3d11f51..8af3edf7e1 100644 --- a/deps/v8/src/inspector/v8-heap-profiler-agent-impl.cc +++ b/deps/v8/src/inspector/v8-heap-profiler-agent-impl.cc @@ -363,17 +363,24 @@ buildSampingHeapProfileNode(const v8::AllocationProfile::Node* node) { Response V8HeapProfilerAgentImpl::stopSampling( std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfile>* profile) { + Response result = getSamplingProfile(profile); + if (result.isSuccess()) { + m_isolate->GetHeapProfiler()->StopSamplingHeapProfiler(); + m_state->setBoolean(HeapProfilerAgentState::samplingHeapProfilerEnabled, + false); + } + return result; +} + +Response V8HeapProfilerAgentImpl::getSamplingProfile( + std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfile>* profile) { v8::HeapProfiler* profiler = m_isolate->GetHeapProfiler(); - if (!profiler) return Response::Error("Cannot access v8 heap profiler"); v8::HandleScope scope( - m_isolate); // Allocation profile contains Local handles. + m_isolate); // v8::AllocationProfile contains Local handles. std::unique_ptr<v8::AllocationProfile> v8Profile( profiler->GetAllocationProfile()); - profiler->StopSamplingHeapProfiler(); - m_state->setBoolean(HeapProfilerAgentState::samplingHeapProfilerEnabled, - false); if (!v8Profile) - return Response::Error("Cannot access v8 sampled heap profile."); + return Response::Error("V8 sampling heap profiler was not started."); v8::AllocationProfile::Node* root = v8Profile->GetRootNode(); *profile = protocol::HeapProfiler::SamplingHeapProfile::create() .setHead(buildSampingHeapProfileNode(root)) |