Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: src/profiler/cpu-profiler.cc

Issue 2396733002: [profiler] Tracing-based CPU profiler. (Closed)
Patch Set: Addressing comments + moving traced-value back to src/tracing Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/v8-profiler.h ('k') | src/profiler/profile-generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 logger->LogCodeObjects(); 319 logger->LogCodeObjects();
320 } 320 }
321 logger->LogCompiledFunctions(); 321 logger->LogCompiledFunctions();
322 logger->LogAccessorCallbacks(); 322 logger->LogAccessorCallbacks();
323 LogBuiltins(); 323 LogBuiltins();
324 // Enable stack sampling. 324 // Enable stack sampling.
325 processor_->AddCurrentStack(isolate_); 325 processor_->AddCurrentStack(isolate_);
326 processor_->StartSynchronously(); 326 processor_->StartSynchronously();
327 } 327 }
328 328
329
330 CpuProfile* CpuProfiler::StopProfiling(const char* title) { 329 CpuProfile* CpuProfiler::StopProfiling(const char* title) {
331 if (!is_profiling_) return nullptr; 330 if (!is_profiling_) return nullptr;
332 StopProcessorIfLastProfile(title); 331 StopProcessorIfLastProfile(title);
333 CpuProfile* result = profiles_->StopProfiling(title); 332 return profiles_->StopProfiling(title);
334 if (result) {
335 result->Print();
336 }
337 return result;
338 } 333 }
339 334
340
341 CpuProfile* CpuProfiler::StopProfiling(String* title) { 335 CpuProfile* CpuProfiler::StopProfiling(String* title) {
342 if (!is_profiling_) return nullptr; 336 return StopProfiling(profiles_->GetName(title));
343 const char* profile_title = profiles_->GetName(title);
344 StopProcessorIfLastProfile(profile_title);
345 return profiles_->StopProfiling(profile_title);
346 } 337 }
347 338
348
349 void CpuProfiler::StopProcessorIfLastProfile(const char* title) { 339 void CpuProfiler::StopProcessorIfLastProfile(const char* title) {
350 if (profiles_->IsLastProfile(title)) { 340 if (!profiles_->IsLastProfile(title)) return;
351 StopProcessor(); 341 StopProcessor();
352 }
353 } 342 }
354 343
355
356 void CpuProfiler::StopProcessor() { 344 void CpuProfiler::StopProcessor() {
357 Logger* logger = isolate_->logger(); 345 Logger* logger = isolate_->logger();
358 is_profiling_ = false; 346 is_profiling_ = false;
359 isolate_->set_is_profiling(false); 347 isolate_->set_is_profiling(false);
360 ProfilerListener* profiler_listener = logger->profiler_listener(); 348 ProfilerListener* profiler_listener = logger->profiler_listener();
361 profiler_listener->RemoveObserver(this); 349 profiler_listener->RemoveObserver(this);
362 processor_->StopSynchronously(); 350 processor_->StopSynchronously();
363 logger->TearDownProfilerListener(); 351 logger->TearDownProfilerListener();
364 processor_.reset(); 352 processor_.reset();
365 generator_.reset(); 353 generator_.reset();
366 logger->is_logging_ = saved_is_logging_; 354 logger->is_logging_ = saved_is_logging_;
367 } 355 }
368 356
369 357
370 void CpuProfiler::LogBuiltins() { 358 void CpuProfiler::LogBuiltins() {
371 Builtins* builtins = isolate_->builtins(); 359 Builtins* builtins = isolate_->builtins();
372 DCHECK(builtins->is_initialized()); 360 DCHECK(builtins->is_initialized());
373 for (int i = 0; i < Builtins::builtin_count; i++) { 361 for (int i = 0; i < Builtins::builtin_count; i++) {
374 CodeEventsContainer evt_rec(CodeEventRecord::REPORT_BUILTIN); 362 CodeEventsContainer evt_rec(CodeEventRecord::REPORT_BUILTIN);
375 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; 363 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_;
376 Builtins::Name id = static_cast<Builtins::Name>(i); 364 Builtins::Name id = static_cast<Builtins::Name>(i);
377 rec->start = builtins->builtin(id)->address(); 365 rec->start = builtins->builtin(id)->address();
378 rec->builtin_id = id; 366 rec->builtin_id = id;
379 processor_->Enqueue(evt_rec); 367 processor_->Enqueue(evt_rec);
380 } 368 }
381 } 369 }
382 370
383 } // namespace internal 371 } // namespace internal
384 } // namespace v8 372 } // namespace v8
OLDNEW
« no previous file with comments | « include/v8-profiler.h ('k') | src/profiler/profile-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698