| OLD | NEW |
| 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 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 msg.Append("%s,%s,", log_events_[CODE_CREATION_EVENT], log_events_[tag]); | 758 msg.Append("%s,%s,", log_events_[CODE_CREATION_EVENT], log_events_[tag]); |
| 759 msg.AppendAddress(code->address()); | 759 msg.AppendAddress(code->address()); |
| 760 msg.Append(",%d,\"", code->ExecutableSize()); | 760 msg.Append(",%d,\"", code->ExecutableSize()); |
| 761 for (const char* p = comment; *p != '\0'; p++) { | 761 for (const char* p = comment; *p != '\0'; p++) { |
| 762 if (*p == '"') { | 762 if (*p == '"') { |
| 763 msg.Append('\\'); | 763 msg.Append('\\'); |
| 764 } | 764 } |
| 765 msg.Append(*p); | 765 msg.Append(*p); |
| 766 } | 766 } |
| 767 msg.Append('"'); | 767 msg.Append('"'); |
| 768 LowLevelCodeCreateEvent(code, &msg); |
| 768 if (FLAG_compress_log) { | 769 if (FLAG_compress_log) { |
| 769 ASSERT(compression_helper_ != NULL); | 770 ASSERT(compression_helper_ != NULL); |
| 770 if (!compression_helper_->HandleMessage(&msg)) return; | 771 if (!compression_helper_->HandleMessage(&msg)) return; |
| 771 } | 772 } |
| 772 msg.Append('\n'); | 773 msg.Append('\n'); |
| 773 msg.WriteToLogFile(); | 774 msg.WriteToLogFile(); |
| 774 #endif | 775 #endif |
| 775 } | 776 } |
| 776 | 777 |
| 777 | 778 |
| 778 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, String* name) { | 779 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, String* name) { |
| 779 #ifdef ENABLE_LOGGING_AND_PROFILING | 780 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 780 if (!Log::IsEnabled() || !FLAG_log_code) return; | 781 if (!Log::IsEnabled() || !FLAG_log_code) return; |
| 781 LogMessageBuilder msg; | 782 LogMessageBuilder msg; |
| 782 SmartPointer<char> str = | 783 SmartPointer<char> str = |
| 783 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 784 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 784 msg.Append("%s,%s,", log_events_[CODE_CREATION_EVENT], log_events_[tag]); | 785 msg.Append("%s,%s,", log_events_[CODE_CREATION_EVENT], log_events_[tag]); |
| 785 msg.AppendAddress(code->address()); | 786 msg.AppendAddress(code->address()); |
| 786 msg.Append(",%d,\"%s\"", code->ExecutableSize(), *str); | 787 msg.Append(",%d,\"%s\"", code->ExecutableSize(), *str); |
| 788 LowLevelCodeCreateEvent(code, &msg); |
| 787 if (FLAG_compress_log) { | 789 if (FLAG_compress_log) { |
| 788 ASSERT(compression_helper_ != NULL); | 790 ASSERT(compression_helper_ != NULL); |
| 789 if (!compression_helper_->HandleMessage(&msg)) return; | 791 if (!compression_helper_->HandleMessage(&msg)) return; |
| 790 } | 792 } |
| 791 msg.Append('\n'); | 793 msg.Append('\n'); |
| 792 msg.WriteToLogFile(); | 794 msg.WriteToLogFile(); |
| 793 #endif | 795 #endif |
| 794 } | 796 } |
| 795 | 797 |
| 796 | 798 |
| 797 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 799 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 798 Code* code, String* name, | 800 Code* code, String* name, |
| 799 String* source, int line) { | 801 String* source, int line) { |
| 800 #ifdef ENABLE_LOGGING_AND_PROFILING | 802 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 801 if (!Log::IsEnabled() || !FLAG_log_code) return; | 803 if (!Log::IsEnabled() || !FLAG_log_code) return; |
| 802 LogMessageBuilder msg; | 804 LogMessageBuilder msg; |
| 803 SmartPointer<char> str = | 805 SmartPointer<char> str = |
| 804 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 806 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 805 SmartPointer<char> sourcestr = | 807 SmartPointer<char> sourcestr = |
| 806 source->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 808 source->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 807 msg.Append("%s,%s,", log_events_[CODE_CREATION_EVENT], log_events_[tag]); | 809 msg.Append("%s,%s,", log_events_[CODE_CREATION_EVENT], log_events_[tag]); |
| 808 msg.AppendAddress(code->address()); | 810 msg.AppendAddress(code->address()); |
| 809 msg.Append(",%d,\"%s %s:%d\"", | 811 msg.Append(",%d,\"%s %s:%d\"", |
| 810 code->ExecutableSize(), *str, *sourcestr, line); | 812 code->ExecutableSize(), *str, *sourcestr, line); |
| 813 LowLevelCodeCreateEvent(code, &msg); |
| 811 if (FLAG_compress_log) { | 814 if (FLAG_compress_log) { |
| 812 ASSERT(compression_helper_ != NULL); | 815 ASSERT(compression_helper_ != NULL); |
| 813 if (!compression_helper_->HandleMessage(&msg)) return; | 816 if (!compression_helper_->HandleMessage(&msg)) return; |
| 814 } | 817 } |
| 815 msg.Append('\n'); | 818 msg.Append('\n'); |
| 816 msg.WriteToLogFile(); | 819 msg.WriteToLogFile(); |
| 817 #endif | 820 #endif |
| 818 } | 821 } |
| 819 | 822 |
| 820 | 823 |
| 821 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) { | 824 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) { |
| 822 #ifdef ENABLE_LOGGING_AND_PROFILING | 825 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 823 if (!Log::IsEnabled() || !FLAG_log_code) return; | 826 if (!Log::IsEnabled() || !FLAG_log_code) return; |
| 824 LogMessageBuilder msg; | 827 LogMessageBuilder msg; |
| 825 msg.Append("%s,%s,", log_events_[CODE_CREATION_EVENT], log_events_[tag]); | 828 msg.Append("%s,%s,", log_events_[CODE_CREATION_EVENT], log_events_[tag]); |
| 826 msg.AppendAddress(code->address()); | 829 msg.AppendAddress(code->address()); |
| 827 msg.Append(",%d,\"args_count: %d\"", code->ExecutableSize(), args_count); | 830 msg.Append(",%d,\"args_count: %d\"", code->ExecutableSize(), args_count); |
| 831 LowLevelCodeCreateEvent(code, &msg); |
| 828 if (FLAG_compress_log) { | 832 if (FLAG_compress_log) { |
| 829 ASSERT(compression_helper_ != NULL); | 833 ASSERT(compression_helper_ != NULL); |
| 830 if (!compression_helper_->HandleMessage(&msg)) return; | 834 if (!compression_helper_->HandleMessage(&msg)) return; |
| 831 } | 835 } |
| 832 msg.Append('\n'); | 836 msg.Append('\n'); |
| 833 msg.WriteToLogFile(); | 837 msg.WriteToLogFile(); |
| 834 #endif | 838 #endif |
| 835 } | 839 } |
| 836 | 840 |
| 837 | 841 |
| 842 void Logger::CodeMovingGCEvent() { |
| 843 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 844 if (!Log::IsEnabled() || !FLAG_log_code || !FLAG_ll_prof) return; |
| 845 LogMessageBuilder msg; |
| 846 msg.Append("%s\n", log_events_[CODE_MOVING_GC]); |
| 847 msg.WriteToLogFile(); |
| 848 OS::SignalCodeMovingGC(); |
| 849 #endif |
| 850 } |
| 851 |
| 852 |
| 838 void Logger::RegExpCodeCreateEvent(Code* code, String* source) { | 853 void Logger::RegExpCodeCreateEvent(Code* code, String* source) { |
| 839 #ifdef ENABLE_LOGGING_AND_PROFILING | 854 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 840 if (!Log::IsEnabled() || !FLAG_log_code) return; | 855 if (!Log::IsEnabled() || !FLAG_log_code) return; |
| 841 LogMessageBuilder msg; | 856 LogMessageBuilder msg; |
| 842 msg.Append("%s,%s,", | 857 msg.Append("%s,%s,", |
| 843 log_events_[CODE_CREATION_EVENT], log_events_[REG_EXP_TAG]); | 858 log_events_[CODE_CREATION_EVENT], log_events_[REG_EXP_TAG]); |
| 844 msg.AppendAddress(code->address()); | 859 msg.AppendAddress(code->address()); |
| 845 msg.Append(",%d,\"", code->ExecutableSize()); | 860 msg.Append(",%d,\"", code->ExecutableSize()); |
| 846 msg.AppendDetailed(source, false); | 861 msg.AppendDetailed(source, false); |
| 847 msg.Append('\"'); | 862 msg.Append('\"'); |
| 863 LowLevelCodeCreateEvent(code, &msg); |
| 848 if (FLAG_compress_log) { | 864 if (FLAG_compress_log) { |
| 849 ASSERT(compression_helper_ != NULL); | 865 ASSERT(compression_helper_ != NULL); |
| 850 if (!compression_helper_->HandleMessage(&msg)) return; | 866 if (!compression_helper_->HandleMessage(&msg)) return; |
| 851 } | 867 } |
| 852 msg.Append('\n'); | 868 msg.Append('\n'); |
| 853 msg.WriteToLogFile(); | 869 msg.WriteToLogFile(); |
| 854 #endif | 870 #endif |
| 855 } | 871 } |
| 856 | 872 |
| 857 | 873 |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 case Code::KEYED_CALL_IC: | 1349 case Code::KEYED_CALL_IC: |
| 1334 description = "A keyed call IC from the snapshot"; | 1350 description = "A keyed call IC from the snapshot"; |
| 1335 tag = Logger::KEYED_CALL_IC_TAG; | 1351 tag = Logger::KEYED_CALL_IC_TAG; |
| 1336 break; | 1352 break; |
| 1337 } | 1353 } |
| 1338 PROFILE(CodeCreateEvent(tag, code_object, description)); | 1354 PROFILE(CodeCreateEvent(tag, code_object, description)); |
| 1339 } | 1355 } |
| 1340 } | 1356 } |
| 1341 | 1357 |
| 1342 | 1358 |
| 1359 void Logger::LogCodeInfo() { |
| 1360 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 1361 if (!Log::IsEnabled() || !FLAG_log_code || !FLAG_ll_prof) return; |
| 1362 #if V8_TARGET_ARCH_IA32 |
| 1363 const char arch[] = "ia32"; |
| 1364 #elif V8_TARGET_ARCH_X64 |
| 1365 const char arch[] = "x64"; |
| 1366 #elif V8_TARGET_ARCH_ARM |
| 1367 const char arch[] = "arm"; |
| 1368 #else |
| 1369 const char arch[] = "unknown"; |
| 1370 #endif |
| 1371 LogMessageBuilder msg; |
| 1372 msg.Append("code-info,%s,%d\n", arch, Code::kHeaderSize); |
| 1373 msg.WriteToLogFile(); |
| 1374 #endif // ENABLE_LOGGING_AND_PROFILING |
| 1375 } |
| 1376 |
| 1377 |
| 1378 void Logger::LowLevelCodeCreateEvent(Code* code, LogMessageBuilder* msg) { |
| 1379 if (!FLAG_ll_prof || Log::output_code_handle_ == NULL) return; |
| 1380 int pos = static_cast<int>(ftell(Log::output_code_handle_)); |
| 1381 fwrite(code->instruction_start(), 1, code->instruction_size(), |
| 1382 Log::output_code_handle_); |
| 1383 msg->Append(",%d", pos); |
| 1384 } |
| 1385 |
| 1386 |
| 1343 void Logger::LogCodeObjects() { | 1387 void Logger::LogCodeObjects() { |
| 1344 AssertNoAllocation no_alloc; | 1388 AssertNoAllocation no_alloc; |
| 1345 HeapIterator iterator; | 1389 HeapIterator iterator; |
| 1346 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 1390 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
| 1347 if (obj->IsCode()) LogCodeObject(obj); | 1391 if (obj->IsCode()) LogCodeObject(obj); |
| 1348 } | 1392 } |
| 1349 } | 1393 } |
| 1350 | 1394 |
| 1351 | 1395 |
| 1352 void Logger::LogCompiledFunctions() { | 1396 void Logger::LogCompiledFunctions() { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 FLAG_log_code = true; | 1488 FLAG_log_code = true; |
| 1445 FLAG_log_gc = true; | 1489 FLAG_log_gc = true; |
| 1446 FLAG_log_suspect = true; | 1490 FLAG_log_suspect = true; |
| 1447 FLAG_log_handles = true; | 1491 FLAG_log_handles = true; |
| 1448 FLAG_log_regexp = true; | 1492 FLAG_log_regexp = true; |
| 1449 } | 1493 } |
| 1450 | 1494 |
| 1451 // --prof implies --log-code. | 1495 // --prof implies --log-code. |
| 1452 if (FLAG_prof) FLAG_log_code = true; | 1496 if (FLAG_prof) FLAG_log_code = true; |
| 1453 | 1497 |
| 1498 // --ll-prof implies --log-code and --log-snapshot-positions. |
| 1499 if (FLAG_ll_prof) { |
| 1500 FLAG_log_code = true; |
| 1501 FLAG_log_snapshot_positions = true; |
| 1502 } |
| 1503 |
| 1454 // --prof_lazy controls --log-code, implies --noprof_auto. | 1504 // --prof_lazy controls --log-code, implies --noprof_auto. |
| 1455 if (FLAG_prof_lazy) { | 1505 if (FLAG_prof_lazy) { |
| 1456 FLAG_log_code = false; | 1506 FLAG_log_code = false; |
| 1457 FLAG_prof_auto = false; | 1507 FLAG_prof_auto = false; |
| 1458 } | 1508 } |
| 1459 | 1509 |
| 1460 bool start_logging = FLAG_log || FLAG_log_runtime || FLAG_log_api | 1510 bool start_logging = FLAG_log || FLAG_log_runtime || FLAG_log_api |
| 1461 || FLAG_log_code || FLAG_log_gc || FLAG_log_handles || FLAG_log_suspect | 1511 || FLAG_log_code || FLAG_log_gc || FLAG_log_handles || FLAG_log_suspect |
| 1462 || FLAG_log_regexp || FLAG_log_state_changes; | 1512 || FLAG_log_regexp || FLAG_log_state_changes; |
| 1463 | 1513 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1505 } | 1555 } |
| 1506 SmartPointer<const char> expanded = stream.ToCString(); | 1556 SmartPointer<const char> expanded = stream.ToCString(); |
| 1507 Log::OpenFile(*expanded); | 1557 Log::OpenFile(*expanded); |
| 1508 } else { | 1558 } else { |
| 1509 Log::OpenFile(FLAG_logfile); | 1559 Log::OpenFile(FLAG_logfile); |
| 1510 } | 1560 } |
| 1511 } | 1561 } |
| 1512 | 1562 |
| 1513 ASSERT(VMState::is_outermost_external()); | 1563 ASSERT(VMState::is_outermost_external()); |
| 1514 | 1564 |
| 1565 if (FLAG_ll_prof) LogCodeInfo(); |
| 1566 |
| 1515 ticker_ = new Ticker(kSamplingIntervalMs); | 1567 ticker_ = new Ticker(kSamplingIntervalMs); |
| 1516 | 1568 |
| 1517 if (FLAG_sliding_state_window && sliding_state_window_ == NULL) { | 1569 if (FLAG_sliding_state_window && sliding_state_window_ == NULL) { |
| 1518 sliding_state_window_ = new SlidingStateWindow(); | 1570 sliding_state_window_ = new SlidingStateWindow(); |
| 1519 } | 1571 } |
| 1520 | 1572 |
| 1521 log_events_ = FLAG_compress_log ? | 1573 log_events_ = FLAG_compress_log ? |
| 1522 kCompressedLogEventsNames : kLongLogEventsNames; | 1574 kCompressedLogEventsNames : kLongLogEventsNames; |
| 1523 if (FLAG_compress_log) { | 1575 if (FLAG_compress_log) { |
| 1524 compression_helper_ = new CompressionHelper(kCompressionWindowSize); | 1576 compression_helper_ = new CompressionHelper(kCompressionWindowSize); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 } | 1639 } |
| 1588 // Otherwise, if the sliding state window computation has not been | 1640 // Otherwise, if the sliding state window computation has not been |
| 1589 // started we do it now. | 1641 // started we do it now. |
| 1590 if (sliding_state_window_ == NULL) { | 1642 if (sliding_state_window_ == NULL) { |
| 1591 sliding_state_window_ = new SlidingStateWindow(); | 1643 sliding_state_window_ = new SlidingStateWindow(); |
| 1592 } | 1644 } |
| 1593 #endif | 1645 #endif |
| 1594 } | 1646 } |
| 1595 | 1647 |
| 1596 } } // namespace v8::internal | 1648 } } // namespace v8::internal |
| OLD | NEW |