| 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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 } | 352 } |
| 353 | 353 |
| 354 | 354 |
| 355 CpuProfile::CpuProfile(const char* title, bool record_samples) | 355 CpuProfile::CpuProfile(const char* title, bool record_samples) |
| 356 : title_(title), | 356 : title_(title), |
| 357 record_samples_(record_samples), | 357 record_samples_(record_samples), |
| 358 start_time_(TimeTicks::HighResolutionNow()) { | 358 start_time_(TimeTicks::HighResolutionNow()) { |
| 359 } | 359 } |
| 360 | 360 |
| 361 | 361 |
| 362 void CpuProfile::AddPath(const Vector<CodeEntry*>& path) { | 362 void CpuProfile::AddPath(TimeTicks timestamp, const Vector<CodeEntry*>& path) { |
| 363 ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path); | 363 ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path); |
| 364 if (record_samples_) samples_.Add(top_frame_node); | 364 if (record_samples_) { |
| 365 timestamps_.Add(timestamp); |
| 366 samples_.Add(top_frame_node); |
| 367 } |
| 365 } | 368 } |
| 366 | 369 |
| 367 | 370 |
| 368 void CpuProfile::CalculateTotalTicksAndSamplingRate() { | 371 void CpuProfile::CalculateTotalTicksAndSamplingRate() { |
| 369 end_time_ = TimeTicks::HighResolutionNow(); | 372 end_time_ = TimeTicks::HighResolutionNow(); |
| 370 } | 373 } |
| 371 | 374 |
| 372 | 375 |
| 373 void CpuProfile::Print() { | 376 void CpuProfile::Print() { |
| 374 OS::Print("[Top down]:\n"); | 377 OS::Print("[Top down]:\n"); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 if (profile == finished_profiles_[i]) { | 541 if (profile == finished_profiles_[i]) { |
| 539 finished_profiles_.Remove(i); | 542 finished_profiles_.Remove(i); |
| 540 return; | 543 return; |
| 541 } | 544 } |
| 542 } | 545 } |
| 543 UNREACHABLE(); | 546 UNREACHABLE(); |
| 544 } | 547 } |
| 545 | 548 |
| 546 | 549 |
| 547 void CpuProfilesCollection::AddPathToCurrentProfiles( | 550 void CpuProfilesCollection::AddPathToCurrentProfiles( |
| 548 const Vector<CodeEntry*>& path) { | 551 TimeTicks timestamp, const Vector<CodeEntry*>& path) { |
| 549 // As starting / stopping profiles is rare relatively to this | 552 // As starting / stopping profiles is rare relatively to this |
| 550 // method, we don't bother minimizing the duration of lock holding, | 553 // method, we don't bother minimizing the duration of lock holding, |
| 551 // e.g. copying contents of the list to a local vector. | 554 // e.g. copying contents of the list to a local vector. |
| 552 current_profiles_semaphore_.Wait(); | 555 current_profiles_semaphore_.Wait(); |
| 553 for (int i = 0; i < current_profiles_.length(); ++i) { | 556 for (int i = 0; i < current_profiles_.length(); ++i) { |
| 554 current_profiles_[i]->AddPath(path); | 557 current_profiles_[i]->AddPath(timestamp, path); |
| 555 } | 558 } |
| 556 current_profiles_semaphore_.Signal(); | 559 current_profiles_semaphore_.Signal(); |
| 557 } | 560 } |
| 558 | 561 |
| 559 | 562 |
| 560 CodeEntry* CpuProfilesCollection::NewCodeEntry( | 563 CodeEntry* CpuProfilesCollection::NewCodeEntry( |
| 561 Logger::LogEventsAndTags tag, | 564 Logger::LogEventsAndTags tag, |
| 562 const char* name, | 565 const char* name, |
| 563 const char* name_prefix, | 566 const char* name_prefix, |
| 564 const char* resource_name, | 567 const char* resource_name, |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 no_symbolized_entries = false; | 670 no_symbolized_entries = false; |
| 668 break; | 671 break; |
| 669 } | 672 } |
| 670 } | 673 } |
| 671 // If no frames were symbolized, put the VM state entry in. | 674 // If no frames were symbolized, put the VM state entry in. |
| 672 if (no_symbolized_entries) { | 675 if (no_symbolized_entries) { |
| 673 *entry++ = EntryForVMState(sample.state); | 676 *entry++ = EntryForVMState(sample.state); |
| 674 } | 677 } |
| 675 } | 678 } |
| 676 | 679 |
| 677 profiles_->AddPathToCurrentProfiles(entries); | 680 profiles_->AddPathToCurrentProfiles(sample.timestamp, entries); |
| 678 } | 681 } |
| 679 | 682 |
| 680 | 683 |
| 681 CodeEntry* ProfileGenerator::EntryForVMState(StateTag tag) { | 684 CodeEntry* ProfileGenerator::EntryForVMState(StateTag tag) { |
| 682 switch (tag) { | 685 switch (tag) { |
| 683 case GC: | 686 case GC: |
| 684 return gc_entry_; | 687 return gc_entry_; |
| 685 case JS: | 688 case JS: |
| 686 case COMPILER: | 689 case COMPILER: |
| 687 // DOM events handlers are reported as OTHER / EXTERNAL entries. | 690 // DOM events handlers are reported as OTHER / EXTERNAL entries. |
| 688 // To avoid confusing people, let's put all these entries into | 691 // To avoid confusing people, let's put all these entries into |
| 689 // one bucket. | 692 // one bucket. |
| 690 case OTHER: | 693 case OTHER: |
| 691 case EXTERNAL: | 694 case EXTERNAL: |
| 692 return program_entry_; | 695 return program_entry_; |
| 693 case IDLE: | 696 case IDLE: |
| 694 return idle_entry_; | 697 return idle_entry_; |
| 695 default: return NULL; | 698 default: return NULL; |
| 696 } | 699 } |
| 697 } | 700 } |
| 698 | 701 |
| 699 } } // namespace v8::internal | 702 } } // namespace v8::internal |
| OLD | NEW |