| 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 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 } | 950 } |
| 951 if (FLAG_compress_log) { | 951 if (FLAG_compress_log) { |
| 952 ASSERT(compression_helper_ != NULL); | 952 ASSERT(compression_helper_ != NULL); |
| 953 if (!compression_helper_->HandleMessage(&msg)) return; | 953 if (!compression_helper_->HandleMessage(&msg)) return; |
| 954 } | 954 } |
| 955 msg.Append('\n'); | 955 msg.Append('\n'); |
| 956 msg.WriteToLogFile(); | 956 msg.WriteToLogFile(); |
| 957 } | 957 } |
| 958 | 958 |
| 959 | 959 |
| 960 bool Logger::IsProfilerPaused() { | 960 int Logger::GetActiveProfilerModules() { |
| 961 return profiler_->paused(); | 961 int result = PROFILER_MODULE_NONE; |
| 962 if (!profiler_->paused()) { |
| 963 result |= PROFILER_MODULE_CPU; |
| 964 } |
| 965 if (FLAG_log_gc) { |
| 966 result |= PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS; |
| 967 } |
| 968 return result; |
| 962 } | 969 } |
| 963 | 970 |
| 964 | 971 |
| 965 void Logger::PauseProfiler() { | 972 void Logger::PauseProfiler(int flags) { |
| 966 if (profiler_->paused()) { | 973 if (!Log::IsEnabled()) return; |
| 967 return; | 974 const int active_modules = GetActiveProfilerModules(); |
| 975 const int modules_to_disable = active_modules & flags; |
| 976 if (modules_to_disable == PROFILER_MODULE_NONE) return; |
| 977 |
| 978 if (modules_to_disable & PROFILER_MODULE_CPU) { |
| 979 profiler_->pause(); |
| 980 if (FLAG_prof_lazy) { |
| 981 if (!FLAG_sliding_state_window) ticker_->Stop(); |
| 982 FLAG_log_code = false; |
| 983 // Must be the same message as Log::kDynamicBufferSeal. |
| 984 LOG(UncheckedStringEvent("profiler", "pause")); |
| 985 } |
| 968 } | 986 } |
| 969 profiler_->pause(); | 987 if (modules_to_disable & |
| 970 if (FLAG_prof_lazy) { | 988 (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) { |
| 971 if (!FLAG_sliding_state_window) ticker_->Stop(); | 989 FLAG_log_gc = false; |
| 972 FLAG_log_code = false; | |
| 973 // Must be the same message as Log::kDynamicBufferSeal. | |
| 974 LOG(UncheckedStringEvent("profiler", "pause")); | |
| 975 } | 990 } |
| 976 is_logging_ = false; | 991 // Turn off logging if no active modules remain. |
| 992 if (active_modules & ~flags == PROFILER_MODULE_NONE) { |
| 993 is_logging_ = false; |
| 994 } |
| 977 } | 995 } |
| 978 | 996 |
| 979 | 997 |
| 980 void Logger::ResumeProfiler() { | 998 void Logger::ResumeProfiler(int flags) { |
| 981 if (!profiler_->paused() || !Log::IsEnabled()) { | 999 if (!Log::IsEnabled()) return; |
| 982 return; | 1000 const int modules_to_enable = ~GetActiveProfilerModules() & flags; |
| 1001 if (modules_to_enable != PROFILER_MODULE_NONE) { |
| 1002 is_logging_ = true; |
| 983 } | 1003 } |
| 984 is_logging_ = true; | 1004 if (modules_to_enable & PROFILER_MODULE_CPU) { |
| 985 if (FLAG_prof_lazy) { | 1005 if (FLAG_prof_lazy) { |
| 986 LOG(UncheckedStringEvent("profiler", "resume")); | 1006 LOG(UncheckedStringEvent("profiler", "resume")); |
| 987 FLAG_log_code = true; | 1007 FLAG_log_code = true; |
| 988 LogCompiledFunctions(); | 1008 LogCompiledFunctions(); |
| 989 if (!FLAG_sliding_state_window) ticker_->Start(); | 1009 if (!FLAG_sliding_state_window) ticker_->Start(); |
| 1010 } |
| 1011 profiler_->resume(); |
| 990 } | 1012 } |
| 991 profiler_->resume(); | 1013 if (modules_to_enable & |
| 1014 (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) { |
| 1015 FLAG_log_gc = true; |
| 1016 } |
| 992 } | 1017 } |
| 993 | 1018 |
| 994 | 1019 |
| 995 // This function can be called when Log's mutex is acquired, | 1020 // This function can be called when Log's mutex is acquired, |
| 996 // either from main or Profiler's thread. | 1021 // either from main or Profiler's thread. |
| 997 void Logger::StopLoggingAndProfiling() { | 1022 void Logger::StopLoggingAndProfiling() { |
| 998 Log::stop(); | 1023 Log::stop(); |
| 999 PauseProfiler(); | 1024 PauseProfiler(PROFILER_MODULE_CPU); |
| 1000 } | 1025 } |
| 1001 | 1026 |
| 1002 | 1027 |
| 1003 bool Logger::IsProfilerSamplerActive() { | 1028 bool Logger::IsProfilerSamplerActive() { |
| 1004 return ticker_->IsActive(); | 1029 return ticker_->IsActive(); |
| 1005 } | 1030 } |
| 1006 | 1031 |
| 1007 | 1032 |
| 1008 int Logger::GetLogLines(int from_pos, char* dest_buf, int max_size) { | 1033 int Logger::GetLogLines(int from_pos, char* dest_buf, int max_size) { |
| 1009 return Log::GetLogLines(from_pos, dest_buf, max_size); | 1034 return Log::GetLogLines(from_pos, dest_buf, max_size); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1225 // Otherwise, if the sliding state window computation has not been | 1250 // Otherwise, if the sliding state window computation has not been |
| 1226 // started we do it now. | 1251 // started we do it now. |
| 1227 if (sliding_state_window_ == NULL) { | 1252 if (sliding_state_window_ == NULL) { |
| 1228 sliding_state_window_ = new SlidingStateWindow(); | 1253 sliding_state_window_ = new SlidingStateWindow(); |
| 1229 } | 1254 } |
| 1230 #endif | 1255 #endif |
| 1231 } | 1256 } |
| 1232 | 1257 |
| 1233 | 1258 |
| 1234 } } // namespace v8::internal | 1259 } } // namespace v8::internal |
| OLD | NEW |