Commit 1426ea1d authored by Alexei Filippov's avatar Alexei Filippov Committed by Commit Bot

[cpu-profiler] Lazily create CPU profiler.

We cannot drop the deprecated API right away because we need to keep binary compatiblity.
As a short term solution create CPU profiler lazily if the API is called.

BUG=v8:7070

Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: I04029844895976b25db165f4fba6afbfe1681913
Reviewed-on: https://chromium-review.googlesource.com/1047848Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Alexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53113}
parent 0263383d
......@@ -8016,7 +8016,7 @@ HeapProfiler* Isolate::GetHeapProfiler() {
CpuProfiler* Isolate::GetCpuProfiler() {
i::CpuProfiler* cpu_profiler =
reinterpret_cast<i::Isolate*>(this)->cpu_profiler();
reinterpret_cast<i::Isolate*>(this)->EnsureCpuProfiler();
return reinterpret_cast<CpuProfiler*>(cpu_profiler);
}
......
......@@ -2969,7 +2969,6 @@ bool Isolate::Init(StartupDeserializer* des) {
date_cache_ = new DateCache();
call_descriptor_data_ =
new CallInterfaceDescriptorData[CallDescriptors::NUMBER_OF_DESCRIPTORS];
cpu_profiler_ = new CpuProfiler(this);
heap_profiler_ = new HeapProfiler(heap());
interpreter_ = new interpreter::Interpreter(this);
compiler_dispatcher_ =
......@@ -4065,6 +4064,13 @@ void Isolate::SetIdle(bool is_idle) {
}
}
CpuProfiler* Isolate::EnsureCpuProfiler() {
if (!cpu_profiler_) {
cpu_profiler_ = new CpuProfiler(this);
}
return cpu_profiler_;
}
bool StackLimitCheck::JsHasOverflowed(uintptr_t gap) const {
StackGuard* stack_guard = isolate_->stack_guard();
#ifdef USE_SIMULATOR
......
......@@ -1495,7 +1495,7 @@ class Isolate : private HiddenFactory {
// TODO(alph): Remove along with the deprecated GetCpuProfiler().
friend v8::CpuProfiler* v8::Isolate::GetCpuProfiler();
CpuProfiler* cpu_profiler() const { return cpu_profiler_; }
CpuProfiler* EnsureCpuProfiler();
base::Atomic32 id_;
EntryStackItem* entry_stack_;
......
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