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

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

Issue 11231002: Perform CPU sampling by CPU sampling thread only iff processing thread is not running. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 8 years, 2 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 | « no previous file | src/platform.h » ('j') | src/platform.h » ('J')
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 // 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 243 }
244 } 244 }
245 } 245 }
246 246
247 247
248 void ProfilerEventsProcessor::Run() { 248 void ProfilerEventsProcessor::Run() {
249 unsigned dequeue_order = 0; 249 unsigned dequeue_order = 0;
250 250
251 while (running_) { 251 while (running_) {
252 int64_t stop_time = OS::Ticks() + period_in_useconds_; 252 int64_t stop_time = OS::Ticks() + period_in_useconds_;
253 if (sampler_ != NULL) { 253 sampler_->DoSample();
254 sampler_->DoSample();
255 }
256 ProcessEventsQueue(stop_time, &dequeue_order); 254 ProcessEventsQueue(stop_time, &dequeue_order);
257 } 255 }
258 256
259 while (ProcessTicks(dequeue_order) && ProcessCodeEvent(&dequeue_order)) { } 257 while (ProcessTicks(dequeue_order) && ProcessCodeEvent(&dequeue_order)) { }
260 } 258 }
261 259
262 260
263 void CpuProfiler::StartProfiling(const char* title) { 261 void CpuProfiler::StartProfiling(const char* title) {
264 ASSERT(Isolate::Current()->cpu_profiler() != NULL); 262 ASSERT(Isolate::Current()->cpu_profiler() != NULL);
265 Isolate::Current()->cpu_profiler()->StartCollectingProfile(title); 263 Isolate::Current()->cpu_profiler()->StartCollectingProfile(title);
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 FLAG_log_code = saved_log_code_flag; 510 FLAG_log_code = saved_log_code_flag;
513 } 511 }
514 isolate->logger()->LogCompiledFunctions(); 512 isolate->logger()->LogCompiledFunctions();
515 isolate->logger()->LogAccessorCallbacks(); 513 isolate->logger()->LogAccessorCallbacks();
516 } 514 }
517 // Enable stack sampling. 515 // Enable stack sampling.
518 if (!sampler->IsActive()) { 516 if (!sampler->IsActive()) {
519 sampler->Start(); 517 sampler->Start();
520 need_to_stop_sampler_ = true; 518 need_to_stop_sampler_ = true;
521 } 519 }
520 sampler->SetHasProcessingThread(true);
522 sampler->IncreaseProfilingDepth(); 521 sampler->IncreaseProfilingDepth();
523 processor_->Start(); 522 processor_->Start();
524 } 523 }
525 } 524 }
526 525
527 526
528 CpuProfile* CpuProfiler::StopCollectingProfile(const char* title) { 527 CpuProfile* CpuProfiler::StopCollectingProfile(const char* title) {
529 const double actual_sampling_rate = generator_->actual_sampling_rate(); 528 const double actual_sampling_rate = generator_->actual_sampling_rate();
530 StopProcessorIfLastProfile(title); 529 StopProcessorIfLastProfile(title);
531 CpuProfile* result = 530 CpuProfile* result =
(...skipping 22 matching lines...) Expand all
554 } 553 }
555 554
556 555
557 void CpuProfiler::StopProcessor() { 556 void CpuProfiler::StopProcessor() {
558 NoBarrier_Store(&is_profiling_, false); 557 NoBarrier_Store(&is_profiling_, false);
559 processor_->Stop(); 558 processor_->Stop();
560 processor_->Join(); 559 processor_->Join();
561 Logger* logger = Isolate::Current()->logger(); 560 Logger* logger = Isolate::Current()->logger();
562 Sampler* sampler = logger->sampler(); 561 Sampler* sampler = logger->sampler();
563 sampler->DecreaseProfilingDepth(); 562 sampler->DecreaseProfilingDepth();
563 sampler->SetHasProcessingThread(false);
564 if (need_to_stop_sampler_) { 564 if (need_to_stop_sampler_) {
565 sampler->Stop(); 565 sampler->Stop();
566 need_to_stop_sampler_ = false; 566 need_to_stop_sampler_ = false;
567 } 567 }
568 delete processor_; 568 delete processor_;
569 delete generator_; 569 delete generator_;
570 processor_ = NULL; 570 processor_ = NULL;
571 generator_ = NULL; 571 generator_ = NULL;
572 logger->logging_nesting_ = saved_logging_nesting_; 572 logger->logging_nesting_ = saved_logging_nesting_;
573 } 573 }
574 574
575 575
576 void CpuProfiler::SetUp() { 576 void CpuProfiler::SetUp() {
577 Isolate* isolate = Isolate::Current(); 577 Isolate* isolate = Isolate::Current();
578 if (isolate->cpu_profiler() == NULL) { 578 if (isolate->cpu_profiler() == NULL) {
579 isolate->set_cpu_profiler(new CpuProfiler()); 579 isolate->set_cpu_profiler(new CpuProfiler());
580 } 580 }
581 } 581 }
582 582
583 583
584 void CpuProfiler::TearDown() { 584 void CpuProfiler::TearDown() {
585 Isolate* isolate = Isolate::Current(); 585 Isolate* isolate = Isolate::Current();
586 if (isolate->cpu_profiler() != NULL) { 586 if (isolate->cpu_profiler() != NULL) {
587 delete isolate->cpu_profiler(); 587 delete isolate->cpu_profiler();
588 } 588 }
589 isolate->set_cpu_profiler(NULL); 589 isolate->set_cpu_profiler(NULL);
590 } 590 }
591 591
592 } } // namespace v8::internal 592 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/platform.h » ('j') | src/platform.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698