Commit e4e3650e authored by alph's avatar alph Committed by Commit bot

[profiler] Introduce Tracing CPU profiler V8 API.

Tracing CPU profiler allows V8 to automatically collect CPU profile when tracing
is started with category v8.cpu_profile2 enabled.

BUG=chromium:406277

Review-Url: https://codereview.chromium.org/2378143003
Cr-Commit-Position: refs/heads/master@{#39855}
parent 9af3142f
......@@ -1535,6 +1535,8 @@ v8_source_set("v8_base") {
"src/profiler/strings-storage.h",
"src/profiler/tick-sample.cc",
"src/profiler/tick-sample.h",
"src/profiler/tracing-cpu-profiler.cc",
"src/profiler/tracing-cpu-profiler.h",
"src/profiler/unbound-queue-inl.h",
"src/profiler/unbound-queue.h",
"src/property-descriptor.cc",
......
......@@ -46,6 +46,20 @@ template class V8_EXPORT std::vector<v8::CpuProfileDeoptInfo>;
namespace v8 {
/**
* TracingCpuProfiler monitors tracing being enabled/disabled
* and emits CpuProfile trace events once v8.cpu_profile2 tracing category
* is enabled. It has no overhead unless the category is enabled.
*/
class V8_EXPORT TracingCpuProfiler {
public:
static std::unique_ptr<TracingCpuProfiler> Create(Isolate*);
virtual ~TracingCpuProfiler() = default;
protected:
TracingCpuProfiler() = default;
};
// TickSample captures the information collected for each sample.
struct TickSample {
// Internal profiling (with --prof + tools/$OS-tick-processor) wants to
......
// Copyright 2016 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.
#include "src/profiler/tracing-cpu-profiler.h"
#include "src/v8.h"
namespace v8 {
std::unique_ptr<TracingCpuProfiler> TracingCpuProfiler::Create(
v8::Isolate* isolate) {
return std::unique_ptr<TracingCpuProfiler>(
new internal::TracingCpuProfilerImpl(
reinterpret_cast<internal::Isolate*>(isolate)));
}
namespace internal {
TracingCpuProfilerImpl::TracingCpuProfilerImpl(Isolate* isolate) {}
TracingCpuProfilerImpl::~TracingCpuProfilerImpl() {}
} // namespace internal
} // namespace v8
// Copyright 2016 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_PROFILER_TRACING_CPU_PROFILER_H
#define V8_PROFILER_TRACING_CPU_PROFILER_H
#include "include/v8-profiler.h"
#include "src/base/macros.h"
namespace v8 {
namespace internal {
class TracingCpuProfilerImpl final : public TracingCpuProfiler {
public:
explicit TracingCpuProfilerImpl(Isolate*);
~TracingCpuProfilerImpl();
private:
DISALLOW_COPY_AND_ASSIGN(TracingCpuProfilerImpl);
};
} // namespace internal
} // namespace v8
#endif // V8_PROFILER_TRACING_CPU_PROFILER_H
......@@ -1103,6 +1103,8 @@
'profiler/strings-storage.h',
'profiler/tick-sample.cc',
'profiler/tick-sample.h',
'profiler/tracing-cpu-profiler.cc',
'profiler/tracing-cpu-profiler.h',
'profiler/unbound-queue-inl.h',
'profiler/unbound-queue.h',
'property-descriptor.cc',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment