| 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 "v8.h" | 5 #include "v8.h" |
| 6 | 6 |
| 7 #include "cpu-profiler-inl.h" | 7 #include "cpu-profiler-inl.h" |
| 8 | 8 |
| 9 #include "compiler.h" | 9 #include "compiler.h" |
| 10 #include "frames-inl.h" | 10 #include "frames-inl.h" |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 } | 411 } |
| 412 } | 412 } |
| 413 | 413 |
| 414 | 414 |
| 415 void CpuProfiler::StartProfiling(String* title, bool record_samples) { | 415 void CpuProfiler::StartProfiling(String* title, bool record_samples) { |
| 416 StartProfiling(profiles_->GetName(title), record_samples); | 416 StartProfiling(profiles_->GetName(title), record_samples); |
| 417 } | 417 } |
| 418 | 418 |
| 419 | 419 |
| 420 void CpuProfiler::StartProcessorIfNotStarted() { | 420 void CpuProfiler::StartProcessorIfNotStarted() { |
| 421 if (processor_ == NULL) { | 421 if (processor_ != NULL) { |
| 422 Logger* logger = isolate_->logger(); | |
| 423 // Disable logging when using the new implementation. | |
| 424 saved_is_logging_ = logger->is_logging_; | |
| 425 logger->is_logging_ = false; | |
| 426 generator_ = new ProfileGenerator(profiles_); | |
| 427 Sampler* sampler = logger->sampler(); | |
| 428 processor_ = new ProfilerEventsProcessor( | |
| 429 generator_, sampler, sampling_interval_); | |
| 430 is_profiling_ = true; | |
| 431 // Enumerate stuff we already have in the heap. | |
| 432 ASSERT(isolate_->heap()->HasBeenSetUp()); | |
| 433 if (!FLAG_prof_browser_mode) { | |
| 434 logger->LogCodeObjects(); | |
| 435 } | |
| 436 logger->LogCompiledFunctions(); | |
| 437 logger->LogAccessorCallbacks(); | |
| 438 LogBuiltins(); | |
| 439 // Enable stack sampling. | |
| 440 sampler->SetHasProcessingThread(true); | |
| 441 sampler->IncreaseProfilingDepth(); | |
| 442 processor_->AddCurrentStack(isolate_); | 422 processor_->AddCurrentStack(isolate_); |
| 443 processor_->StartSynchronously(); | 423 return; |
| 444 } | 424 } |
| 425 Logger* logger = isolate_->logger(); |
| 426 // Disable logging when using the new implementation. |
| 427 saved_is_logging_ = logger->is_logging_; |
| 428 logger->is_logging_ = false; |
| 429 generator_ = new ProfileGenerator(profiles_); |
| 430 Sampler* sampler = logger->sampler(); |
| 431 processor_ = new ProfilerEventsProcessor( |
| 432 generator_, sampler, sampling_interval_); |
| 433 is_profiling_ = true; |
| 434 // Enumerate stuff we already have in the heap. |
| 435 ASSERT(isolate_->heap()->HasBeenSetUp()); |
| 436 if (!FLAG_prof_browser_mode) { |
| 437 logger->LogCodeObjects(); |
| 438 } |
| 439 logger->LogCompiledFunctions(); |
| 440 logger->LogAccessorCallbacks(); |
| 441 LogBuiltins(); |
| 442 // Enable stack sampling. |
| 443 sampler->SetHasProcessingThread(true); |
| 444 sampler->IncreaseProfilingDepth(); |
| 445 processor_->AddCurrentStack(isolate_); |
| 446 processor_->StartSynchronously(); |
| 445 } | 447 } |
| 446 | 448 |
| 447 | 449 |
| 448 CpuProfile* CpuProfiler::StopProfiling(const char* title) { | 450 CpuProfile* CpuProfiler::StopProfiling(const char* title) { |
| 449 if (!is_profiling_) return NULL; | 451 if (!is_profiling_) return NULL; |
| 450 StopProcessorIfLastProfile(title); | 452 StopProcessorIfLastProfile(title); |
| 451 CpuProfile* result = profiles_->StopProfiling(title); | 453 CpuProfile* result = profiles_->StopProfiling(title); |
| 452 if (result != NULL) { | 454 if (result != NULL) { |
| 453 result->Print(); | 455 result->Print(); |
| 454 } | 456 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; | 494 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; |
| 493 Builtins::Name id = static_cast<Builtins::Name>(i); | 495 Builtins::Name id = static_cast<Builtins::Name>(i); |
| 494 rec->start = builtins->builtin(id)->address(); | 496 rec->start = builtins->builtin(id)->address(); |
| 495 rec->builtin_id = id; | 497 rec->builtin_id = id; |
| 496 processor_->Enqueue(evt_rec); | 498 processor_->Enqueue(evt_rec); |
| 497 } | 499 } |
| 498 } | 500 } |
| 499 | 501 |
| 500 | 502 |
| 501 } } // namespace v8::internal | 503 } } // namespace v8::internal |
| OLD | NEW |