#include "src/inspector/v8-heap-profiler-agent-impl.h"
#include "include/v8-context.h"
#include "include/v8-inspector.h"
#include "include/v8-platform.h"
#include "include/v8-profiler.h"
#include "src/base/platform/mutex.h"
#include "src/base/platform/time.h"
#include "src/inspector/injected-script.h"
#include "src/inspector/inspected-context.h"
#include "src/inspector/protocol/Protocol.h"
#include "src/inspector/string-util.h"
#include "src/inspector/v8-debugger.h"
#include "src/inspector/v8-inspector-impl.h"
#include "src/inspector/v8-inspector-session-impl.h"
namespace v8_inspector {
namespace {
namespace HeapProfilerAgentState {
static const char heapProfilerEnabled[] = …;
static const char heapObjectsTrackingEnabled[] = …;
static const char allocationTrackingEnabled[] = …;
static const char samplingHeapProfilerEnabled[] = …;
static const char samplingHeapProfilerInterval[] = …;
static const char samplingHeapProfilerFlags[] = …;
}
class HeapSnapshotProgress final : public v8::ActivityControl { … };
class GlobalObjectNameResolver final
: public v8::HeapProfiler::ObjectNameResolver { … };
class HeapSnapshotOutputStream final : public v8::OutputStream { … };
v8::Local<v8::Object> objectByHeapObjectId(v8::Isolate* isolate, int id) { … }
class InspectableHeapObject final : public V8InspectorSession::Inspectable { … };
class HeapStatsStream final : public v8::OutputStream { … };
}
struct V8HeapProfilerAgentImpl::AsyncCallbacks { … };
class V8HeapProfilerAgentImpl::GCTask : public v8::Task { … };
struct V8HeapProfilerAgentImpl::HeapSnapshotProtocolOptions { … };
class V8HeapProfilerAgentImpl::HeapSnapshotTask : public v8::Task { … };
V8HeapProfilerAgentImpl::V8HeapProfilerAgentImpl(
V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel,
protocol::DictionaryValue* state)
: … { … }
V8HeapProfilerAgentImpl::~V8HeapProfilerAgentImpl() { … }
void V8HeapProfilerAgentImpl::restore() { … }
void V8HeapProfilerAgentImpl::collectGarbage(
std::unique_ptr<CollectGarbageCallback> callback) { … }
Response V8HeapProfilerAgentImpl::startTrackingHeapObjects(
Maybe<bool> trackAllocations) { … }
Response V8HeapProfilerAgentImpl::stopTrackingHeapObjects(
Maybe<bool> reportProgress, Maybe<bool> treatGlobalObjectsAsRoots,
Maybe<bool> captureNumericValue, Maybe<bool> exposeInternals) { … }
Response V8HeapProfilerAgentImpl::enable() { … }
Response V8HeapProfilerAgentImpl::disable() { … }
void V8HeapProfilerAgentImpl::takeHeapSnapshot(
Maybe<bool> reportProgress, Maybe<bool> treatGlobalObjectsAsRoots,
Maybe<bool> captureNumericValue, Maybe<bool> exposeInternals,
std::unique_ptr<TakeHeapSnapshotCallback> callback) { … }
Response V8HeapProfilerAgentImpl::takeHeapSnapshotNow(
const HeapSnapshotProtocolOptions& protocolOptions,
cppgc::EmbedderStackState stackState) { … }
Response V8HeapProfilerAgentImpl::getObjectByHeapObjectId(
const String16& heapSnapshotObjectId, Maybe<String16> objectGroup,
std::unique_ptr<protocol::Runtime::RemoteObject>* result) { … }
void V8HeapProfilerAgentImpl::takePendingHeapSnapshots() { … }
Response V8HeapProfilerAgentImpl::addInspectedHeapObject(
const String16& inspectedHeapObjectId) { … }
Response V8HeapProfilerAgentImpl::getHeapObjectId(
const String16& objectId, String16* heapSnapshotObjectId) { … }
void V8HeapProfilerAgentImpl::requestHeapStatsUpdate() { … }
void V8HeapProfilerAgentImpl::onTimer(void* data) { … }
static constexpr v8::base::TimeDelta kDefaultTimerDelay = …;
void V8HeapProfilerAgentImpl::onTimerImpl() { … }
void V8HeapProfilerAgentImpl::startTrackingHeapObjectsInternal(
bool trackAllocations) { … }
void V8HeapProfilerAgentImpl::stopTrackingHeapObjectsInternal() { … }
Response V8HeapProfilerAgentImpl::startSampling(
Maybe<double> samplingInterval,
Maybe<bool> includeObjectsCollectedByMajorGC,
Maybe<bool> includeObjectsCollectedByMinorGC) { … }
namespace {
std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfileNode>
buildSampingHeapProfileNode(v8::Isolate* isolate,
const v8::AllocationProfile::Node* node) { … }
}
Response V8HeapProfilerAgentImpl::stopSampling(
std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfile>* profile) { … }
Response V8HeapProfilerAgentImpl::getSamplingProfile(
std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfile>* profile) { … }
}