Chromium Code Reviews| 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 TickSample sample; | 300 TickSample sample; |
| 301 // Reset 'paused_' flag, otherwise semaphore may not be signalled. | 301 // Reset 'paused_' flag, otherwise semaphore may not be signalled. |
| 302 resume(); | 302 resume(); |
| 303 Insert(&sample); | 303 Insert(&sample); |
| 304 Join(); | 304 Join(); |
| 305 | 305 |
| 306 LOG(UncheckedStringEvent("profiler", "end")); | 306 LOG(UncheckedStringEvent("profiler", "end")); |
| 307 } | 307 } |
| 308 | 308 |
| 309 | 309 |
| 310 void Profiler::Run() { | 310 void Profiler::Run() { |
|
zarko
2010/06/24 23:13:21
Would it be helpful to ASSERT(Logger::profiler_ ==
| |
| 311 TickSample sample; | 311 TickSample sample; |
| 312 bool overflow = Logger::profiler_->Remove(&sample); | 312 bool overflow = Remove(&sample); |
| 313 while (running_) { | 313 while (running_) { |
| 314 LOG(TickEvent(&sample, overflow)); | 314 LOG(TickEvent(&sample, overflow)); |
| 315 overflow = Logger::profiler_->Remove(&sample); | 315 overflow = Remove(&sample); |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 | 318 |
| 319 | 319 |
| 320 // | 320 // |
| 321 // Logger class implementation. | 321 // Logger class implementation. |
| 322 // | 322 // |
| 323 Ticker* Logger::ticker_ = NULL; | 323 Ticker* Logger::ticker_ = NULL; |
| 324 Profiler* Logger::profiler_ = NULL; | 324 Profiler* Logger::profiler_ = NULL; |
| 325 SlidingStateWindow* Logger::sliding_state_window_ = NULL; | 325 SlidingStateWindow* Logger::sliding_state_window_ = NULL; |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1143 ASSERT(compression_helper_ != NULL); | 1143 ASSERT(compression_helper_ != NULL); |
| 1144 if (!compression_helper_->HandleMessage(&msg)) return; | 1144 if (!compression_helper_->HandleMessage(&msg)) return; |
| 1145 } | 1145 } |
| 1146 msg.Append('\n'); | 1146 msg.Append('\n'); |
| 1147 msg.WriteToLogFile(); | 1147 msg.WriteToLogFile(); |
| 1148 } | 1148 } |
| 1149 | 1149 |
| 1150 | 1150 |
| 1151 int Logger::GetActiveProfilerModules() { | 1151 int Logger::GetActiveProfilerModules() { |
| 1152 int result = PROFILER_MODULE_NONE; | 1152 int result = PROFILER_MODULE_NONE; |
| 1153 if (!profiler_->paused()) { | 1153 if (profiler_ != NULL && !profiler_->paused()) { |
| 1154 result |= PROFILER_MODULE_CPU; | 1154 result |= PROFILER_MODULE_CPU; |
| 1155 } | 1155 } |
| 1156 if (FLAG_log_gc) { | 1156 if (FLAG_log_gc) { |
| 1157 result |= PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS; | 1157 result |= PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS; |
| 1158 } | 1158 } |
| 1159 return result; | 1159 return result; |
| 1160 } | 1160 } |
| 1161 | 1161 |
| 1162 | 1162 |
| 1163 void Logger::PauseProfiler(int flags, int tag) { | 1163 void Logger::PauseProfiler(int flags, int tag) { |
| 1164 if (!Log::IsEnabled()) return; | 1164 if (!Log::IsEnabled()) return; |
| 1165 if (flags & PROFILER_MODULE_CPU) { | 1165 if (profiler_ != NULL && (flags & PROFILER_MODULE_CPU)) { |
| 1166 // It is OK to have negative nesting. | 1166 // It is OK to have negative nesting. |
| 1167 if (--cpu_profiler_nesting_ == 0) { | 1167 if (--cpu_profiler_nesting_ == 0) { |
| 1168 profiler_->pause(); | 1168 profiler_->pause(); |
| 1169 if (FLAG_prof_lazy) { | 1169 if (FLAG_prof_lazy) { |
| 1170 if (!FLAG_sliding_state_window) ticker_->Stop(); | 1170 if (!FLAG_sliding_state_window) ticker_->Stop(); |
| 1171 FLAG_log_code = false; | 1171 FLAG_log_code = false; |
| 1172 // Must be the same message as Log::kDynamicBufferSeal. | 1172 // Must be the same message as Log::kDynamicBufferSeal. |
| 1173 LOG(UncheckedStringEvent("profiler", "pause")); | 1173 LOG(UncheckedStringEvent("profiler", "pause")); |
| 1174 } | 1174 } |
| 1175 --logging_nesting_; | 1175 --logging_nesting_; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1186 UncheckedIntEvent("close-tag", tag); | 1186 UncheckedIntEvent("close-tag", tag); |
| 1187 } | 1187 } |
| 1188 } | 1188 } |
| 1189 | 1189 |
| 1190 | 1190 |
| 1191 void Logger::ResumeProfiler(int flags, int tag) { | 1191 void Logger::ResumeProfiler(int flags, int tag) { |
| 1192 if (!Log::IsEnabled()) return; | 1192 if (!Log::IsEnabled()) return; |
| 1193 if (tag != 0) { | 1193 if (tag != 0) { |
| 1194 UncheckedIntEvent("open-tag", tag); | 1194 UncheckedIntEvent("open-tag", tag); |
| 1195 } | 1195 } |
| 1196 if (flags & PROFILER_MODULE_CPU) { | 1196 if (profiler_ != NULL && (flags & PROFILER_MODULE_CPU)) { |
| 1197 if (cpu_profiler_nesting_++ == 0) { | 1197 if (cpu_profiler_nesting_++ == 0) { |
| 1198 ++logging_nesting_; | 1198 ++logging_nesting_; |
| 1199 if (FLAG_prof_lazy) { | 1199 if (FLAG_prof_lazy) { |
| 1200 profiler_->Engage(); | 1200 profiler_->Engage(); |
| 1201 LOG(UncheckedStringEvent("profiler", "resume")); | 1201 LOG(UncheckedStringEvent("profiler", "resume")); |
| 1202 FLAG_log_code = true; | 1202 FLAG_log_code = true; |
| 1203 LogCompiledFunctions(); | 1203 LogCompiledFunctions(); |
| 1204 LogFunctionObjects(); | 1204 LogFunctionObjects(); |
| 1205 LogAccessorCallbacks(); | 1205 LogAccessorCallbacks(); |
| 1206 if (!FLAG_sliding_state_window) ticker_->Start(); | 1206 if (!FLAG_sliding_state_window) ticker_->Start(); |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1552 } | 1552 } |
| 1553 // Otherwise, if the sliding state window computation has not been | 1553 // Otherwise, if the sliding state window computation has not been |
| 1554 // started we do it now. | 1554 // started we do it now. |
| 1555 if (sliding_state_window_ == NULL) { | 1555 if (sliding_state_window_ == NULL) { |
| 1556 sliding_state_window_ = new SlidingStateWindow(); | 1556 sliding_state_window_ = new SlidingStateWindow(); |
| 1557 } | 1557 } |
| 1558 #endif | 1558 #endif |
| 1559 } | 1559 } |
| 1560 | 1560 |
| 1561 } } // namespace v8::internal | 1561 } } // namespace v8::internal |
| OLD | NEW |