diff options
Diffstat (limited to 'deps/v8/include/v8-profiler.h')
-rw-r--r-- | deps/v8/include/v8-profiler.h | 77 |
1 files changed, 66 insertions, 11 deletions
diff --git a/deps/v8/include/v8-profiler.h b/deps/v8/include/v8-profiler.h index 672a694e07..46d3eb8aa4 100644 --- a/deps/v8/include/v8-profiler.h +++ b/deps/v8/include/v8-profiler.h @@ -5,6 +5,7 @@ #ifndef V8_V8_PROFILER_H_ #define V8_V8_PROFILER_H_ +#include <limits.h> #include <unordered_set> #include <vector> #include "v8.h" // NOLINT(build/include) @@ -297,6 +298,53 @@ enum CpuProfilingMode { kCallerLineNumbers, }; +// Determines how names are derived for functions sampled. +enum CpuProfilingNamingMode { + // Use the immediate name of functions at compilation time. + kStandardNaming, + // Use more verbose naming for functions without names, inferred from scope + // where possible. + kDebugNaming, +}; + +/** + * Optional profiling attributes. + */ +class V8_EXPORT CpuProfilingOptions { + public: + // Indicates that the sample buffer size should not be explicitly limited. + static const unsigned kNoSampleLimit = UINT_MAX; + + /** + * \param mode Type of computation of stack frame line numbers. + * \param max_samples The maximum number of samples that should be recorded by + * the profiler. Samples obtained after this limit will be + * discarded. + * \param sampling_interval_us controls the profile-specific target + * sampling interval. The provided sampling + * interval will be snapped to the next lowest + * non-zero multiple of the profiler's sampling + * interval, set via SetSamplingInterval(). If + * zero, the sampling interval will be equal to + * the profiler's sampling interval. + */ + CpuProfilingOptions(CpuProfilingMode mode = kLeafNodeLineNumbers, + unsigned max_samples = kNoSampleLimit, + int sampling_interval_us = 0) + : mode_(mode), + max_samples_(max_samples), + sampling_interval_us_(sampling_interval_us) {} + + CpuProfilingMode mode() const { return mode_; } + unsigned max_samples() const { return max_samples_; } + int sampling_interval_us() const { return sampling_interval_us_; } + + private: + CpuProfilingMode mode_; + unsigned max_samples_; + int sampling_interval_us_; +}; + /** * Interface for controlling CPU profiling. Instance of the * profiler can be created using v8::CpuProfiler::New method. @@ -308,7 +356,8 @@ class V8_EXPORT CpuProfiler { * initialized. The profiler object must be disposed after use by calling * |Dispose| method. */ - static CpuProfiler* New(Isolate* isolate); + static CpuProfiler* New(Isolate* isolate, + CpuProfilingNamingMode = kDebugNaming); /** * Synchronously collect current stack sample in all profilers attached to @@ -339,18 +388,26 @@ class V8_EXPORT CpuProfiler { void SetUsePreciseSampling(bool); /** - * Starts collecting CPU profile. Title may be an empty string. It - * is allowed to have several profiles being collected at - * once. Attempts to start collecting several profiles with the same - * title are silently ignored. While collecting a profile, functions - * from all security contexts are included in it. The token-based - * filtering is only performed when querying for a profile. + * Starts collecting a CPU profile. Title may be an empty string. Several + * profiles may be collected at once. Attempts to start collecting several + * profiles with the same title are silently ignored. + */ + void StartProfiling(Local<String> title, CpuProfilingOptions options); + + /** + * Starts profiling with the same semantics as above, except with expanded + * parameters. * * |record_samples| parameter controls whether individual samples should * be recorded in addition to the aggregated tree. + * + * |max_samples| controls the maximum number of samples that should be + * recorded by the profiler. Samples obtained after this limit will be + * discarded. */ - void StartProfiling(Local<String> title, CpuProfilingMode mode, - bool record_samples = false); + void StartProfiling( + Local<String> title, CpuProfilingMode mode, bool record_samples = false, + unsigned max_samples = CpuProfilingOptions::kNoSampleLimit); /** * The same as StartProfiling above, but the CpuProfilingMode defaults to * kLeafNodeLineNumbers mode, which was the previous default behavior of the @@ -391,7 +448,6 @@ class V8_EXPORT CpuProfiler { CpuProfiler& operator=(const CpuProfiler&); }; - /** * HeapSnapshotEdge represents a directed connection between heap * graph nodes: from retainers to retained nodes. @@ -742,7 +798,6 @@ class V8_EXPORT EmbedderGraph { */ virtual const char* NamePrefix() { return nullptr; } - private: Node(const Node&) = delete; Node& operator=(const Node&) = delete; }; |