v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
v8-heap-profiler-agent-impl.h
Go to the documentation of this file.
1// Copyright 2016 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_INSPECTOR_V8_HEAP_PROFILER_AGENT_IMPL_H_
6#define V8_INSPECTOR_V8_HEAP_PROFILER_AGENT_IMPL_H_
7
8#include <memory>
9
10#include "src/base/macros.h"
11#include "src/inspector/protocol/Forward.h"
12#include "src/inspector/protocol/HeapProfiler.h"
13
14namespace v8 {
15class Isolate;
16}
17
18namespace v8_inspector {
19
20class V8InspectorSessionImpl;
21
22using protocol::Response;
23
24class V8HeapProfilerAgentImpl : public protocol::HeapProfiler::Backend {
25 public:
26 V8HeapProfilerAgentImpl(V8InspectorSessionImpl*, protocol::FrontendChannel*,
27 protocol::DictionaryValue* state);
28 ~V8HeapProfilerAgentImpl() override;
31 void restore();
32
33 void collectGarbage(
34 std::unique_ptr<CollectGarbageCallback> callback) override;
35
36 Response enable() override;
38 std::optional<bool> trackAllocations) override;
40 std::optional<bool> reportProgress,
41 std::optional<bool> treatGlobalObjectsAsRoots,
42 std::optional<bool> captureNumericValue,
43 std::optional<bool> exposeInternals) override;
44
45 Response disable() override;
46
48 std::optional<bool> reportProgress,
49 std::optional<bool> treatGlobalObjectsAsRoots,
50 std::optional<bool> captureNumericValue,
51 std::optional<bool> exposeInternals,
52 std::unique_ptr<TakeHeapSnapshotCallback> callback) override;
53
55 const String16& heapSnapshotObjectId, std::optional<String16> objectGroup,
56 std::unique_ptr<protocol::Runtime::RemoteObject>* result) override;
58 const String16& inspectedHeapObjectId) override;
59 Response getHeapObjectId(const String16& objectId,
60 String16* heapSnapshotObjectId) override;
61
62 Response startSampling(
63 std::optional<double> samplingInterval,
64 std::optional<bool> includeObjectsCollectedByMajorGC,
65 std::optional<bool> includeObjectsCollectedByMinorGC) override;
66 Response stopSampling(
67 std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfile>*) override;
68 Response getSamplingProfile(
69 std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfile>*) override;
70
71 // If any heap snapshot requests have been deferred, run them now. This is
72 // called by the debugger when pausing execution on this thread.
74
75 private:
76 struct AsyncCallbacks;
77 class GCTask;
78 class HeapSnapshotTask;
80
81 Response takeHeapSnapshotNow(
82 const HeapSnapshotProtocolOptions& protocolOptions,
83 cppgc::EmbedderStackState stackState);
84 void startTrackingHeapObjectsInternal(bool trackAllocations);
87 static void onTimer(void*);
88 void onTimerImpl();
89
92 protocol::HeapProfiler::Frontend m_frontend;
93 protocol::DictionaryValue* m_state;
96 std::shared_ptr<AsyncCallbacks> m_asyncCallbacks;
97};
98
99} // namespace v8_inspector
100
101#endif // V8_INSPECTOR_V8_HEAP_PROFILER_AGENT_IMPL_H_
void collectGarbage(std::unique_ptr< CollectGarbageCallback > callback) override
Response takeHeapSnapshotNow(const HeapSnapshotProtocolOptions &protocolOptions, cppgc::EmbedderStackState stackState)
V8HeapProfilerAgentImpl & operator=(const V8HeapProfilerAgentImpl &)=delete
Response getHeapObjectId(const String16 &objectId, String16 *heapSnapshotObjectId) override
V8HeapProfilerAgentImpl(const V8HeapProfilerAgentImpl &)=delete
Response stopTrackingHeapObjects(std::optional< bool > reportProgress, std::optional< bool > treatGlobalObjectsAsRoots, std::optional< bool > captureNumericValue, std::optional< bool > exposeInternals) override
std::shared_ptr< AsyncCallbacks > m_asyncCallbacks
void takeHeapSnapshot(std::optional< bool > reportProgress, std::optional< bool > treatGlobalObjectsAsRoots, std::optional< bool > captureNumericValue, std::optional< bool > exposeInternals, std::unique_ptr< TakeHeapSnapshotCallback > callback) override
Response addInspectedHeapObject(const String16 &inspectedHeapObjectId) override
V8HeapProfilerAgentImpl(V8InspectorSessionImpl *, protocol::FrontendChannel *, protocol::DictionaryValue *state)
Response startSampling(std::optional< double > samplingInterval, std::optional< bool > includeObjectsCollectedByMajorGC, std::optional< bool > includeObjectsCollectedByMinorGC) override
void startTrackingHeapObjectsInternal(bool trackAllocations)
protocol::HeapProfiler::Frontend m_frontend
Response getSamplingProfile(std::unique_ptr< protocol::HeapProfiler::SamplingHeapProfile > *) override
Response startTrackingHeapObjects(std::optional< bool > trackAllocations) override
Response getObjectByHeapObjectId(const String16 &heapSnapshotObjectId, std::optional< String16 > objectGroup, std::unique_ptr< protocol::Runtime::RemoteObject > *result) override
Response stopSampling(std::unique_ptr< protocol::HeapProfiler::SamplingHeapProfile > *) override
TNode< Object > callback
ZoneVector< RpoNumber > & result
EmbedderStackState
Definition common.h:15