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