| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 bool Logger::IsProfilerPaused() { | 806 bool Logger::IsProfilerPaused() { |
| 807 return profiler_->paused(); | 807 return profiler_->paused(); |
| 808 } | 808 } |
| 809 | 809 |
| 810 | 810 |
| 811 void Logger::PauseProfiler() { | 811 void Logger::PauseProfiler() { |
| 812 profiler_->pause(); | 812 profiler_->pause(); |
| 813 if (FLAG_prof_lazy) { | 813 if (FLAG_prof_lazy) { |
| 814 if (!FLAG_sliding_state_window) ticker_->Stop(); | 814 if (!FLAG_sliding_state_window) ticker_->Stop(); |
| 815 FLAG_log_code = false; | 815 FLAG_log_code = false; |
| 816 // Must be the same message as Log::kDynamicBufferSeal. |
| 816 LOG(UncheckedStringEvent("profiler", "pause")); | 817 LOG(UncheckedStringEvent("profiler", "pause")); |
| 817 } | 818 } |
| 818 } | 819 } |
| 819 | 820 |
| 820 | 821 |
| 821 void Logger::ResumeProfiler() { | 822 void Logger::ResumeProfiler() { |
| 823 if (!Log::IsEnabled()) return; |
| 822 if (FLAG_prof_lazy) { | 824 if (FLAG_prof_lazy) { |
| 823 LOG(UncheckedStringEvent("profiler", "resume")); | 825 LOG(UncheckedStringEvent("profiler", "resume")); |
| 824 FLAG_log_code = true; | 826 FLAG_log_code = true; |
| 825 LogCompiledFunctions(); | 827 LogCompiledFunctions(); |
| 826 if (!FLAG_sliding_state_window) ticker_->Start(); | 828 if (!FLAG_sliding_state_window) ticker_->Start(); |
| 827 } | 829 } |
| 828 profiler_->resume(); | 830 profiler_->resume(); |
| 829 } | 831 } |
| 830 | 832 |
| 831 | 833 |
| 834 // This function can be called when Log's mutex is acquired, |
| 835 // either from main or Profiler's thread. |
| 836 void Logger::StopLoggingAndProfiling() { |
| 837 Log::stop(); |
| 838 PauseProfiler(); |
| 839 } |
| 840 |
| 841 |
| 832 bool Logger::IsProfilerSamplerActive() { | 842 bool Logger::IsProfilerSamplerActive() { |
| 833 return ticker_->IsActive(); | 843 return ticker_->IsActive(); |
| 834 } | 844 } |
| 835 | 845 |
| 836 | 846 |
| 837 int Logger::GetLogLines(int from_pos, char* dest_buf, int max_size) { | 847 int Logger::GetLogLines(int from_pos, char* dest_buf, int max_size) { |
| 838 return Log::GetLogLines(from_pos, dest_buf, max_size); | 848 return Log::GetLogLines(from_pos, dest_buf, max_size); |
| 839 } | 849 } |
| 840 | 850 |
| 841 | 851 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 sliding_state_window_ = new SlidingStateWindow(); | 998 sliding_state_window_ = new SlidingStateWindow(); |
| 989 } | 999 } |
| 990 | 1000 |
| 991 if (FLAG_prof) { | 1001 if (FLAG_prof) { |
| 992 profiler_ = new Profiler(); | 1002 profiler_ = new Profiler(); |
| 993 if (!FLAG_prof_auto) | 1003 if (!FLAG_prof_auto) |
| 994 profiler_->pause(); | 1004 profiler_->pause(); |
| 995 profiler_->Engage(); | 1005 profiler_->Engage(); |
| 996 } | 1006 } |
| 997 | 1007 |
| 1008 LogMessageBuilder::write_failure_handler = StopLoggingAndProfiling; |
| 1009 |
| 998 return true; | 1010 return true; |
| 999 | 1011 |
| 1000 #else | 1012 #else |
| 1001 return false; | 1013 return false; |
| 1002 #endif | 1014 #endif |
| 1003 } | 1015 } |
| 1004 | 1016 |
| 1005 | 1017 |
| 1006 void Logger::TearDown() { | 1018 void Logger::TearDown() { |
| 1007 #ifdef ENABLE_LOGGING_AND_PROFILING | 1019 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 1020 LogMessageBuilder::write_failure_handler = NULL; |
| 1021 |
| 1008 // Stop the profiler before closing the file. | 1022 // Stop the profiler before closing the file. |
| 1009 if (profiler_ != NULL) { | 1023 if (profiler_ != NULL) { |
| 1010 profiler_->Disengage(); | 1024 profiler_->Disengage(); |
| 1011 delete profiler_; | 1025 delete profiler_; |
| 1012 profiler_ = NULL; | 1026 profiler_ = NULL; |
| 1013 } | 1027 } |
| 1014 | 1028 |
| 1015 delete sliding_state_window_; | 1029 delete sliding_state_window_; |
| 1016 sliding_state_window_ = NULL; | 1030 sliding_state_window_ = NULL; |
| 1017 | 1031 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 } else if (previous_->state_ == EXTERNAL) { | 1131 } else if (previous_->state_ == EXTERNAL) { |
| 1118 // We are leaving V8. | 1132 // We are leaving V8. |
| 1119 Heap::Protect(); | 1133 Heap::Protect(); |
| 1120 } | 1134 } |
| 1121 } | 1135 } |
| 1122 #endif | 1136 #endif |
| 1123 } | 1137 } |
| 1124 #endif | 1138 #endif |
| 1125 | 1139 |
| 1126 } } // namespace v8::internal | 1140 } } // namespace v8::internal |
| OLD | NEW |