|
1 | 1 | #include "node_internals.h"
|
2 | 2 | #include "async_wrap.h"
|
3 |
| -#include "v8-profiler.h" |
4 | 3 |
|
5 | 4 | #include <stdio.h>
|
6 | 5 | #include <algorithm>
|
@@ -65,6 +64,15 @@ IsolateData::IsolateData(Isolate* isolate,
|
65 | 64 | IsolateData::~IsolateData() {
|
66 | 65 | if (platform_ != nullptr)
|
67 | 66 | platform_->UnregisterIsolate(this);
|
| 67 | + if (cpu_profiler_ != nullptr) |
| 68 | + cpu_profiler_->Dispose(); |
| 69 | +} |
| 70 | + |
| 71 | +v8::CpuProfiler* IsolateData::GetCpuProfiler() { |
| 72 | + if (cpu_profiler_ != nullptr) return cpu_profiler_; |
| 73 | + cpu_profiler_ = v8::CpuProfiler::New(isolate()); |
| 74 | + CHECK_NE(cpu_profiler_, nullptr); |
| 75 | + return cpu_profiler_; |
68 | 76 | }
|
69 | 77 |
|
70 | 78 | void Environment::Start(int argc,
|
@@ -150,12 +158,12 @@ void Environment::CleanupHandles() {
|
150 | 158 | void Environment::StartProfilerIdleNotifier() {
|
151 | 159 | uv_prepare_start(&idle_prepare_handle_, [](uv_prepare_t* handle) {
|
152 | 160 | Environment* env = ContainerOf(&Environment::idle_prepare_handle_, handle);
|
153 |
| - env->isolate()->GetCpuProfiler()->SetIdle(true); |
| 161 | + env->isolate_data()->GetCpuProfiler()->SetIdle(true); |
154 | 162 | });
|
155 | 163 |
|
156 | 164 | uv_check_start(&idle_check_handle_, [](uv_check_t* handle) {
|
157 | 165 | Environment* env = ContainerOf(&Environment::idle_check_handle_, handle);
|
158 |
| - env->isolate()->GetCpuProfiler()->SetIdle(false); |
| 166 | + env->isolate_data()->GetCpuProfiler()->SetIdle(false); |
159 | 167 | });
|
160 | 168 | }
|
161 | 169 |
|
|
0 commit comments