Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/profiler/cpu-profiler.h" | 5 #include "src/profiler/cpu-profiler.h" |
| 6 | 6 |
| 7 #include "src/debug/debug.h" | 7 #include "src/debug/debug.h" |
| 8 #include "src/deoptimizer.h" | 8 #include "src/deoptimizer.h" |
| 9 #include "src/frames-inl.h" | 9 #include "src/frames-inl.h" |
| 10 #include "src/locked-queue-inl.h" | 10 #include "src/locked-queue-inl.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 void CpuProfiler::set_sampling_interval(base::TimeDelta value) { | 270 void CpuProfiler::set_sampling_interval(base::TimeDelta value) { |
| 271 DCHECK(!is_profiling_); | 271 DCHECK(!is_profiling_); |
| 272 sampling_interval_ = value; | 272 sampling_interval_ = value; |
| 273 } | 273 } |
| 274 | 274 |
| 275 void CpuProfiler::ResetProfiles() { | 275 void CpuProfiler::ResetProfiles() { |
| 276 profiles_.reset(new CpuProfilesCollection(isolate_)); | 276 profiles_.reset(new CpuProfilesCollection(isolate_)); |
| 277 profiles_->set_cpu_profiler(this); | 277 profiles_->set_cpu_profiler(this); |
| 278 } | 278 } |
| 279 | 279 |
| 280 void CpuProfiler::CreateEntriesForRuntimeCallStats() { | |
| 281 static_entries_.clear(); | |
| 282 RuntimeCallStats* rcs = isolate_->counters()->runtime_call_stats(); | |
| 283 CodeMap* code_map = generator_->code_map(); | |
| 284 for (int i = 0; i < RuntimeCallStats::counters_count; ++i) { | |
| 285 RuntimeCallCounter* counter = &(rcs->*(RuntimeCallStats::counters[i])); | |
| 286 DCHECK(counter->name()); | |
|
Camillo Bruni
2017/01/26 18:17:31
nit: DCHECK_NOT_NULL
| |
| 287 std::unique_ptr<CodeEntry> entry( | |
| 288 new CodeEntry(CodeEventListener::FUNCTION_TAG, counter->name(), | |
| 289 CodeEntry::kEmptyNamePrefix, "native V8Runtime")); | |
|
fmeawad
2017/01/26 15:37:58
Another option is to generate them from the counte
alph
2017/01/26 18:05:56
Sorry, I didn't get it. What do you mean?
| |
| 290 code_map->AddCode(reinterpret_cast<Address>(counter), entry.get(), 1); | |
| 291 static_entries_.push_back(std::move(entry)); | |
| 292 } | |
| 293 } | |
| 294 | |
| 280 void CpuProfiler::CollectSample() { | 295 void CpuProfiler::CollectSample() { |
| 281 if (processor_) { | 296 if (processor_) { |
| 282 processor_->AddCurrentStack(isolate_); | 297 processor_->AddCurrentStack(isolate_); |
| 283 } | 298 } |
| 284 } | 299 } |
| 285 | 300 |
| 286 void CpuProfiler::StartProfiling(const char* title, bool record_samples) { | 301 void CpuProfiler::StartProfiling(const char* title, bool record_samples) { |
| 287 if (profiles_->StartProfiling(title, record_samples)) { | 302 if (profiles_->StartProfiling(title, record_samples)) { |
| 288 StartProcessorIfNotStarted(); | 303 StartProcessorIfNotStarted(); |
| 289 } | 304 } |
| 290 } | 305 } |
| 291 | 306 |
| 292 | 307 |
| 293 void CpuProfiler::StartProfiling(String* title, bool record_samples) { | 308 void CpuProfiler::StartProfiling(String* title, bool record_samples) { |
| 294 StartProfiling(profiles_->GetName(title), record_samples); | 309 StartProfiling(profiles_->GetName(title), record_samples); |
| 295 isolate_->debug()->feature_tracker()->Track(DebugFeatureTracker::kProfiler); | 310 isolate_->debug()->feature_tracker()->Track(DebugFeatureTracker::kProfiler); |
| 296 } | 311 } |
| 297 | 312 |
| 298 | 313 |
| 299 void CpuProfiler::StartProcessorIfNotStarted() { | 314 void CpuProfiler::StartProcessorIfNotStarted() { |
| 300 if (processor_) { | 315 if (processor_) { |
| 301 processor_->AddCurrentStack(isolate_); | 316 processor_->AddCurrentStack(isolate_); |
| 302 return; | 317 return; |
| 303 } | 318 } |
| 304 Logger* logger = isolate_->logger(); | 319 Logger* logger = isolate_->logger(); |
| 305 // Disable logging when using the new implementation. | 320 // Disable logging when using the new implementation. |
| 306 saved_is_logging_ = logger->is_logging_; | 321 saved_is_logging_ = logger->is_logging_; |
| 307 logger->is_logging_ = false; | 322 logger->is_logging_ = false; |
| 308 generator_.reset(new ProfileGenerator(isolate_, profiles_.get())); | 323 generator_.reset(new ProfileGenerator(profiles_.get())); |
| 309 processor_.reset(new ProfilerEventsProcessor(isolate_, generator_.get(), | 324 processor_.reset(new ProfilerEventsProcessor(isolate_, generator_.get(), |
| 310 sampling_interval_)); | 325 sampling_interval_)); |
| 326 CreateEntriesForRuntimeCallStats(); | |
| 311 logger->SetUpProfilerListener(); | 327 logger->SetUpProfilerListener(); |
| 312 ProfilerListener* profiler_listener = logger->profiler_listener(); | 328 ProfilerListener* profiler_listener = logger->profiler_listener(); |
| 313 profiler_listener->AddObserver(this); | 329 profiler_listener->AddObserver(this); |
| 314 is_profiling_ = true; | 330 is_profiling_ = true; |
| 315 isolate_->set_is_profiling(true); | 331 isolate_->set_is_profiling(true); |
| 316 // Enumerate stuff we already have in the heap. | 332 // Enumerate stuff we already have in the heap. |
| 317 DCHECK(isolate_->heap()->HasBeenSetUp()); | 333 DCHECK(isolate_->heap()->HasBeenSetUp()); |
| 318 if (!FLAG_prof_browser_mode) { | 334 if (!FLAG_prof_browser_mode) { |
| 319 logger->LogCodeObjects(); | 335 logger->LogCodeObjects(); |
| 320 } | 336 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; | 379 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; |
| 364 Builtins::Name id = static_cast<Builtins::Name>(i); | 380 Builtins::Name id = static_cast<Builtins::Name>(i); |
| 365 rec->start = builtins->builtin(id)->address(); | 381 rec->start = builtins->builtin(id)->address(); |
| 366 rec->builtin_id = id; | 382 rec->builtin_id = id; |
| 367 processor_->Enqueue(evt_rec); | 383 processor_->Enqueue(evt_rec); |
| 368 } | 384 } |
| 369 } | 385 } |
| 370 | 386 |
| 371 } // namespace internal | 387 } // namespace internal |
| 372 } // namespace v8 | 388 } // namespace v8 |
| OLD | NEW |