OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 void Sampler::TearDown() { | 651 void Sampler::TearDown() { |
652 SamplerThread::TearDown(); | 652 SamplerThread::TearDown(); |
653 } | 653 } |
654 | 654 |
655 | 655 |
656 Sampler::Sampler(Isolate* isolate, int interval) | 656 Sampler::Sampler(Isolate* isolate, int interval) |
657 : isolate_(isolate), | 657 : isolate_(isolate), |
658 interval_(interval), | 658 interval_(interval), |
659 profiling_(false), | 659 profiling_(false), |
660 active_(false), | 660 active_(false), |
661 samples_taken_(0) { | 661 is_counting_samples_(false), |
| 662 js_and_external_sample_count_(0) { |
662 data_ = new PlatformData; | 663 data_ = new PlatformData; |
663 } | 664 } |
664 | 665 |
665 | 666 |
666 Sampler::~Sampler() { | 667 Sampler::~Sampler() { |
667 ASSERT(!IsActive()); | 668 ASSERT(!IsActive()); |
668 delete data_; | 669 delete data_; |
669 } | 670 } |
670 | 671 |
671 | 672 |
672 void Sampler::Start() { | 673 void Sampler::Start() { |
673 ASSERT(!IsActive()); | 674 ASSERT(!IsActive()); |
674 SetActive(true); | 675 SetActive(true); |
675 SamplerThread::AddActiveSampler(this); | 676 SamplerThread::AddActiveSampler(this); |
676 } | 677 } |
677 | 678 |
678 | 679 |
679 void Sampler::Stop() { | 680 void Sampler::Stop() { |
680 ASSERT(IsActive()); | 681 ASSERT(IsActive()); |
681 SamplerThread::RemoveActiveSampler(this); | 682 SamplerThread::RemoveActiveSampler(this); |
682 SetActive(false); | 683 SetActive(false); |
683 } | 684 } |
684 | 685 |
685 | 686 |
686 void Sampler::SampleStack(const RegisterState& state) { | 687 void Sampler::SampleStack(const RegisterState& state) { |
687 TickSample* sample = isolate_->cpu_profiler()->TickSampleEvent(); | 688 TickSample* sample = isolate_->cpu_profiler()->TickSampleEvent(); |
688 TickSample sample_obj; | 689 TickSample sample_obj; |
689 if (sample == NULL) sample = &sample_obj; | 690 if (sample == NULL) sample = &sample_obj; |
690 sample->Init(isolate_, state); | 691 sample->Init(isolate_, state); |
691 if (++samples_taken_ < 0) samples_taken_ = 0; | 692 if (is_counting_samples_) { |
| 693 if (sample->state == JS || sample->state == EXTERNAL) { |
| 694 ++js_and_external_sample_count_; |
| 695 } |
| 696 } |
692 Tick(sample); | 697 Tick(sample); |
693 } | 698 } |
694 | 699 |
695 } } // namespace v8::internal | 700 } } // namespace v8::internal |
OLD | NEW |