| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 engaged_(false), | 649 engaged_(false), |
| 650 running_(false), | 650 running_(false), |
| 651 paused_(false) { | 651 paused_(false) { |
| 652 } | 652 } |
| 653 | 653 |
| 654 | 654 |
| 655 void Profiler::Engage() { | 655 void Profiler::Engage() { |
| 656 if (engaged_) return; | 656 if (engaged_) return; |
| 657 engaged_ = true; | 657 engaged_ = true; |
| 658 | 658 |
| 659 OS::LogSharedLibraryAddresses(); | 659 OS::LogSharedLibraryAddresses(isolate_); |
| 660 | 660 |
| 661 // Start thread processing the profiler buffer. | 661 // Start thread processing the profiler buffer. |
| 662 running_ = true; | 662 running_ = true; |
| 663 Start(); | 663 Start(); |
| 664 | 664 |
| 665 // Register to get ticks. | 665 // Register to get ticks. |
| 666 Logger* logger = isolate_->logger(); | 666 Logger* logger = isolate_->logger(); |
| 667 logger->ticker_->SetProfiler(this); | 667 logger->ticker_->SetProfiler(this); |
| 668 | 668 |
| 669 logger->ProfilerBeginEvent(); | 669 logger->ProfilerBeginEvent(); |
| 670 } | 670 } |
| 671 | 671 |
| 672 | 672 |
| 673 void Profiler::Disengage() { | 673 void Profiler::Disengage() { |
| 674 if (!engaged_) return; | 674 if (!engaged_) return; |
| 675 | 675 |
| 676 // Stop receiving ticks. | 676 // Stop receiving ticks. |
| 677 isolate_->logger()->ticker_->ClearProfiler(); | 677 isolate_->logger()->ticker_->ClearProfiler(); |
| 678 | 678 |
| 679 // Terminate the worker thread by setting running_ to false, | 679 // Terminate the worker thread by setting running_ to false, |
| 680 // inserting a fake element in the queue and then wait for | 680 // inserting a fake element in the queue and then wait for |
| 681 // the thread to terminate. | 681 // the thread to terminate. |
| 682 running_ = false; | 682 running_ = false; |
| 683 TickSample sample; | 683 TickSample sample; |
| 684 // Reset 'paused_' flag, otherwise semaphore may not be signalled. | 684 // Reset 'paused_' flag, otherwise semaphore may not be signalled. |
| 685 resume(); | 685 resume(); |
| 686 Insert(&sample); | 686 Insert(&sample); |
| 687 Join(); | 687 Join(); |
| 688 | 688 |
| 689 LOG(ISOLATE, UncheckedStringEvent("profiler", "end")); | 689 LOG(isolate_, UncheckedStringEvent("profiler", "end")); |
| 690 } | 690 } |
| 691 | 691 |
| 692 | 692 |
| 693 void Profiler::Run() { | 693 void Profiler::Run() { |
| 694 TickSample sample; | 694 TickSample sample; |
| 695 bool overflow = Remove(&sample); | 695 bool overflow = Remove(&sample); |
| 696 while (running_) { | 696 while (running_) { |
| 697 LOG(isolate_, TickEvent(&sample, overflow)); | 697 LOG(isolate_, TickEvent(&sample, overflow)); |
| 698 overflow = Remove(&sample); | 698 overflow = Remove(&sample); |
| 699 } | 699 } |
| (...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 if (jit_logger_) { | 1906 if (jit_logger_) { |
| 1907 removeCodeEventListener(jit_logger_); | 1907 removeCodeEventListener(jit_logger_); |
| 1908 delete jit_logger_; | 1908 delete jit_logger_; |
| 1909 jit_logger_ = NULL; | 1909 jit_logger_ = NULL; |
| 1910 } | 1910 } |
| 1911 | 1911 |
| 1912 return log_->Close(); | 1912 return log_->Close(); |
| 1913 } | 1913 } |
| 1914 | 1914 |
| 1915 } } // namespace v8::internal | 1915 } } // namespace v8::internal |
| OLD | NEW |