// Copyright 2010 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_V8_PROFILER_H_ #define V8_V8_PROFILER_H_ #include <limits.h> #include <memory> #include <unordered_set> #include <vector> #include "cppgc/common.h" // NOLINT(build/include_directory) #include "v8-local-handle.h" // NOLINT(build/include_directory) #include "v8-message.h" // NOLINT(build/include_directory) #include "v8-persistent-handle.h" // NOLINT(build/include_directory) /** * Profiler support for the V8 JavaScript engine. */ namespace v8 { enum class EmbedderStateTag : uint8_t; class HeapGraphNode; struct HeapStatsUpdate; class Object; enum StateTag : uint16_t; NativeObject; SnapshotObjectId; ProfilerId; struct CpuProfileDeoptFrame { … }; namespace internal { class CpuProfile; } // namespace internal } // namespace v8 #ifdef V8_OS_WIN template class V8_EXPORT std::vector<v8::CpuProfileDeoptFrame>; #endif namespace v8 { struct V8_EXPORT CpuProfileDeoptInfo { … }; } // namespace v8 #ifdef V8_OS_WIN template class V8_EXPORT std::vector<v8::CpuProfileDeoptInfo>; #endif namespace v8 { /** * CpuProfileNode represents a node in a call graph. */ class V8_EXPORT CpuProfileNode { … }; /** * An interface for exporting data from V8, using "push" model. */ class V8_EXPORT OutputStream { … }; /** * CpuProfile contains a CPU profile in a form of top-down call tree * (from main() down to functions that do all the work). */ class V8_EXPORT CpuProfile { … }; enum CpuProfilingMode { … }; // Determines how names are derived for functions sampled. enum CpuProfilingNamingMode { … }; enum CpuProfilingLoggingMode { … }; // Enum for returning profiling status. Once StartProfiling is called, // we want to return to clients whether the profiling was able to start // correctly, or return a descriptive error. enum class CpuProfilingStatus { … }; /** * Result from StartProfiling returning the Profiling Status, and * id of the started profiler, or 0 if profiler is not started */ struct CpuProfilingResult { … }; /** * Delegate for when max samples reached and samples are discarded. */ class V8_EXPORT DiscardedSamplesDelegate { … }; /** * Optional profiling attributes. */ class V8_EXPORT CpuProfilingOptions { … }; /** * Interface for controlling CPU profiling. Instance of the * profiler can be created using v8::CpuProfiler::New method. */ class V8_EXPORT CpuProfiler { … }; /** * HeapSnapshotEdge represents a directed connection between heap * graph nodes: from retainers to retained nodes. */ class V8_EXPORT HeapGraphEdge { … }; /** * HeapGraphNode represents a node in a heap graph. */ class V8_EXPORT HeapGraphNode { … }; /** * HeapSnapshots record the state of the JS heap at some moment. */ class V8_EXPORT HeapSnapshot { … }; /** * An interface for reporting progress and controlling long-running * activities. */ class V8_EXPORT ActivityControl { … }; /** * AllocationProfile is a sampled profile of allocations done by the program. * This is structured as a call-graph. */ class V8_EXPORT AllocationProfile { … }; /** * An object graph consisting of embedder objects and V8 objects. * Edges of the graph are strong references between the objects. * The embedder can build this graph during heap snapshot generation * to include the embedder objects in the heap snapshot. * Usage: * 1) Define derived class of EmbedderGraph::Node for embedder objects. * 2) Set the build embedder graph callback on the heap profiler using * HeapProfiler::AddBuildEmbedderGraphCallback. * 3) In the callback use graph->AddEdge(node1, node2) to add an edge from * node1 to node2. * 4) To represent references from/to V8 object, construct V8 nodes using * graph->V8Node(value). */ class V8_EXPORT EmbedderGraph { … }; class QueryObjectPredicate { … }; /** * Interface for controlling heap profiling. Instance of the * profiler can be retrieved using v8::Isolate::GetHeapProfiler. */ class V8_EXPORT HeapProfiler { … }; /** * A struct for exporting HeapStats data from V8, using "push" model. * See HeapProfiler::GetHeapStats. */ struct HeapStatsUpdate { … }; #define CODE_EVENTS_LIST(V) … /** * Note that this enum may be extended in the future. Please include a default * case if this enum is used in a switch statement. */ enum CodeEventType { … }; /** * Representation of a code creation event */ class V8_EXPORT CodeEvent { … }; /** * Interface to listen to code creation and code relocation events. */ class V8_EXPORT CodeEventHandler { … }; } // namespace v8 #endif // V8_V8_PROFILER_H_