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

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

Issue 2000323007: Revert of Create libsampler as V8 sampler library. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 "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"
11 #include "src/log-inl.h" 11 #include "src/log-inl.h"
12 #include "src/profiler/cpu-profiler-inl.h" 12 #include "src/profiler/cpu-profiler-inl.h"
13 #include "src/vm-state-inl.h" 13 #include "src/vm-state-inl.h"
14 14
15 #include "include/v8-profiler.h" 15 #include "include/v8-profiler.h"
16 16
17 namespace v8 { 17 namespace v8 {
18 namespace internal { 18 namespace internal {
19 19
20 static const int kProfilerStackSize = 64 * KB; 20 static const int kProfilerStackSize = 64 * KB;
21 21
22 22
23 ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator, 23 ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator,
24 sampler::Sampler* sampler, 24 Sampler* sampler,
25 base::TimeDelta period) 25 base::TimeDelta period)
26 : Thread(Thread::Options("v8:ProfEvntProc", kProfilerStackSize)), 26 : Thread(Thread::Options("v8:ProfEvntProc", kProfilerStackSize)),
27 generator_(generator), 27 generator_(generator),
28 sampler_(sampler), 28 sampler_(sampler),
29 running_(1), 29 running_(1),
30 period_(period), 30 period_(period),
31 last_code_event_id_(0), 31 last_code_event_id_(0),
32 last_processed_code_event_id_(0) {} 32 last_processed_code_event_id_(0) {}
33 33
34 34
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 void CpuProfiler::StartProcessorIfNotStarted() { 559 void CpuProfiler::StartProcessorIfNotStarted() {
560 if (processor_ != NULL) { 560 if (processor_ != NULL) {
561 processor_->AddCurrentStack(isolate_); 561 processor_->AddCurrentStack(isolate_);
562 return; 562 return;
563 } 563 }
564 Logger* logger = isolate_->logger(); 564 Logger* logger = isolate_->logger();
565 // Disable logging when using the new implementation. 565 // Disable logging when using the new implementation.
566 saved_is_logging_ = logger->is_logging_; 566 saved_is_logging_ = logger->is_logging_;
567 logger->is_logging_ = false; 567 logger->is_logging_ = false;
568 generator_ = new ProfileGenerator(profiles_); 568 generator_ = new ProfileGenerator(profiles_);
569 sampler::Sampler* sampler = logger->sampler(); 569 Sampler* sampler = logger->sampler();
570 processor_ = new ProfilerEventsProcessor( 570 processor_ = new ProfilerEventsProcessor(
571 generator_, sampler, sampling_interval_); 571 generator_, sampler, sampling_interval_);
572 is_profiling_ = true; 572 is_profiling_ = true;
573 // Enumerate stuff we already have in the heap. 573 // Enumerate stuff we already have in the heap.
574 DCHECK(isolate_->heap()->HasBeenSetUp()); 574 DCHECK(isolate_->heap()->HasBeenSetUp());
575 if (!FLAG_prof_browser_mode) { 575 if (!FLAG_prof_browser_mode) {
576 logger->LogCodeObjects(); 576 logger->LogCodeObjects();
577 } 577 }
578 logger->LogCompiledFunctions(); 578 logger->LogCompiledFunctions();
579 logger->LogAccessorCallbacks(); 579 logger->LogAccessorCallbacks();
(...skipping 25 matching lines...) Expand all
605 } 605 }
606 606
607 607
608 void CpuProfiler::StopProcessorIfLastProfile(const char* title) { 608 void CpuProfiler::StopProcessorIfLastProfile(const char* title) {
609 if (profiles_->IsLastProfile(title)) StopProcessor(); 609 if (profiles_->IsLastProfile(title)) StopProcessor();
610 } 610 }
611 611
612 612
613 void CpuProfiler::StopProcessor() { 613 void CpuProfiler::StopProcessor() {
614 Logger* logger = isolate_->logger(); 614 Logger* logger = isolate_->logger();
615 sampler::Sampler* sampler = 615 Sampler* sampler = reinterpret_cast<Sampler*>(logger->ticker_);
616 reinterpret_cast<sampler::Sampler*>(logger->ticker_);
617 is_profiling_ = false; 616 is_profiling_ = false;
618 processor_->StopSynchronously(); 617 processor_->StopSynchronously();
619 delete processor_; 618 delete processor_;
620 delete generator_; 619 delete generator_;
621 processor_ = NULL; 620 processor_ = NULL;
622 generator_ = NULL; 621 generator_ = NULL;
623 sampler->SetHasProcessingThread(false); 622 sampler->SetHasProcessingThread(false);
624 sampler->DecreaseProfilingDepth(); 623 sampler->DecreaseProfilingDepth();
625 logger->is_logging_ = saved_is_logging_; 624 logger->is_logging_ = saved_is_logging_;
626 } 625 }
627 626
628 627
629 void CpuProfiler::LogBuiltins() { 628 void CpuProfiler::LogBuiltins() {
630 Builtins* builtins = isolate_->builtins(); 629 Builtins* builtins = isolate_->builtins();
631 DCHECK(builtins->is_initialized()); 630 DCHECK(builtins->is_initialized());
632 for (int i = 0; i < Builtins::builtin_count; i++) { 631 for (int i = 0; i < Builtins::builtin_count; i++) {
633 CodeEventsContainer evt_rec(CodeEventRecord::REPORT_BUILTIN); 632 CodeEventsContainer evt_rec(CodeEventRecord::REPORT_BUILTIN);
634 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; 633 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_;
635 Builtins::Name id = static_cast<Builtins::Name>(i); 634 Builtins::Name id = static_cast<Builtins::Name>(i);
636 rec->start = builtins->builtin(id)->address(); 635 rec->start = builtins->builtin(id)->address();
637 rec->builtin_id = id; 636 rec->builtin_id = id;
638 processor_->Enqueue(evt_rec); 637 processor_->Enqueue(evt_rec);
639 } 638 }
640 } 639 }
641 640
642 641
643 } // namespace internal 642 } // namespace internal
644 } // namespace v8 643 } // 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