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

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: fixed crash in tests due to absent sampler Created 8 years, 1 month 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') | 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 // 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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 FLAG_log_code = saved_log_code_flag; 512 FLAG_log_code = saved_log_code_flag;
513 } 513 }
514 isolate->logger()->LogCompiledFunctions(); 514 isolate->logger()->LogCompiledFunctions();
515 isolate->logger()->LogAccessorCallbacks(); 515 isolate->logger()->LogAccessorCallbacks();
516 } 516 }
517 // Enable stack sampling. 517 // Enable stack sampling.
518 if (!sampler->IsActive()) { 518 if (!sampler->IsActive()) {
519 sampler->Start(); 519 sampler->Start();
520 need_to_stop_sampler_ = true; 520 need_to_stop_sampler_ = true;
521 } 521 }
522 sampler->SetHasProcessingThread(true);
522 sampler->IncreaseProfilingDepth(); 523 sampler->IncreaseProfilingDepth();
523 processor_->Start(); 524 processor_->Start();
524 } 525 }
525 } 526 }
526 527
527 528
528 CpuProfile* CpuProfiler::StopCollectingProfile(const char* title) { 529 CpuProfile* CpuProfiler::StopCollectingProfile(const char* title) {
529 const double actual_sampling_rate = generator_->actual_sampling_rate(); 530 const double actual_sampling_rate = generator_->actual_sampling_rate();
530 StopProcessorIfLastProfile(title); 531 StopProcessorIfLastProfile(title);
531 CpuProfile* result = 532 CpuProfile* result =
(...skipping 22 matching lines...) Expand all
554 } 555 }
555 556
556 557
557 void CpuProfiler::StopProcessor() { 558 void CpuProfiler::StopProcessor() {
558 NoBarrier_Store(&is_profiling_, false); 559 NoBarrier_Store(&is_profiling_, false);
559 processor_->Stop(); 560 processor_->Stop();
560 processor_->Join(); 561 processor_->Join();
561 Logger* logger = Isolate::Current()->logger(); 562 Logger* logger = Isolate::Current()->logger();
562 Sampler* sampler = logger->sampler(); 563 Sampler* sampler = logger->sampler();
563 sampler->DecreaseProfilingDepth(); 564 sampler->DecreaseProfilingDepth();
565 sampler->SetHasProcessingThread(false);
564 if (need_to_stop_sampler_) { 566 if (need_to_stop_sampler_) {
565 sampler->Stop(); 567 sampler->Stop();
566 need_to_stop_sampler_ = false; 568 need_to_stop_sampler_ = false;
567 } 569 }
568 delete processor_; 570 delete processor_;
569 delete generator_; 571 delete generator_;
570 processor_ = NULL; 572 processor_ = NULL;
571 generator_ = NULL; 573 generator_ = NULL;
572 logger->logging_nesting_ = saved_logging_nesting_; 574 logger->logging_nesting_ = saved_logging_nesting_;
573 } 575 }
574 576
575 577
576 void CpuProfiler::SetUp() { 578 void CpuProfiler::SetUp() {
577 Isolate* isolate = Isolate::Current(); 579 Isolate* isolate = Isolate::Current();
578 if (isolate->cpu_profiler() == NULL) { 580 if (isolate->cpu_profiler() == NULL) {
579 isolate->set_cpu_profiler(new CpuProfiler()); 581 isolate->set_cpu_profiler(new CpuProfiler());
580 } 582 }
581 } 583 }
582 584
583 585
584 void CpuProfiler::TearDown() { 586 void CpuProfiler::TearDown() {
585 Isolate* isolate = Isolate::Current(); 587 Isolate* isolate = Isolate::Current();
586 if (isolate->cpu_profiler() != NULL) { 588 if (isolate->cpu_profiler() != NULL) {
587 delete isolate->cpu_profiler(); 589 delete isolate->cpu_profiler();
588 } 590 }
589 isolate->set_cpu_profiler(NULL); 591 isolate->set_cpu_profiler(NULL);
590 } 592 }
591 593
592 } } // namespace v8::internal 594 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698