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

Side by Side Diff: src/log.cc

Issue 112863002: Merge bleeding_edge 18021:18297 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/log.h ('k') | src/log-utils.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 239 }
240 240
241 241
242 void CodeEventLogger::RegExpCodeCreateEvent(Code* code, String* source) { 242 void CodeEventLogger::RegExpCodeCreateEvent(Code* code, String* source) {
243 name_buffer_->Init(Logger::REG_EXP_TAG); 243 name_buffer_->Init(Logger::REG_EXP_TAG);
244 name_buffer_->AppendString(source); 244 name_buffer_->AppendString(source);
245 LogRecordedBuffer(code, NULL, name_buffer_->get(), name_buffer_->size()); 245 LogRecordedBuffer(code, NULL, name_buffer_->get(), name_buffer_->size());
246 } 246 }
247 247
248 248
249 // Linux perf tool logging support
250 class PerfBasicLogger : public CodeEventLogger {
251 public:
252 PerfBasicLogger();
253 virtual ~PerfBasicLogger();
254
255 virtual void CodeMoveEvent(Address from, Address to) { }
256 virtual void CodeDeleteEvent(Address from) { }
257
258 private:
259 virtual void LogRecordedBuffer(Code* code,
260 SharedFunctionInfo* shared,
261 const char* name,
262 int length);
263
264 // Extension added to V8 log file name to get the low-level log name.
265 static const char kFilenameFormatString[];
266 static const int kFilenameBufferPadding;
267
268 // File buffer size of the low-level log. We don't use the default to
269 // minimize the associated overhead.
270 static const int kLogBufferSize = 2 * MB;
271
272 FILE* perf_output_handle_;
273 };
274
275 const char PerfBasicLogger::kFilenameFormatString[] = "/tmp/perf-%d.map";
276 // Extra space for the PID in the filename
277 const int PerfBasicLogger::kFilenameBufferPadding = 16;
278
279 PerfBasicLogger::PerfBasicLogger()
280 : perf_output_handle_(NULL) {
281 // Open the perf JIT dump file.
282 int bufferSize = sizeof(kFilenameFormatString) + kFilenameBufferPadding;
283 ScopedVector<char> perf_dump_name(bufferSize);
284 int size = OS::SNPrintF(
285 perf_dump_name,
286 kFilenameFormatString,
287 OS::GetCurrentProcessId());
288 CHECK_NE(size, -1);
289 perf_output_handle_ = OS::FOpen(perf_dump_name.start(), OS::LogFileOpenMode);
290 CHECK_NE(perf_output_handle_, NULL);
291 setvbuf(perf_output_handle_, NULL, _IOFBF, kLogBufferSize);
292 }
293
294
295 PerfBasicLogger::~PerfBasicLogger() {
296 fclose(perf_output_handle_);
297 perf_output_handle_ = NULL;
298 }
299
300
301 void PerfBasicLogger::LogRecordedBuffer(Code* code,
302 SharedFunctionInfo*,
303 const char* name,
304 int length) {
305 ASSERT(code->instruction_start() == code->address() + Code::kHeaderSize);
306
307 OS::FPrint(perf_output_handle_, "%llx %x %.*s\n",
308 reinterpret_cast<uint64_t>(code->instruction_start()),
309 code->instruction_size(),
310 length, name);
311 }
312
313
314 // Linux perf tool logging support
315 class PerfJitLogger : public CodeEventLogger {
316 public:
317 PerfJitLogger();
318 virtual ~PerfJitLogger();
319
320 virtual void CodeMoveEvent(Address from, Address to) { }
321 virtual void CodeDeleteEvent(Address from) { }
322
323 private:
324 virtual void LogRecordedBuffer(Code* code,
325 SharedFunctionInfo* shared,
326 const char* name,
327 int length);
328
329 // Extension added to V8 log file name to get the low-level log name.
330 static const char kFilenameFormatString[];
331 static const int kFilenameBufferPadding;
332
333 // File buffer size of the low-level log. We don't use the default to
334 // minimize the associated overhead.
335 static const int kLogBufferSize = 2 * MB;
336
337 void LogWriteBytes(const char* bytes, int size);
338 void LogWriteHeader();
339
340 static const uint32_t kJitHeaderMagic = 0x4F74496A;
341 static const uint32_t kJitHeaderVersion = 0x2;
342 static const uint32_t kElfMachIA32 = 3;
343 static const uint32_t kElfMachX64 = 62;
344 static const uint32_t kElfMachARM = 40;
345 static const uint32_t kElfMachMIPS = 10;
346
347 struct jitheader {
348 uint32_t magic;
349 uint32_t version;
350 uint32_t total_size;
351 uint32_t elf_mach;
352 uint32_t pad1;
353 uint32_t pid;
354 uint64_t timestamp;
355 };
356
357 enum jit_record_type {
358 JIT_CODE_LOAD = 0
359 // JIT_CODE_UNLOAD = 1,
360 // JIT_CODE_CLOSE = 2,
361 // JIT_CODE_DEBUG_INFO = 3,
362 // JIT_CODE_PAGE_MAP = 4,
363 // JIT_CODE_MAX = 5
364 };
365
366 struct jr_code_load {
367 uint32_t id;
368 uint32_t total_size;
369 uint64_t timestamp;
370 uint64_t vma;
371 uint64_t code_addr;
372 uint32_t code_size;
373 uint32_t align;
374 };
375
376 uint32_t GetElfMach() {
377 #if V8_TARGET_ARCH_IA32
378 return kElfMachIA32;
379 #elif V8_TARGET_ARCH_X64
380 return kElfMachX64;
381 #elif V8_TARGET_ARCH_ARM
382 return kElfMachARM;
383 #elif V8_TARGET_ARCH_MIPS
384 return kElfMachMIPS;
385 #else
386 UNIMPLEMENTED();
387 return 0;
388 #endif
389 }
390
391 FILE* perf_output_handle_;
392 };
393
394 const char PerfJitLogger::kFilenameFormatString[] = "/tmp/jit-%d.dump";
395
396 // Extra padding for the PID in the filename
397 const int PerfJitLogger::kFilenameBufferPadding = 16;
398
399 PerfJitLogger::PerfJitLogger()
400 : perf_output_handle_(NULL) {
401 // Open the perf JIT dump file.
402 int bufferSize = sizeof(kFilenameFormatString) + kFilenameBufferPadding;
403 ScopedVector<char> perf_dump_name(bufferSize);
404 int size = OS::SNPrintF(
405 perf_dump_name,
406 kFilenameFormatString,
407 OS::GetCurrentProcessId());
408 CHECK_NE(size, -1);
409 perf_output_handle_ = OS::FOpen(perf_dump_name.start(), OS::LogFileOpenMode);
410 CHECK_NE(perf_output_handle_, NULL);
411 setvbuf(perf_output_handle_, NULL, _IOFBF, kLogBufferSize);
412
413 LogWriteHeader();
414 }
415
416
417 PerfJitLogger::~PerfJitLogger() {
418 fclose(perf_output_handle_);
419 perf_output_handle_ = NULL;
420 }
421
422
423 void PerfJitLogger::LogRecordedBuffer(Code* code,
424 SharedFunctionInfo*,
425 const char* name,
426 int length) {
427 ASSERT(code->instruction_start() == code->address() + Code::kHeaderSize);
428 ASSERT(perf_output_handle_ != NULL);
429
430 const char* code_name = name;
431 uint8_t* code_pointer = reinterpret_cast<uint8_t*>(code->instruction_start());
432 uint32_t code_size = code->instruction_size();
433
434 static const char string_terminator[] = "\0";
435
436 jr_code_load code_load;
437 code_load.id = JIT_CODE_LOAD;
438 code_load.total_size = sizeof(code_load) + length + 1 + code_size;
439 code_load.timestamp =
440 static_cast<uint64_t>(OS::TimeCurrentMillis() * 1000.0);
441 code_load.vma = 0x0; // Our addresses are absolute.
442 code_load.code_addr = reinterpret_cast<uint64_t>(code->instruction_start());
443 code_load.code_size = code_size;
444 code_load.align = 0;
445
446 LogWriteBytes(reinterpret_cast<const char*>(&code_load), sizeof(code_load));
447 LogWriteBytes(code_name, length);
448 LogWriteBytes(string_terminator, 1);
449 LogWriteBytes(reinterpret_cast<const char*>(code_pointer), code_size);
450 }
451
452
453 void PerfJitLogger::LogWriteBytes(const char* bytes, int size) {
454 size_t rv = fwrite(bytes, 1, size, perf_output_handle_);
455 ASSERT(static_cast<size_t>(size) == rv);
456 USE(rv);
457 }
458
459
460 void PerfJitLogger::LogWriteHeader() {
461 ASSERT(perf_output_handle_ != NULL);
462 jitheader header;
463 header.magic = kJitHeaderMagic;
464 header.version = kJitHeaderVersion;
465 header.total_size = sizeof(jitheader);
466 header.pad1 = 0xdeadbeef;
467 header.elf_mach = GetElfMach();
468 header.pid = OS::GetCurrentProcessId();
469 header.timestamp = static_cast<uint64_t>(OS::TimeCurrentMillis() * 1000.0);
470 LogWriteBytes(reinterpret_cast<const char*>(&header), sizeof(header));
471 }
472
473
249 // Low-level logging support. 474 // Low-level logging support.
250 #define LL_LOG(Call) if (ll_logger_) ll_logger_->Call; 475 #define LL_LOG(Call) if (ll_logger_) ll_logger_->Call;
251 476
252 class LowLevelLogger : public CodeEventLogger { 477 class LowLevelLogger : public CodeEventLogger {
253 public: 478 public:
254 explicit LowLevelLogger(const char* file_name); 479 explicit LowLevelLogger(const char* file_name);
255 virtual ~LowLevelLogger(); 480 virtual ~LowLevelLogger();
256 481
257 virtual void CodeMoveEvent(Address from, Address to); 482 virtual void CodeMoveEvent(Address from, Address to);
258 virtual void CodeDeleteEvent(Address from); 483 virtual void CodeDeleteEvent(Address from);
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 // Logger class implementation. 929 // Logger class implementation.
705 // 930 //
706 931
707 Logger::Logger(Isolate* isolate) 932 Logger::Logger(Isolate* isolate)
708 : isolate_(isolate), 933 : isolate_(isolate),
709 ticker_(NULL), 934 ticker_(NULL),
710 profiler_(NULL), 935 profiler_(NULL),
711 log_events_(NULL), 936 log_events_(NULL),
712 is_logging_(false), 937 is_logging_(false),
713 log_(new Log(this)), 938 log_(new Log(this)),
939 perf_basic_logger_(NULL),
940 perf_jit_logger_(NULL),
714 ll_logger_(NULL), 941 ll_logger_(NULL),
715 jit_logger_(NULL), 942 jit_logger_(NULL),
716 listeners_(5), 943 listeners_(5),
717 is_initialized_(false) { 944 is_initialized_(false) {
718 } 945 }
719 946
720 947
721 Logger::~Logger() { 948 Logger::~Logger() {
722 delete log_; 949 delete log_;
723 } 950 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 va_end(ap); 1034 va_end(ap);
808 msg.WriteToLogFile(); 1035 msg.WriteToLogFile();
809 } 1036 }
810 1037
811 1038
812 void Logger::ApiNamedSecurityCheck(Object* key) { 1039 void Logger::ApiNamedSecurityCheck(Object* key) {
813 if (!log_->IsEnabled() || !FLAG_log_api) return; 1040 if (!log_->IsEnabled() || !FLAG_log_api) return;
814 if (key->IsString()) { 1041 if (key->IsString()) {
815 SmartArrayPointer<char> str = 1042 SmartArrayPointer<char> str =
816 String::cast(key)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1043 String::cast(key)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
817 ApiEvent("api,check-security,\"%s\"\n", *str); 1044 ApiEvent("api,check-security,\"%s\"\n", str.get());
818 } else if (key->IsSymbol()) { 1045 } else if (key->IsSymbol()) {
819 Symbol* symbol = Symbol::cast(key); 1046 Symbol* symbol = Symbol::cast(key);
820 if (symbol->name()->IsUndefined()) { 1047 if (symbol->name()->IsUndefined()) {
821 ApiEvent("api,check-security,symbol(hash %x)\n", 1048 ApiEvent("api,check-security,symbol(hash %x)\n",
822 Symbol::cast(key)->Hash()); 1049 Symbol::cast(key)->Hash());
823 } else { 1050 } else {
824 SmartArrayPointer<char> str = String::cast(symbol->name())->ToCString( 1051 SmartArrayPointer<char> str = String::cast(symbol->name())->ToCString(
825 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1052 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
826 ApiEvent("api,check-security,symbol(\"%s\" hash %x)\n", 1053 ApiEvent("api,check-security,symbol(\"%s\" hash %x)\n",
827 *str, 1054 str.get(),
828 Symbol::cast(key)->Hash()); 1055 Symbol::cast(key)->Hash());
829 } 1056 }
830 } else if (key->IsUndefined()) { 1057 } else if (key->IsUndefined()) {
831 ApiEvent("api,check-security,undefined\n"); 1058 ApiEvent("api,check-security,undefined\n");
832 } else { 1059 } else {
833 ApiEvent("api,check-security,['no-name']\n"); 1060 ApiEvent("api,check-security,['no-name']\n");
834 } 1061 }
835 } 1062 }
836 1063
837 1064
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 JSObject* holder, 1246 JSObject* holder,
1020 Object* name) { 1247 Object* name) {
1021 ASSERT(name->IsName()); 1248 ASSERT(name->IsName());
1022 if (!log_->IsEnabled() || !FLAG_log_api) return; 1249 if (!log_->IsEnabled() || !FLAG_log_api) return;
1023 String* class_name_obj = holder->class_name(); 1250 String* class_name_obj = holder->class_name();
1024 SmartArrayPointer<char> class_name = 1251 SmartArrayPointer<char> class_name =
1025 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1252 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1026 if (name->IsString()) { 1253 if (name->IsString()) {
1027 SmartArrayPointer<char> property_name = 1254 SmartArrayPointer<char> property_name =
1028 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1255 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1029 ApiEvent("api,%s,\"%s\",\"%s\"\n", tag, *class_name, *property_name); 1256 ApiEvent("api,%s,\"%s\",\"%s\"\n", tag, class_name.get(),
1257 property_name.get());
1030 } else { 1258 } else {
1031 Symbol* symbol = Symbol::cast(name); 1259 Symbol* symbol = Symbol::cast(name);
1032 uint32_t hash = symbol->Hash(); 1260 uint32_t hash = symbol->Hash();
1033 if (symbol->name()->IsUndefined()) { 1261 if (symbol->name()->IsUndefined()) {
1034 ApiEvent("api,%s,\"%s\",symbol(hash %x)\n", tag, *class_name, hash); 1262 ApiEvent("api,%s,\"%s\",symbol(hash %x)\n", tag, class_name.get(), hash);
1035 } else { 1263 } else {
1036 SmartArrayPointer<char> str = String::cast(symbol->name())->ToCString( 1264 SmartArrayPointer<char> str = String::cast(symbol->name())->ToCString(
1037 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1265 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1038 ApiEvent("api,%s,\"%s\",symbol(\"%s\" hash %x)\n", 1266 ApiEvent("api,%s,\"%s\",symbol(\"%s\" hash %x)\n",
1039 tag, *class_name, *str, hash); 1267 tag, class_name.get(), str.get(), hash);
1040 } 1268 }
1041 } 1269 }
1042 } 1270 }
1043 1271
1044 void Logger::ApiIndexedPropertyAccess(const char* tag, 1272 void Logger::ApiIndexedPropertyAccess(const char* tag,
1045 JSObject* holder, 1273 JSObject* holder,
1046 uint32_t index) { 1274 uint32_t index) {
1047 if (!log_->IsEnabled() || !FLAG_log_api) return; 1275 if (!log_->IsEnabled() || !FLAG_log_api) return;
1048 String* class_name_obj = holder->class_name(); 1276 String* class_name_obj = holder->class_name();
1049 SmartArrayPointer<char> class_name = 1277 SmartArrayPointer<char> class_name =
1050 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1278 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1051 ApiEvent("api,%s,\"%s\",%u\n", tag, *class_name, index); 1279 ApiEvent("api,%s,\"%s\",%u\n", tag, class_name.get(), index);
1052 } 1280 }
1053 1281
1054 1282
1055 void Logger::ApiObjectAccess(const char* tag, JSObject* object) { 1283 void Logger::ApiObjectAccess(const char* tag, JSObject* object) {
1056 if (!log_->IsEnabled() || !FLAG_log_api) return; 1284 if (!log_->IsEnabled() || !FLAG_log_api) return;
1057 String* class_name_obj = object->class_name(); 1285 String* class_name_obj = object->class_name();
1058 SmartArrayPointer<char> class_name = 1286 SmartArrayPointer<char> class_name =
1059 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1287 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1060 ApiEvent("api,%s,\"%s\"\n", tag, *class_name); 1288 ApiEvent("api,%s,\"%s\"\n", tag, class_name.get());
1061 } 1289 }
1062 1290
1063 1291
1064 void Logger::ApiEntryCall(const char* name) { 1292 void Logger::ApiEntryCall(const char* name) {
1065 if (!log_->IsEnabled() || !FLAG_log_api) return; 1293 if (!log_->IsEnabled() || !FLAG_log_api) return;
1066 ApiEvent("api,%s\n", name); 1294 ApiEvent("api,%s\n", name);
1067 } 1295 }
1068 1296
1069 1297
1070 void Logger::NewEvent(const char* name, void* object, size_t size) { 1298 void Logger::NewEvent(const char* name, void* object, size_t size) {
(...skipping 27 matching lines...) Expand all
1098 Address entry_point) { 1326 Address entry_point) {
1099 if (!FLAG_log_code || !log_->IsEnabled()) return; 1327 if (!FLAG_log_code || !log_->IsEnabled()) return;
1100 Log::MessageBuilder msg(log_); 1328 Log::MessageBuilder msg(log_);
1101 msg.Append("%s,%s,-2,", 1329 msg.Append("%s,%s,-2,",
1102 kLogEventsNames[CODE_CREATION_EVENT], 1330 kLogEventsNames[CODE_CREATION_EVENT],
1103 kLogEventsNames[CALLBACK_TAG]); 1331 kLogEventsNames[CALLBACK_TAG]);
1104 msg.AppendAddress(entry_point); 1332 msg.AppendAddress(entry_point);
1105 if (name->IsString()) { 1333 if (name->IsString()) {
1106 SmartArrayPointer<char> str = 1334 SmartArrayPointer<char> str =
1107 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1335 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1108 msg.Append(",1,\"%s%s\"", prefix, *str); 1336 msg.Append(",1,\"%s%s\"", prefix, str.get());
1109 } else { 1337 } else {
1110 Symbol* symbol = Symbol::cast(name); 1338 Symbol* symbol = Symbol::cast(name);
1111 if (symbol->name()->IsUndefined()) { 1339 if (symbol->name()->IsUndefined()) {
1112 msg.Append(",1,symbol(hash %x)", prefix, symbol->Hash()); 1340 msg.Append(",1,symbol(hash %x)", prefix, symbol->Hash());
1113 } else { 1341 } else {
1114 SmartArrayPointer<char> str = String::cast(symbol->name())->ToCString( 1342 SmartArrayPointer<char> str = String::cast(symbol->name())->ToCString(
1115 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1343 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1116 msg.Append(",1,symbol(\"%s\" hash %x)", prefix, *str, symbol->Hash()); 1344 msg.Append(",1,symbol(\"%s\" hash %x)", prefix, str.get(),
1345 symbol->Hash());
1117 } 1346 }
1118 } 1347 }
1119 msg.Append('\n'); 1348 msg.Append('\n');
1120 msg.WriteToLogFile(); 1349 msg.WriteToLogFile();
1121 } 1350 }
1122 1351
1123 1352
1124 void Logger::CallbackEvent(Name* name, Address entry_point) { 1353 void Logger::CallbackEvent(Name* name, Address entry_point) {
1125 PROFILER_LOG(CallbackEvent(name, entry_point)); 1354 PROFILER_LOG(CallbackEvent(name, entry_point));
1126 CallbackEventInternal("", name, entry_point); 1355 CallbackEventInternal("", name, entry_point);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 if (!FLAG_log_code || !log_->IsEnabled()) return; 1434 if (!FLAG_log_code || !log_->IsEnabled()) return;
1206 if (code == isolate_->builtins()->builtin( 1435 if (code == isolate_->builtins()->builtin(
1207 Builtins::kLazyCompile)) 1436 Builtins::kLazyCompile))
1208 return; 1437 return;
1209 1438
1210 Log::MessageBuilder msg(log_); 1439 Log::MessageBuilder msg(log_);
1211 AppendCodeCreateHeader(&msg, tag, code); 1440 AppendCodeCreateHeader(&msg, tag, code);
1212 if (name->IsString()) { 1441 if (name->IsString()) {
1213 SmartArrayPointer<char> str = 1442 SmartArrayPointer<char> str =
1214 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1443 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1215 msg.Append("\"%s\"", *str); 1444 msg.Append("\"%s\"", str.get());
1216 } else { 1445 } else {
1217 msg.AppendSymbolName(Symbol::cast(name)); 1446 msg.AppendSymbolName(Symbol::cast(name));
1218 } 1447 }
1219 msg.Append(','); 1448 msg.Append(',');
1220 msg.AppendAddress(shared->address()); 1449 msg.AppendAddress(shared->address());
1221 msg.Append(",%s", ComputeMarker(code)); 1450 msg.Append(",%s", ComputeMarker(code));
1222 msg.Append('\n'); 1451 msg.Append('\n');
1223 msg.WriteToLogFile(); 1452 msg.WriteToLogFile();
1224 } 1453 }
1225 1454
(...skipping 10 matching lines...) Expand all
1236 1465
1237 if (!is_logging_code_events()) return; 1466 if (!is_logging_code_events()) return;
1238 CALL_LISTENERS(CodeCreateEvent(tag, code, shared, info, source, line, 1467 CALL_LISTENERS(CodeCreateEvent(tag, code, shared, info, source, line,
1239 column)); 1468 column));
1240 1469
1241 if (!FLAG_log_code || !log_->IsEnabled()) return; 1470 if (!FLAG_log_code || !log_->IsEnabled()) return;
1242 Log::MessageBuilder msg(log_); 1471 Log::MessageBuilder msg(log_);
1243 AppendCodeCreateHeader(&msg, tag, code); 1472 AppendCodeCreateHeader(&msg, tag, code);
1244 SmartArrayPointer<char> name = 1473 SmartArrayPointer<char> name =
1245 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1474 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1246 msg.Append("\"%s ", *name); 1475 msg.Append("\"%s ", name.get());
1247 if (source->IsString()) { 1476 if (source->IsString()) {
1248 SmartArrayPointer<char> sourcestr = 1477 SmartArrayPointer<char> sourcestr =
1249 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1478 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1250 msg.Append("%s", *sourcestr); 1479 msg.Append("%s", sourcestr.get());
1251 } else { 1480 } else {
1252 msg.AppendSymbolName(Symbol::cast(source)); 1481 msg.AppendSymbolName(Symbol::cast(source));
1253 } 1482 }
1254 msg.Append(":%d:%d\",", line, column); 1483 msg.Append(":%d:%d\",", line, column);
1255 msg.AppendAddress(shared->address()); 1484 msg.AppendAddress(shared->address());
1256 msg.Append(",%s", ComputeMarker(code)); 1485 msg.Append(",%s", ComputeMarker(code));
1257 msg.Append('\n'); 1486 msg.Append('\n');
1258 msg.WriteToLogFile(); 1487 msg.WriteToLogFile();
1259 } 1488 }
1260 1489
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 1833
1605 1834
1606 void Logger::LogCodeObject(Object* object) { 1835 void Logger::LogCodeObject(Object* object) {
1607 Code* code_object = Code::cast(object); 1836 Code* code_object = Code::cast(object);
1608 LogEventsAndTags tag = Logger::STUB_TAG; 1837 LogEventsAndTags tag = Logger::STUB_TAG;
1609 const char* description = "Unknown code from the snapshot"; 1838 const char* description = "Unknown code from the snapshot";
1610 switch (code_object->kind()) { 1839 switch (code_object->kind()) {
1611 case Code::FUNCTION: 1840 case Code::FUNCTION:
1612 case Code::OPTIMIZED_FUNCTION: 1841 case Code::OPTIMIZED_FUNCTION:
1613 return; // We log this later using LogCompiledFunctions. 1842 return; // We log this later using LogCompiledFunctions.
1614 case Code::BINARY_OP_IC: { 1843 case Code::BINARY_OP_IC:
1615 BinaryOpStub stub(code_object->extended_extra_ic_state());
1616 description = stub.GetName().Detach();
1617 tag = Logger::STUB_TAG;
1618 break;
1619 }
1620 case Code::COMPARE_IC: // fall through 1844 case Code::COMPARE_IC: // fall through
1621 case Code::COMPARE_NIL_IC: // fall through 1845 case Code::COMPARE_NIL_IC: // fall through
1622 case Code::TO_BOOLEAN_IC: // fall through 1846 case Code::TO_BOOLEAN_IC: // fall through
1623 case Code::STUB: 1847 case Code::STUB:
1624 description = 1848 description =
1625 CodeStub::MajorName(CodeStub::GetMajorKey(code_object), true); 1849 CodeStub::MajorName(CodeStub::GetMajorKey(code_object), true);
1626 if (description == NULL) 1850 if (description == NULL)
1627 description = "A stub from the snapshot"; 1851 description = "A stub from the snapshot";
1628 tag = Logger::STUB_TAG; 1852 tag = Logger::STUB_TAG;
1629 break; 1853 break;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1835 if (is_initialized_) return true; 2059 if (is_initialized_) return true;
1836 is_initialized_ = true; 2060 is_initialized_ = true;
1837 2061
1838 // --ll-prof implies --log-code and --log-snapshot-positions. 2062 // --ll-prof implies --log-code and --log-snapshot-positions.
1839 if (FLAG_ll_prof) { 2063 if (FLAG_ll_prof) {
1840 FLAG_log_snapshot_positions = true; 2064 FLAG_log_snapshot_positions = true;
1841 } 2065 }
1842 2066
1843 SmartArrayPointer<const char> log_file_name = 2067 SmartArrayPointer<const char> log_file_name =
1844 PrepareLogFileName(isolate, FLAG_logfile); 2068 PrepareLogFileName(isolate, FLAG_logfile);
1845 log_->Initialize(*log_file_name); 2069 log_->Initialize(log_file_name.get());
2070
2071
2072 if (FLAG_perf_basic_prof) {
2073 perf_basic_logger_ = new PerfBasicLogger();
2074 addCodeEventListener(perf_basic_logger_);
2075 }
2076
2077 if (FLAG_perf_jit_prof) {
2078 perf_jit_logger_ = new PerfJitLogger();
2079 addCodeEventListener(perf_jit_logger_);
2080 }
1846 2081
1847 if (FLAG_ll_prof) { 2082 if (FLAG_ll_prof) {
1848 ll_logger_ = new LowLevelLogger(*log_file_name); 2083 ll_logger_ = new LowLevelLogger(log_file_name.get());
1849 addCodeEventListener(ll_logger_); 2084 addCodeEventListener(ll_logger_);
1850 } 2085 }
1851 2086
1852 ticker_ = new Ticker(isolate, kSamplingIntervalMs); 2087 ticker_ = new Ticker(isolate, kSamplingIntervalMs);
1853 2088
1854 if (Log::InitLogAtStart()) { 2089 if (Log::InitLogAtStart()) {
1855 is_logging_ = true; 2090 is_logging_ = true;
1856 } 2091 }
1857 2092
1858 if (FLAG_prof) { 2093 if (FLAG_prof) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 // Stop the profiler before closing the file. 2134 // Stop the profiler before closing the file.
1900 if (profiler_ != NULL) { 2135 if (profiler_ != NULL) {
1901 profiler_->Disengage(); 2136 profiler_->Disengage();
1902 delete profiler_; 2137 delete profiler_;
1903 profiler_ = NULL; 2138 profiler_ = NULL;
1904 } 2139 }
1905 2140
1906 delete ticker_; 2141 delete ticker_;
1907 ticker_ = NULL; 2142 ticker_ = NULL;
1908 2143
2144 if (perf_basic_logger_) {
2145 removeCodeEventListener(perf_basic_logger_);
2146 delete perf_basic_logger_;
2147 perf_basic_logger_ = NULL;
2148 }
2149
2150 if (perf_jit_logger_) {
2151 removeCodeEventListener(perf_jit_logger_);
2152 delete perf_jit_logger_;
2153 perf_jit_logger_ = NULL;
2154 }
2155
1909 if (ll_logger_) { 2156 if (ll_logger_) {
1910 removeCodeEventListener(ll_logger_); 2157 removeCodeEventListener(ll_logger_);
1911 delete ll_logger_; 2158 delete ll_logger_;
1912 ll_logger_ = NULL; 2159 ll_logger_ = NULL;
1913 } 2160 }
1914 2161
1915 if (jit_logger_) { 2162 if (jit_logger_) {
1916 removeCodeEventListener(jit_logger_); 2163 removeCodeEventListener(jit_logger_);
1917 delete jit_logger_; 2164 delete jit_logger_;
1918 jit_logger_ = NULL; 2165 jit_logger_ = NULL;
1919 } 2166 }
1920 2167
1921 return log_->Close(); 2168 return log_->Close();
1922 } 2169 }
1923 2170
1924 } } // namespace v8::internal 2171 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log.h ('k') | src/log-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698