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

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

Issue 1708573003: [WIP]Create a V8 sampler library and tracing controller. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 | « src/profiler/cpu-profiler.h ('k') | src/profiler/sampler.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 "include/v8-sampler.h"
7 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
8 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
9 #include "src/frames-inl.h" 10 #include "src/frames-inl.h"
10 #include "src/locked-queue-inl.h" 11 #include "src/locked-queue-inl.h"
11 #include "src/log-inl.h" 12 #include "src/log-inl.h"
12 #include "src/profiler/cpu-profiler-inl.h" 13 #include "src/profiler/cpu-profiler-inl.h"
13 #include "src/vm-state-inl.h" 14 #include "src/vm-state-inl.h"
14 15
15 #include "include/v8-profiler.h" 16 #include "include/v8-profiler.h"
16 17
17 namespace v8 { 18 namespace v8 {
18 namespace internal { 19 namespace internal {
19 20
20 static const int kProfilerStackSize = 64 * KB; 21 static const int kProfilerStackSize = 64 * KB;
21 22
22 23
23 ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator, 24 ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator,
24 Sampler* sampler, 25 V8Sampler* sampler,
25 base::TimeDelta period) 26 base::TimeDelta period)
26 : Thread(Thread::Options("v8:ProfEvntProc", kProfilerStackSize)), 27 : Thread(Thread::Options("v8:ProfEvntProc", kProfilerStackSize)),
27 generator_(generator), 28 generator_(generator),
28 sampler_(sampler), 29 sampler_(sampler),
29 running_(1), 30 running_(1),
30 period_(period), 31 period_(period),
31 last_code_event_id_(0), 32 last_code_event_id_(0),
32 last_processed_code_event_id_(0) {} 33 last_processed_code_event_id_(0) {}
33 34
34 35
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 void CpuProfiler::StartProcessorIfNotStarted() { 452 void CpuProfiler::StartProcessorIfNotStarted() {
452 if (processor_ != NULL) { 453 if (processor_ != NULL) {
453 processor_->AddCurrentStack(isolate_); 454 processor_->AddCurrentStack(isolate_);
454 return; 455 return;
455 } 456 }
456 Logger* logger = isolate_->logger(); 457 Logger* logger = isolate_->logger();
457 // Disable logging when using the new implementation. 458 // Disable logging when using the new implementation.
458 saved_is_logging_ = logger->is_logging_; 459 saved_is_logging_ = logger->is_logging_;
459 logger->is_logging_ = false; 460 logger->is_logging_ = false;
460 generator_ = new ProfileGenerator(profiles_); 461 generator_ = new ProfileGenerator(profiles_);
461 Sampler* sampler = logger->sampler(); 462 // Sampler* sampler = logger->sampler();
463 V8Sampler* sampler = logger->sampler();
462 processor_ = new ProfilerEventsProcessor( 464 processor_ = new ProfilerEventsProcessor(
463 generator_, sampler, sampling_interval_); 465 generator_, sampler, sampling_interval_);
464 is_profiling_ = true; 466 is_profiling_ = true;
465 // Enumerate stuff we already have in the heap. 467 // Enumerate stuff we already have in the heap.
466 DCHECK(isolate_->heap()->HasBeenSetUp()); 468 DCHECK(isolate_->heap()->HasBeenSetUp());
467 if (!FLAG_prof_browser_mode) { 469 if (!FLAG_prof_browser_mode) {
468 logger->LogCodeObjects(); 470 logger->LogCodeObjects();
469 } 471 }
470 logger->LogCompiledFunctions(); 472 logger->LogCompiledFunctions();
471 logger->LogAccessorCallbacks(); 473 logger->LogAccessorCallbacks();
(...skipping 25 matching lines...) Expand all
497 } 499 }
498 500
499 501
500 void CpuProfiler::StopProcessorIfLastProfile(const char* title) { 502 void CpuProfiler::StopProcessorIfLastProfile(const char* title) {
501 if (profiles_->IsLastProfile(title)) StopProcessor(); 503 if (profiles_->IsLastProfile(title)) StopProcessor();
502 } 504 }
503 505
504 506
505 void CpuProfiler::StopProcessor() { 507 void CpuProfiler::StopProcessor() {
506 Logger* logger = isolate_->logger(); 508 Logger* logger = isolate_->logger();
507 Sampler* sampler = reinterpret_cast<Sampler*>(logger->ticker_); 509 // Sampler* sampler = reinterpret_cast<Sampler*>(logger->ticker_);
510 V8Sampler* sampler = reinterpret_cast<V8Sampler*>(logger->ticker_);
508 is_profiling_ = false; 511 is_profiling_ = false;
509 processor_->StopSynchronously(); 512 processor_->StopSynchronously();
510 delete processor_; 513 delete processor_;
511 delete generator_; 514 delete generator_;
512 processor_ = NULL; 515 processor_ = NULL;
513 generator_ = NULL; 516 generator_ = NULL;
514 sampler->SetHasProcessingThread(false); 517 sampler->SetHasProcessingThread(false);
515 sampler->DecreaseProfilingDepth(); 518 sampler->DecreaseProfilingDepth();
516 logger->is_logging_ = saved_is_logging_; 519 logger->is_logging_ = saved_is_logging_;
517 } 520 }
518 521
519 522
520 void CpuProfiler::LogBuiltins() { 523 void CpuProfiler::LogBuiltins() {
521 Builtins* builtins = isolate_->builtins(); 524 Builtins* builtins = isolate_->builtins();
522 DCHECK(builtins->is_initialized()); 525 DCHECK(builtins->is_initialized());
523 for (int i = 0; i < Builtins::builtin_count; i++) { 526 for (int i = 0; i < Builtins::builtin_count; i++) {
524 CodeEventsContainer evt_rec(CodeEventRecord::REPORT_BUILTIN); 527 CodeEventsContainer evt_rec(CodeEventRecord::REPORT_BUILTIN);
525 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; 528 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_;
526 Builtins::Name id = static_cast<Builtins::Name>(i); 529 Builtins::Name id = static_cast<Builtins::Name>(i);
527 rec->start = builtins->builtin(id)->address(); 530 rec->start = builtins->builtin(id)->address();
528 rec->builtin_id = id; 531 rec->builtin_id = id;
529 processor_->Enqueue(evt_rec); 532 processor_->Enqueue(evt_rec);
530 } 533 }
531 } 534 }
532 535
533 536
534 } // namespace internal 537 } // namespace internal
535 } // namespace v8 538 } // namespace v8
OLDNEW
« no previous file with comments | « src/profiler/cpu-profiler.h ('k') | src/profiler/sampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698