| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 | 438 |
| 439 | 439 |
| 440 void CpuProfiler::StartProcessorIfNotStarted() { | 440 void CpuProfiler::StartProcessorIfNotStarted() { |
| 441 if (processor_ == NULL) { | 441 if (processor_ == NULL) { |
| 442 // Disable logging when using the new implementation. | 442 // Disable logging when using the new implementation. |
| 443 saved_logging_nesting_ = isolate_->logger()->logging_nesting_; | 443 saved_logging_nesting_ = isolate_->logger()->logging_nesting_; |
| 444 isolate_->logger()->logging_nesting_ = 0; | 444 isolate_->logger()->logging_nesting_ = 0; |
| 445 generator_ = new ProfileGenerator(profiles_); | 445 generator_ = new ProfileGenerator(profiles_); |
| 446 processor_ = new ProfilerEventsProcessor(generator_); | 446 processor_ = new ProfilerEventsProcessor(generator_); |
| 447 is_profiling_ = true; | 447 is_profiling_ = true; |
| 448 processor_->Start(); | 448 processor_->StartSynchronously(); |
| 449 // Enumerate stuff we already have in the heap. | 449 // Enumerate stuff we already have in the heap. |
| 450 if (isolate_->heap()->HasBeenSetUp()) { | 450 if (isolate_->heap()->HasBeenSetUp()) { |
| 451 if (!FLAG_prof_browser_mode) { | 451 if (!FLAG_prof_browser_mode) { |
| 452 bool saved_log_code_flag = FLAG_log_code; | 452 bool saved_log_code_flag = FLAG_log_code; |
| 453 FLAG_log_code = true; | 453 FLAG_log_code = true; |
| 454 isolate_->logger()->LogCodeObjects(); | 454 isolate_->logger()->LogCodeObjects(); |
| 455 FLAG_log_code = saved_log_code_flag; | 455 FLAG_log_code = saved_log_code_flag; |
| 456 } | 456 } |
| 457 isolate_->logger()->LogCompiledFunctions(); | 457 isolate_->logger()->LogCompiledFunctions(); |
| 458 isolate_->logger()->LogAccessorCallbacks(); | 458 isolate_->logger()->LogAccessorCallbacks(); |
| 459 } | 459 } |
| 460 // Enable stack sampling. | 460 // Enable stack sampling. |
| 461 Sampler* sampler = reinterpret_cast<Sampler*>(isolate_->logger()->ticker_); | 461 Sampler* sampler = reinterpret_cast<Sampler*>(isolate_->logger()->ticker_); |
| 462 sampler->IncreaseProfilingDepth(); |
| 462 if (!sampler->IsActive()) { | 463 if (!sampler->IsActive()) { |
| 463 sampler->Start(); | 464 sampler->Start(); |
| 464 need_to_stop_sampler_ = true; | 465 need_to_stop_sampler_ = true; |
| 465 } | 466 } |
| 466 sampler->IncreaseProfilingDepth(); | |
| 467 } | 467 } |
| 468 } | 468 } |
| 469 | 469 |
| 470 | 470 |
| 471 CpuProfile* CpuProfiler::StopProfiling(const char* title) { | 471 CpuProfile* CpuProfiler::StopProfiling(const char* title) { |
| 472 if (!is_profiling_) return NULL; | 472 if (!is_profiling_) return NULL; |
| 473 const double actual_sampling_rate = generator_->actual_sampling_rate(); | 473 const double actual_sampling_rate = generator_->actual_sampling_rate(); |
| 474 StopProcessorIfLastProfile(title); | 474 StopProcessorIfLastProfile(title); |
| 475 CpuProfile* result = | 475 CpuProfile* result = |
| 476 profiles_->StopProfiling(TokenEnumerator::kNoSecurityToken, | 476 profiles_->StopProfiling(TokenEnumerator::kNoSecurityToken, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 processor_->Join(); | 511 processor_->Join(); |
| 512 delete processor_; | 512 delete processor_; |
| 513 delete generator_; | 513 delete generator_; |
| 514 processor_ = NULL; | 514 processor_ = NULL; |
| 515 generator_ = NULL; | 515 generator_ = NULL; |
| 516 logger->logging_nesting_ = saved_logging_nesting_; | 516 logger->logging_nesting_ = saved_logging_nesting_; |
| 517 } | 517 } |
| 518 | 518 |
| 519 | 519 |
| 520 } } // namespace v8::internal | 520 } } // namespace v8::internal |
| OLD | NEW |