| 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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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* 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 isolate_->set_is_profiling(true); |
| 573 // Enumerate stuff we already have in the heap. | 574 // Enumerate stuff we already have in the heap. |
| 574 DCHECK(isolate_->heap()->HasBeenSetUp()); | 575 DCHECK(isolate_->heap()->HasBeenSetUp()); |
| 575 if (!FLAG_prof_browser_mode) { | 576 if (!FLAG_prof_browser_mode) { |
| 576 logger->LogCodeObjects(); | 577 logger->LogCodeObjects(); |
| 577 } | 578 } |
| 578 logger->LogCompiledFunctions(); | 579 logger->LogCompiledFunctions(); |
| 579 logger->LogAccessorCallbacks(); | 580 logger->LogAccessorCallbacks(); |
| 580 LogBuiltins(); | 581 LogBuiltins(); |
| 581 // Enable stack sampling. | 582 // Enable stack sampling. |
| 582 sampler->SetHasProcessingThread(true); | 583 sampler->SetHasProcessingThread(true); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 608 void CpuProfiler::StopProcessorIfLastProfile(const char* title) { | 609 void CpuProfiler::StopProcessorIfLastProfile(const char* title) { |
| 609 if (profiles_->IsLastProfile(title)) StopProcessor(); | 610 if (profiles_->IsLastProfile(title)) StopProcessor(); |
| 610 } | 611 } |
| 611 | 612 |
| 612 | 613 |
| 613 void CpuProfiler::StopProcessor() { | 614 void CpuProfiler::StopProcessor() { |
| 614 Logger* logger = isolate_->logger(); | 615 Logger* logger = isolate_->logger(); |
| 615 sampler::Sampler* sampler = | 616 sampler::Sampler* sampler = |
| 616 reinterpret_cast<sampler::Sampler*>(logger->ticker_); | 617 reinterpret_cast<sampler::Sampler*>(logger->ticker_); |
| 617 is_profiling_ = false; | 618 is_profiling_ = false; |
| 619 isolate_->set_is_profiling(false); |
| 618 processor_->StopSynchronously(); | 620 processor_->StopSynchronously(); |
| 619 delete processor_; | 621 delete processor_; |
| 620 delete generator_; | 622 delete generator_; |
| 621 processor_ = NULL; | 623 processor_ = NULL; |
| 622 generator_ = NULL; | 624 generator_ = NULL; |
| 623 sampler->SetHasProcessingThread(false); | 625 sampler->SetHasProcessingThread(false); |
| 624 sampler->DecreaseProfilingDepth(); | 626 sampler->DecreaseProfilingDepth(); |
| 625 logger->is_logging_ = saved_is_logging_; | 627 logger->is_logging_ = saved_is_logging_; |
| 626 } | 628 } |
| 627 | 629 |
| 628 | 630 |
| 629 void CpuProfiler::LogBuiltins() { | 631 void CpuProfiler::LogBuiltins() { |
| 630 Builtins* builtins = isolate_->builtins(); | 632 Builtins* builtins = isolate_->builtins(); |
| 631 DCHECK(builtins->is_initialized()); | 633 DCHECK(builtins->is_initialized()); |
| 632 for (int i = 0; i < Builtins::builtin_count; i++) { | 634 for (int i = 0; i < Builtins::builtin_count; i++) { |
| 633 CodeEventsContainer evt_rec(CodeEventRecord::REPORT_BUILTIN); | 635 CodeEventsContainer evt_rec(CodeEventRecord::REPORT_BUILTIN); |
| 634 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; | 636 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; |
| 635 Builtins::Name id = static_cast<Builtins::Name>(i); | 637 Builtins::Name id = static_cast<Builtins::Name>(i); |
| 636 rec->start = builtins->builtin(id)->address(); | 638 rec->start = builtins->builtin(id)->address(); |
| 637 rec->builtin_id = id; | 639 rec->builtin_id = id; |
| 638 processor_->Enqueue(evt_rec); | 640 processor_->Enqueue(evt_rec); |
| 639 } | 641 } |
| 640 } | 642 } |
| 641 | 643 |
| 642 | 644 |
| 643 } // namespace internal | 645 } // namespace internal |
| 644 } // namespace v8 | 646 } // namespace v8 |
| OLD | NEW |