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

Side by Side Diff: src/log.cc

Issue 844006: Merge changes up to V8 version 2.1.3 into the partial snapshots (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: Created 10 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/log.h ('k') | src/macros.py » ('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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // 322 //
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 int Logger::logging_nesting_ = 0;
333 int Logger::cpu_profiler_nesting_ = 0; 333 int Logger::cpu_profiler_nesting_ = 0;
334 int Logger::heap_profiler_nesting_ = 0; 334 int Logger::heap_profiler_nesting_ = 0;
335 335
336 #define DECLARE_LONG_EVENT(ignore1, long_name, ignore2) long_name, 336 #define DECLARE_LONG_EVENT(ignore1, long_name, ignore2) long_name,
337 const char* kLongLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = { 337 const char* kLongLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = {
338 LOG_EVENTS_AND_TAGS_LIST(DECLARE_LONG_EVENT) 338 LOG_EVENTS_AND_TAGS_LIST(DECLARE_LONG_EVENT)
339 }; 339 };
340 #undef DECLARE_LONG_EVENT 340 #undef DECLARE_LONG_EVENT
341 341
342 #define DECLARE_SHORT_EVENT(ignore1, ignore2, short_name) short_name, 342 #define DECLARE_SHORT_EVENT(ignore1, ignore2, short_name) short_name,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 if (!Log::IsEnabled()) return; 382 if (!Log::IsEnabled()) return;
383 LogMessageBuilder msg; 383 LogMessageBuilder msg;
384 msg.Append("%s,\"%s\"\n", name, value); 384 msg.Append("%s,\"%s\"\n", name, value);
385 msg.WriteToLogFile(); 385 msg.WriteToLogFile();
386 } 386 }
387 #endif 387 #endif
388 388
389 389
390 void Logger::IntEvent(const char* name, int value) { 390 void Logger::IntEvent(const char* name, int value) {
391 #ifdef ENABLE_LOGGING_AND_PROFILING 391 #ifdef ENABLE_LOGGING_AND_PROFILING
392 if (!Log::IsEnabled() || !FLAG_log) return; 392 if (FLAG_log) UncheckedIntEvent(name, value);
393 LogMessageBuilder msg;
394 msg.Append("%s,%d\n", name, value);
395 msg.WriteToLogFile();
396 #endif 393 #endif
397 } 394 }
398 395
399 396
397 #ifdef ENABLE_LOGGING_AND_PROFILING
398 void Logger::UncheckedIntEvent(const char* name, int value) {
399 if (!Log::IsEnabled()) return;
400 LogMessageBuilder msg;
401 msg.Append("%s,%d\n", name, value);
402 msg.WriteToLogFile();
403 }
404 #endif
405
406
400 void Logger::HandleEvent(const char* name, Object** location) { 407 void Logger::HandleEvent(const char* name, Object** location) {
401 #ifdef ENABLE_LOGGING_AND_PROFILING 408 #ifdef ENABLE_LOGGING_AND_PROFILING
402 if (!Log::IsEnabled() || !FLAG_log_handles) return; 409 if (!Log::IsEnabled() || !FLAG_log_handles) return;
403 LogMessageBuilder msg; 410 LogMessageBuilder msg;
404 msg.Append("%s,0x%" V8PRIxPTR "\n", name, location); 411 msg.Append("%s,0x%" V8PRIxPTR "\n", name, location);
405 msg.WriteToLogFile(); 412 msg.WriteToLogFile();
406 #endif 413 #endif
407 } 414 }
408 415
409 416
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 if (flags & PROFILER_MODULE_CPU) { 1169 if (flags & PROFILER_MODULE_CPU) {
1163 // It is OK to have negative nesting. 1170 // It is OK to have negative nesting.
1164 if (--cpu_profiler_nesting_ == 0) { 1171 if (--cpu_profiler_nesting_ == 0) {
1165 profiler_->pause(); 1172 profiler_->pause();
1166 if (FLAG_prof_lazy) { 1173 if (FLAG_prof_lazy) {
1167 if (!FLAG_sliding_state_window) ticker_->Stop(); 1174 if (!FLAG_sliding_state_window) ticker_->Stop();
1168 FLAG_log_code = false; 1175 FLAG_log_code = false;
1169 // Must be the same message as Log::kDynamicBufferSeal. 1176 // Must be the same message as Log::kDynamicBufferSeal.
1170 LOG(UncheckedStringEvent("profiler", "pause")); 1177 LOG(UncheckedStringEvent("profiler", "pause"));
1171 } 1178 }
1179 --logging_nesting_;
1172 } 1180 }
1173 } 1181 }
1174 if (flags & 1182 if (flags &
1175 (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) { 1183 (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) {
1176 if (--heap_profiler_nesting_ == 0) { 1184 if (--heap_profiler_nesting_ == 0) {
1177 FLAG_log_gc = false; 1185 FLAG_log_gc = false;
1186 --logging_nesting_;
1178 } 1187 }
1179 } 1188 }
1180 if (tag != 0) { 1189 if (tag != 0) {
1181 IntEvent("close-tag", tag); 1190 UncheckedIntEvent("close-tag", tag);
1182 }
1183 if (GetActiveProfilerModules() == PROFILER_MODULE_NONE) {
1184 is_logging_ = false;
1185 } 1191 }
1186 } 1192 }
1187 1193
1188 1194
1189 void Logger::ResumeProfiler(int flags, int tag) { 1195 void Logger::ResumeProfiler(int flags, int tag) {
1190 if (!Log::IsEnabled()) return; 1196 if (!Log::IsEnabled()) return;
1191 if (tag != 0) { 1197 if (tag != 0) {
1192 IntEvent("open-tag", tag); 1198 UncheckedIntEvent("open-tag", tag);
1193 } 1199 }
1194 if (flags & PROFILER_MODULE_CPU) { 1200 if (flags & PROFILER_MODULE_CPU) {
1195 if (cpu_profiler_nesting_++ == 0) { 1201 if (cpu_profiler_nesting_++ == 0) {
1196 is_logging_ = true; 1202 ++logging_nesting_;
1197 if (FLAG_prof_lazy) { 1203 if (FLAG_prof_lazy) {
1198 profiler_->Engage(); 1204 profiler_->Engage();
1199 LOG(UncheckedStringEvent("profiler", "resume")); 1205 LOG(UncheckedStringEvent("profiler", "resume"));
1200 FLAG_log_code = true; 1206 FLAG_log_code = true;
1201 LogCompiledFunctions(); 1207 LogCompiledFunctions();
1202 LogFunctionObjects(); 1208 LogFunctionObjects();
1203 LogAccessorCallbacks(); 1209 LogAccessorCallbacks();
1204 if (!FLAG_sliding_state_window) ticker_->Start(); 1210 if (!FLAG_sliding_state_window) ticker_->Start();
1205 } 1211 }
1206 profiler_->resume(); 1212 profiler_->resume();
1207 } 1213 }
1208 } 1214 }
1209 if (flags & 1215 if (flags &
1210 (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) { 1216 (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) {
1211 if (heap_profiler_nesting_++ == 0) { 1217 if (heap_profiler_nesting_++ == 0) {
1212 is_logging_ = true; 1218 ++logging_nesting_;
1213 FLAG_log_gc = true; 1219 FLAG_log_gc = true;
1214 } 1220 }
1215 } 1221 }
1216 } 1222 }
1217 1223
1218 1224
1219 // This function can be called when Log's mutex is acquired, 1225 // This function can be called when Log's mutex is acquired,
1220 // either from main or Profiler's thread. 1226 // either from main or Profiler's thread.
1221 void Logger::StopLoggingAndProfiling() { 1227 void Logger::StopLoggingAndProfiling() {
1222 Log::stop(); 1228 Log::stop();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 1260
1255 1261
1256 void Logger::LogCodeObject(Object* object) { 1262 void Logger::LogCodeObject(Object* object) {
1257 if (FLAG_log_code) { 1263 if (FLAG_log_code) {
1258 Code* code_object = Code::cast(object); 1264 Code* code_object = Code::cast(object);
1259 LogEventsAndTags tag = Logger::STUB_TAG; 1265 LogEventsAndTags tag = Logger::STUB_TAG;
1260 const char* description = "Unknown code from the snapshot"; 1266 const char* description = "Unknown code from the snapshot";
1261 switch (code_object->kind()) { 1267 switch (code_object->kind()) {
1262 case Code::FUNCTION: 1268 case Code::FUNCTION:
1263 return; // We log this later using LogCompiledFunctions. 1269 return; // We log this later using LogCompiledFunctions.
1270 case Code::BINARY_OP_IC:
1271 // fall through
1264 case Code::STUB: 1272 case Code::STUB:
1265 description = CodeStub::MajorName(code_object->major_key(), true); 1273 description = CodeStub::MajorName(code_object->major_key(), true);
1266 if (description == NULL) 1274 if (description == NULL)
1267 description = "A stub from the snapshot"; 1275 description = "A stub from the snapshot";
1268 tag = Logger::STUB_TAG; 1276 tag = Logger::STUB_TAG;
1269 break; 1277 break;
1270 case Code::BUILTIN: 1278 case Code::BUILTIN:
1271 description = "A builtin from the snapshot"; 1279 description = "A builtin from the snapshot";
1272 tag = Logger::BUILTIN_TAG; 1280 tag = Logger::BUILTIN_TAG;
1273 break; 1281 break;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 if (FLAG_sliding_state_window && sliding_state_window_ == NULL) { 1483 if (FLAG_sliding_state_window && sliding_state_window_ == NULL) {
1476 sliding_state_window_ = new SlidingStateWindow(); 1484 sliding_state_window_ = new SlidingStateWindow();
1477 } 1485 }
1478 1486
1479 log_events_ = FLAG_compress_log ? 1487 log_events_ = FLAG_compress_log ?
1480 kCompressedLogEventsNames : kLongLogEventsNames; 1488 kCompressedLogEventsNames : kLongLogEventsNames;
1481 if (FLAG_compress_log) { 1489 if (FLAG_compress_log) {
1482 compression_helper_ = new CompressionHelper(kCompressionWindowSize); 1490 compression_helper_ = new CompressionHelper(kCompressionWindowSize);
1483 } 1491 }
1484 1492
1485 is_logging_ = start_logging; 1493 if (start_logging) {
1494 logging_nesting_ = 1;
1495 }
1486 1496
1487 if (FLAG_prof) { 1497 if (FLAG_prof) {
1488 profiler_ = new Profiler(); 1498 profiler_ = new Profiler();
1489 if (!FLAG_prof_auto) { 1499 if (!FLAG_prof_auto) {
1490 profiler_->pause(); 1500 profiler_->pause();
1491 } else { 1501 } else {
1492 is_logging_ = true; 1502 logging_nesting_ = 1;
1493 } 1503 }
1494 if (!FLAG_prof_lazy) { 1504 if (!FLAG_prof_lazy) {
1495 profiler_->Engage(); 1505 profiler_->Engage();
1496 } 1506 }
1497 } 1507 }
1498 1508
1499 LogMessageBuilder::set_write_failure_handler(StopLoggingAndProfiling); 1509 LogMessageBuilder::set_write_failure_handler(StopLoggingAndProfiling);
1500 1510
1501 return true; 1511 return true;
1502 1512
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 // Otherwise, if the sliding state window computation has not been 1554 // Otherwise, if the sliding state window computation has not been
1545 // started we do it now. 1555 // started we do it now.
1546 if (sliding_state_window_ == NULL) { 1556 if (sliding_state_window_ == NULL) {
1547 sliding_state_window_ = new SlidingStateWindow(); 1557 sliding_state_window_ = new SlidingStateWindow();
1548 } 1558 }
1549 #endif 1559 #endif
1550 } 1560 }
1551 1561
1552 1562
1553 } } // namespace v8::internal 1563 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log.h ('k') | src/macros.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698