Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: src/log.cc

Issue 619004: Implement tagging of profiler log event blocks. (Closed)
Patch Set: Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/log.h ('k') | src/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 // Logger class implementation. 323 // Logger class implementation.
324 // 324 //
325 Ticker* Logger::ticker_ = NULL; 325 Ticker* Logger::ticker_ = NULL;
326 Profiler* Logger::profiler_ = NULL; 326 Profiler* Logger::profiler_ = NULL;
327 VMState* Logger::current_state_ = NULL; 327 VMState* Logger::current_state_ = NULL;
328 VMState Logger::bottom_state_(EXTERNAL); 328 VMState Logger::bottom_state_(EXTERNAL);
329 SlidingStateWindow* Logger::sliding_state_window_ = NULL; 329 SlidingStateWindow* Logger::sliding_state_window_ = NULL;
330 const char** Logger::log_events_ = NULL; 330 const char** Logger::log_events_ = NULL;
331 CompressionHelper* Logger::compression_helper_ = NULL; 331 CompressionHelper* Logger::compression_helper_ = NULL;
332 bool Logger::is_logging_ = false; 332 bool Logger::is_logging_ = false;
333 int Logger::cpu_profiler_nesting_ = 0;
334 int Logger::heap_profiler_nesting_ = 0;
333 335
334 #define DECLARE_LONG_EVENT(ignore1, long_name, ignore2) long_name, 336 #define DECLARE_LONG_EVENT(ignore1, long_name, ignore2) long_name,
335 const char* kLongLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = { 337 const char* kLongLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = {
336 LOG_EVENTS_AND_TAGS_LIST(DECLARE_LONG_EVENT) 338 LOG_EVENTS_AND_TAGS_LIST(DECLARE_LONG_EVENT)
337 }; 339 };
338 #undef DECLARE_LONG_EVENT 340 #undef DECLARE_LONG_EVENT
339 341
340 #define DECLARE_SHORT_EVENT(ignore1, ignore2, short_name) short_name, 342 #define DECLARE_SHORT_EVENT(ignore1, ignore2, short_name) short_name,
341 const char* kCompressedLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = { 343 const char* kCompressedLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = {
342 LOG_EVENTS_AND_TAGS_LIST(DECLARE_SHORT_EVENT) 344 LOG_EVENTS_AND_TAGS_LIST(DECLARE_SHORT_EVENT)
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 if (!profiler_->paused()) { 1159 if (!profiler_->paused()) {
1158 result |= PROFILER_MODULE_CPU; 1160 result |= PROFILER_MODULE_CPU;
1159 } 1161 }
1160 if (FLAG_log_gc) { 1162 if (FLAG_log_gc) {
1161 result |= PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS; 1163 result |= PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS;
1162 } 1164 }
1163 return result; 1165 return result;
1164 } 1166 }
1165 1167
1166 1168
1167 void Logger::PauseProfiler(int flags) { 1169 void Logger::PauseProfiler(int flags, int tag) {
1168 if (!Log::IsEnabled()) return; 1170 if (!Log::IsEnabled()) return;
1169 const int active_modules = GetActiveProfilerModules(); 1171 if (flags & PROFILER_MODULE_CPU) {
1170 const int modules_to_disable = active_modules & flags; 1172 if (--cpu_profiler_nesting_ == 0) {
Søren Thygesen Gjesse 2010/02/17 13:18:26 Maybe make a note that these counters can be both
mnaganov (inactive) 2010/02/17 13:22:50 Done.
1171 if (modules_to_disable == PROFILER_MODULE_NONE) return; 1173 profiler_->pause();
1172 1174 if (FLAG_prof_lazy) {
1173 if (modules_to_disable & PROFILER_MODULE_CPU) { 1175 if (!FLAG_sliding_state_window) ticker_->Stop();
1174 profiler_->pause(); 1176 FLAG_log_code = false;
1175 if (FLAG_prof_lazy) { 1177 // Must be the same message as Log::kDynamicBufferSeal.
1176 if (!FLAG_sliding_state_window) ticker_->Stop(); 1178 LOG(UncheckedStringEvent("profiler", "pause"));
1177 FLAG_log_code = false; 1179 }
1178 // Must be the same message as Log::kDynamicBufferSeal.
1179 LOG(UncheckedStringEvent("profiler", "pause"));
1180 } 1180 }
1181 } 1181 }
1182 if (modules_to_disable & 1182 if (flags &
1183 (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) { 1183 (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) {
1184 FLAG_log_gc = false; 1184 if (--heap_profiler_nesting_ == 0) {
1185 FLAG_log_gc = false;
1186 }
1185 } 1187 }
1186 // Turn off logging if no active modules remain. 1188 if (tag != 0) {
1187 if ((active_modules & ~flags) == PROFILER_MODULE_NONE) { 1189 IntEvent("close-tag", tag);
1190 }
1191 if (GetActiveProfilerModules() == PROFILER_MODULE_NONE) {
1188 is_logging_ = false; 1192 is_logging_ = false;
1189 } 1193 }
1190 } 1194 }
1191 1195
1192 1196
1193 void Logger::ResumeProfiler(int flags) { 1197 void Logger::ResumeProfiler(int flags, int tag) {
1194 if (!Log::IsEnabled()) return; 1198 if (!Log::IsEnabled()) return;
1195 const int modules_to_enable = ~GetActiveProfilerModules() & flags; 1199 if (tag != 0) {
1196 if (modules_to_enable != PROFILER_MODULE_NONE) { 1200 IntEvent("open-tag", tag);
1197 is_logging_ = true;
1198 } 1201 }
1199 if (modules_to_enable & PROFILER_MODULE_CPU) { 1202 if (flags & PROFILER_MODULE_CPU) {
1200 if (FLAG_prof_lazy) { 1203 if (cpu_profiler_nesting_++ == 0) {
1201 profiler_->Engage(); 1204 is_logging_ = true;
1202 LOG(UncheckedStringEvent("profiler", "resume")); 1205 if (FLAG_prof_lazy) {
1203 FLAG_log_code = true; 1206 profiler_->Engage();
1204 LogCompiledFunctions(); 1207 LOG(UncheckedStringEvent("profiler", "resume"));
1205 LogFunctionObjects(); 1208 FLAG_log_code = true;
1206 LogAccessorCallbacks(); 1209 LogCompiledFunctions();
1207 if (!FLAG_sliding_state_window) ticker_->Start(); 1210 LogFunctionObjects();
1211 LogAccessorCallbacks();
1212 if (!FLAG_sliding_state_window) ticker_->Start();
1213 }
1214 profiler_->resume();
1208 } 1215 }
1209 profiler_->resume();
1210 } 1216 }
1211 if (modules_to_enable & 1217 if (flags &
1212 (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) { 1218 (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) {
1213 FLAG_log_gc = true; 1219 if (heap_profiler_nesting_++ == 0) {
1220 is_logging_ = true;
1221 FLAG_log_gc = true;
1222 }
1214 } 1223 }
1215 } 1224 }
1216 1225
1217 1226
1218 // This function can be called when Log's mutex is acquired, 1227 // This function can be called when Log's mutex is acquired,
1219 // either from main or Profiler's thread. 1228 // either from main or Profiler's thread.
1220 void Logger::StopLoggingAndProfiling() { 1229 void Logger::StopLoggingAndProfiling() {
1221 Log::stop(); 1230 Log::stop();
1222 PauseProfiler(PROFILER_MODULE_CPU); 1231 PauseProfiler(PROFILER_MODULE_CPU, 0);
1223 } 1232 }
1224 1233
1225 1234
1226 bool Logger::IsProfilerSamplerActive() { 1235 bool Logger::IsProfilerSamplerActive() {
1227 return ticker_->IsActive(); 1236 return ticker_->IsActive();
1228 } 1237 }
1229 1238
1230 1239
1231 int Logger::GetLogLines(int from_pos, char* dest_buf, int max_size) { 1240 int Logger::GetLogLines(int from_pos, char* dest_buf, int max_size) {
1232 return Log::GetLogLines(from_pos, dest_buf, max_size); 1241 return Log::GetLogLines(from_pos, dest_buf, max_size);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 // Otherwise, if the sliding state window computation has not been 1552 // Otherwise, if the sliding state window computation has not been
1544 // started we do it now. 1553 // started we do it now.
1545 if (sliding_state_window_ == NULL) { 1554 if (sliding_state_window_ == NULL) {
1546 sliding_state_window_ = new SlidingStateWindow(); 1555 sliding_state_window_ = new SlidingStateWindow();
1547 } 1556 }
1548 #endif 1557 #endif
1549 } 1558 }
1550 1559
1551 1560
1552 } } // namespace v8::internal 1561 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log.h ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698