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

Side by Side Diff: src/log.cc

Issue 112036: Introduce Logger::LogCompiledFunctions that logs current map of compiled code. (Closed)
Patch Set: struct -> class Created 11 years, 7 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') | test/cctest/test-log.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 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 1101
1102 void Logger::ResumeProfiler() { 1102 void Logger::ResumeProfiler() {
1103 profiler_->resume(); 1103 profiler_->resume();
1104 } 1104 }
1105 1105
1106 1106
1107 int Logger::GetLogLines(int from_pos, char* dest_buf, int max_size) { 1107 int Logger::GetLogLines(int from_pos, char* dest_buf, int max_size) {
1108 return Log::GetLogLines(from_pos, dest_buf, max_size); 1108 return Log::GetLogLines(from_pos, dest_buf, max_size);
1109 } 1109 }
1110 1110
1111
1112 void Logger::LogCompiledFunctions() {
1113 HandleScope scope;
1114 Handle<SharedFunctionInfo>* sfis = NULL;
1115 int compiled_funcs_count = 0;
1116
1117 {
1118 AssertNoAllocation no_alloc;
1119
1120 HeapIterator iterator;
1121 while (iterator.has_next()) {
1122 HeapObject* obj = iterator.next();
1123 ASSERT(obj != NULL);
1124 if (obj->IsSharedFunctionInfo()
1125 && SharedFunctionInfo::cast(obj)->is_compiled()) {
1126 ++compiled_funcs_count;
1127 }
1128 }
1129
1130 sfis = NewArray< Handle<SharedFunctionInfo> >(compiled_funcs_count);
1131 iterator.reset();
1132
1133 int i = 0;
1134 while (iterator.has_next()) {
1135 HeapObject* obj = iterator.next();
1136 ASSERT(obj != NULL);
1137 if (obj->IsSharedFunctionInfo()
1138 && SharedFunctionInfo::cast(obj)->is_compiled()) {
1139 sfis[i++] = Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(obj));
1140 }
1141 }
1142 }
1143
1144 // During iteration, there can be heap allocation due to
1145 // GetScriptLineNumber call.
1146 for (int i = 0; i < compiled_funcs_count; ++i) {
1147 Handle<SharedFunctionInfo> shared = sfis[i];
1148 Handle<String> name(String::cast(shared->name()));
1149 Handle<String> func_name(name->length() > 0 ?
1150 *name : shared->inferred_name());
1151 if (shared->script()->IsScript()) {
1152 Handle<Script> script(Script::cast(shared->script()));
1153 if (script->name()->IsString()) {
1154 Handle<String> script_name(String::cast(script->name()));
1155 int line_num = GetScriptLineNumber(script, shared->start_position());
1156 if (line_num > 0) {
1157 line_num += script->line_offset()->value() + 1;
1158 LOG(CodeCreateEvent("LazyCompile", shared->code(), *func_name,
1159 *script_name, line_num));
1160 } else {
1161 // Can't distinguish enum and script here, so always use Script.
1162 LOG(CodeCreateEvent("Script", shared->code(), *script_name));
1163 }
1164 continue;
1165 }
1166 }
1167 // If no script or script has no name.
1168 LOG(CodeCreateEvent("LazyCompile", shared->code(), *func_name));
1169 }
1170
1171 DeleteArray(sfis);
1172 }
1173
1111 #endif 1174 #endif
1112 1175
1113 1176
1114 bool Logger::Setup() { 1177 bool Logger::Setup() {
1115 #ifdef ENABLE_LOGGING_AND_PROFILING 1178 #ifdef ENABLE_LOGGING_AND_PROFILING
1116 // --log-all enables all the log flags. 1179 // --log-all enables all the log flags.
1117 if (FLAG_log_all) { 1180 if (FLAG_log_all) {
1118 FLAG_log_runtime = true; 1181 FLAG_log_runtime = true;
1119 FLAG_log_api = true; 1182 FLAG_log_api = true;
1120 FLAG_log_code = true; 1183 FLAG_log_code = true;
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 } else if (previous_->state_ == EXTERNAL) { 1379 } else if (previous_->state_ == EXTERNAL) {
1317 // We are leaving V8. 1380 // We are leaving V8.
1318 Heap::Protect(); 1381 Heap::Protect();
1319 } 1382 }
1320 } 1383 }
1321 #endif 1384 #endif
1322 } 1385 }
1323 #endif 1386 #endif
1324 1387
1325 } } // namespace v8::internal 1388 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log.h ('k') | test/cctest/test-log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698