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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/profile-generator-inl.h" | 7 #include "src/profile-generator-inl.h" |
8 | 8 |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/debug.h" | 10 #include "src/debug.h" |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 | 462 |
463 bool CpuProfilesCollection::StartProfiling(const char* title, | 463 bool CpuProfilesCollection::StartProfiling(const char* title, |
464 bool record_samples) { | 464 bool record_samples) { |
465 current_profiles_semaphore_.Wait(); | 465 current_profiles_semaphore_.Wait(); |
466 if (current_profiles_.length() >= kMaxSimultaneousProfiles) { | 466 if (current_profiles_.length() >= kMaxSimultaneousProfiles) { |
467 current_profiles_semaphore_.Signal(); | 467 current_profiles_semaphore_.Signal(); |
468 return false; | 468 return false; |
469 } | 469 } |
470 for (int i = 0; i < current_profiles_.length(); ++i) { | 470 for (int i = 0; i < current_profiles_.length(); ++i) { |
471 if (strcmp(current_profiles_[i]->title(), title) == 0) { | 471 if (strcmp(current_profiles_[i]->title(), title) == 0) { |
472 // Ignore attempts to start profile with the same title. | 472 // Ignore attempts to start profile with the same title... |
473 current_profiles_semaphore_.Signal(); | 473 current_profiles_semaphore_.Signal(); |
474 return false; | 474 // ... though return true to force it collect a sample. |
| 475 return true; |
475 } | 476 } |
476 } | 477 } |
477 current_profiles_.Add(new CpuProfile(title, record_samples)); | 478 current_profiles_.Add(new CpuProfile(title, record_samples)); |
478 current_profiles_semaphore_.Signal(); | 479 current_profiles_semaphore_.Signal(); |
479 return true; | 480 return true; |
480 } | 481 } |
481 | 482 |
482 | 483 |
483 CpuProfile* CpuProfilesCollection::StopProfiling(const char* title) { | 484 CpuProfile* CpuProfilesCollection::StopProfiling(const char* title) { |
484 const int title_len = StrLength(title); | 485 const int title_len = StrLength(title); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 case OTHER: | 667 case OTHER: |
667 case EXTERNAL: | 668 case EXTERNAL: |
668 return program_entry_; | 669 return program_entry_; |
669 case IDLE: | 670 case IDLE: |
670 return idle_entry_; | 671 return idle_entry_; |
671 default: return NULL; | 672 default: return NULL; |
672 } | 673 } |
673 } | 674 } |
674 | 675 |
675 } } // namespace v8::internal | 676 } } // namespace v8::internal |
OLD | NEW |