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

Side by Side Diff: src/log.cc

Issue 434074: Include getters and setters callbacks invocations in CPU profiler log. (Closed)
Patch Set: Comments addressed Created 11 years 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/stub-cache.cc » ('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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 673
674 private: 674 private:
675 LogRecordCompressor compressor_; 675 LogRecordCompressor compressor_;
676 int repeat_count_; 676 int repeat_count_;
677 EmbeddedVector<char, 20> prefix_; 677 EmbeddedVector<char, 20> prefix_;
678 }; 678 };
679 679
680 #endif // ENABLE_LOGGING_AND_PROFILING 680 #endif // ENABLE_LOGGING_AND_PROFILING
681 681
682 682
683 void Logger::CallbackEvent(String* name, Address entry_point) {
684 #ifdef ENABLE_LOGGING_AND_PROFILING 683 #ifdef ENABLE_LOGGING_AND_PROFILING
684 void Logger::CallbackEventInternal(const char* prefix, const char* name,
685 Address entry_point) {
685 if (!Log::IsEnabled() || !FLAG_log_code) return; 686 if (!Log::IsEnabled() || !FLAG_log_code) return;
686 LogMessageBuilder msg; 687 LogMessageBuilder msg;
687 msg.Append("%s,%s,", 688 msg.Append("%s,%s,",
688 log_events_[CODE_CREATION_EVENT], log_events_[CALLBACK_TAG]); 689 log_events_[CODE_CREATION_EVENT], log_events_[CALLBACK_TAG]);
689 msg.AppendAddress(entry_point); 690 msg.AppendAddress(entry_point);
690 SmartPointer<char> str = 691 msg.Append(",1,\"%s%s\"", prefix, name);
691 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
692 msg.Append(",1,\"%s\"", *str);
693 if (FLAG_compress_log) { 692 if (FLAG_compress_log) {
694 ASSERT(compression_helper_ != NULL); 693 ASSERT(compression_helper_ != NULL);
695 if (!compression_helper_->HandleMessage(&msg)) return; 694 if (!compression_helper_->HandleMessage(&msg)) return;
696 } 695 }
697 msg.Append('\n'); 696 msg.Append('\n');
698 msg.WriteToLogFile(); 697 msg.WriteToLogFile();
698 }
699 #endif
700
701
702 void Logger::CallbackEvent(String* name, Address entry_point) {
703 #ifdef ENABLE_LOGGING_AND_PROFILING
704 if (!Log::IsEnabled() || !FLAG_log_code) return;
705 SmartPointer<char> str =
706 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
707 CallbackEventInternal("", *str, entry_point);
699 #endif 708 #endif
700 } 709 }
701 710
711
712 void Logger::GetterCallbackEvent(String* name, Address entry_point) {
713 #ifdef ENABLE_LOGGING_AND_PROFILING
714 if (!Log::IsEnabled() || !FLAG_log_code) return;
715 SmartPointer<char> str =
716 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
717 CallbackEventInternal("get ", *str, entry_point);
718 #endif
719 }
720
721
722 void Logger::SetterCallbackEvent(String* name, Address entry_point) {
723 #ifdef ENABLE_LOGGING_AND_PROFILING
724 if (!Log::IsEnabled() || !FLAG_log_code) return;
725 SmartPointer<char> str =
726 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
727 CallbackEventInternal("set ", *str, entry_point);
728 #endif
729 }
730
702 731
703 void Logger::CodeCreateEvent(LogEventsAndTags tag, 732 void Logger::CodeCreateEvent(LogEventsAndTags tag,
704 Code* code, 733 Code* code,
705 const char* comment) { 734 const char* comment) {
706 #ifdef ENABLE_LOGGING_AND_PROFILING 735 #ifdef ENABLE_LOGGING_AND_PROFILING
707 if (!Log::IsEnabled() || !FLAG_log_code) return; 736 if (!Log::IsEnabled() || !FLAG_log_code) return;
708 LogMessageBuilder msg; 737 LogMessageBuilder msg;
709 msg.Append("%s,%s,", log_events_[CODE_CREATION_EVENT], log_events_[tag]); 738 msg.Append("%s,%s,", log_events_[CODE_CREATION_EVENT], log_events_[tag]);
710 msg.AppendAddress(code->address()); 739 msg.AppendAddress(code->address());
711 msg.Append(",%d,\"", code->ExecutableSize()); 740 msg.Append(",%d,\"", code->ExecutableSize());
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 const int modules_to_enable = ~GetActiveProfilerModules() & flags; 1120 const int modules_to_enable = ~GetActiveProfilerModules() & flags;
1092 if (modules_to_enable != PROFILER_MODULE_NONE) { 1121 if (modules_to_enable != PROFILER_MODULE_NONE) {
1093 is_logging_ = true; 1122 is_logging_ = true;
1094 } 1123 }
1095 if (modules_to_enable & PROFILER_MODULE_CPU) { 1124 if (modules_to_enable & PROFILER_MODULE_CPU) {
1096 if (FLAG_prof_lazy) { 1125 if (FLAG_prof_lazy) {
1097 profiler_->Engage(); 1126 profiler_->Engage();
1098 LOG(UncheckedStringEvent("profiler", "resume")); 1127 LOG(UncheckedStringEvent("profiler", "resume"));
1099 FLAG_log_code = true; 1128 FLAG_log_code = true;
1100 LogCompiledFunctions(); 1129 LogCompiledFunctions();
1130 LogAccessorCallbacks();
1101 if (!FLAG_sliding_state_window) ticker_->Start(); 1131 if (!FLAG_sliding_state_window) ticker_->Start();
1102 } 1132 }
1103 profiler_->resume(); 1133 profiler_->resume();
1104 } 1134 }
1105 if (modules_to_enable & 1135 if (modules_to_enable &
1106 (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) { 1136 (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) {
1107 FLAG_log_gc = true; 1137 FLAG_log_gc = true;
1108 } 1138 }
1109 } 1139 }
1110 1140
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 } 1265 }
1236 } else { 1266 } else {
1237 LOG(CodeCreateEvent( 1267 LOG(CodeCreateEvent(
1238 Logger::LAZY_COMPILE_TAG, shared->code(), *func_name)); 1268 Logger::LAZY_COMPILE_TAG, shared->code(), *func_name));
1239 } 1269 }
1240 } 1270 }
1241 1271
1242 DeleteArray(sfis); 1272 DeleteArray(sfis);
1243 } 1273 }
1244 1274
1275
1276 void Logger::LogAccessorCallbacks() {
1277 AssertNoAllocation no_alloc;
1278 HeapIterator iterator;
1279 while (iterator.has_next()) {
1280 HeapObject* obj = iterator.next();
1281 ASSERT(obj != NULL);
1282 if (!obj->IsAccessorInfo()) continue;
1283 AccessorInfo* ai = AccessorInfo::cast(obj);
1284 if (!ai->name()->IsString()) continue;
1285 String* name = String::cast(ai->name());
1286 Address getter_entry = v8::ToCData<Address>(ai->getter());
1287 if (getter_entry != 0) {
1288 LOG(GetterCallbackEvent(name, getter_entry));
1289 }
1290 Address setter_entry = v8::ToCData<Address>(ai->setter());
1291 if (setter_entry != 0) {
1292 LOG(SetterCallbackEvent(name, setter_entry));
1293 }
1294 }
1295 }
1296
1245 #endif 1297 #endif
1246 1298
1247 1299
1248 bool Logger::Setup() { 1300 bool Logger::Setup() {
1249 #ifdef ENABLE_LOGGING_AND_PROFILING 1301 #ifdef ENABLE_LOGGING_AND_PROFILING
1250 // --log-all enables all the log flags. 1302 // --log-all enables all the log flags.
1251 if (FLAG_log_all) { 1303 if (FLAG_log_all) {
1252 FLAG_log_runtime = true; 1304 FLAG_log_runtime = true;
1253 FLAG_log_api = true; 1305 FLAG_log_api = true;
1254 FLAG_log_code = true; 1306 FLAG_log_code = true;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 // Otherwise, if the sliding state window computation has not been 1448 // Otherwise, if the sliding state window computation has not been
1397 // started we do it now. 1449 // started we do it now.
1398 if (sliding_state_window_ == NULL) { 1450 if (sliding_state_window_ == NULL) {
1399 sliding_state_window_ = new SlidingStateWindow(); 1451 sliding_state_window_ = new SlidingStateWindow();
1400 } 1452 }
1401 #endif 1453 #endif
1402 } 1454 }
1403 1455
1404 1456
1405 } } // namespace v8::internal 1457 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log.h ('k') | src/stub-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698