OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 #ifdef ENABLE_LOGGING_AND_PROFILING | 672 #ifdef ENABLE_LOGGING_AND_PROFILING |
673 if (logfile_ == NULL || !FLAG_log) return; | 673 if (logfile_ == NULL || !FLAG_log) return; |
674 LogMessageBuilder msg; | 674 LogMessageBuilder msg; |
675 msg.Append("delete,%s,0x%x\n", name, | 675 msg.Append("delete,%s,0x%x\n", name, |
676 reinterpret_cast<unsigned int>(object)); | 676 reinterpret_cast<unsigned int>(object)); |
677 msg.WriteToLogFile(); | 677 msg.WriteToLogFile(); |
678 #endif | 678 #endif |
679 } | 679 } |
680 | 680 |
681 | 681 |
| 682 int Logger::CodeObjectSize(Code* code) { |
| 683 // Check that the assumptions about the layout of the code object holds. |
| 684 ASSERT_EQ(reinterpret_cast<unsigned int>(code->instruction_start()) - |
| 685 reinterpret_cast<unsigned int>(code->address()), |
| 686 Code::kHeaderSize); |
| 687 return code->instruction_size() + Code::kHeaderSize; |
| 688 } |
| 689 |
| 690 |
682 void Logger::CodeCreateEvent(const char* tag, Code* code, const char* comment) { | 691 void Logger::CodeCreateEvent(const char* tag, Code* code, const char* comment) { |
683 #ifdef ENABLE_LOGGING_AND_PROFILING | 692 #ifdef ENABLE_LOGGING_AND_PROFILING |
684 if (logfile_ == NULL || !FLAG_log_code) return; | 693 if (logfile_ == NULL || !FLAG_log_code) return; |
685 LogMessageBuilder msg; | 694 LogMessageBuilder msg; |
686 msg.Append("code-creation,%s,0x%x,%d,\"", tag, | 695 msg.Append("code-creation,%s,0x%x,%d,\"", tag, |
687 reinterpret_cast<unsigned int>(code->address()), | 696 reinterpret_cast<unsigned int>(code->address()), |
688 code->instruction_size()); | 697 CodeObjectSize(code)); |
689 for (const char* p = comment; *p != '\0'; p++) { | 698 for (const char* p = comment; *p != '\0'; p++) { |
690 if (*p == '"') { | 699 if (*p == '"') { |
691 msg.Append('\\'); | 700 msg.Append('\\'); |
692 } | 701 } |
693 msg.Append(*p); | 702 msg.Append(*p); |
694 } | 703 } |
695 msg.Append('"'); | 704 msg.Append('"'); |
696 msg.Append('\n'); | 705 msg.Append('\n'); |
697 msg.WriteToLogFile(); | 706 msg.WriteToLogFile(); |
698 #endif | 707 #endif |
699 } | 708 } |
700 | 709 |
701 | 710 |
702 void Logger::CodeCreateEvent(const char* tag, Code* code, String* name) { | 711 void Logger::CodeCreateEvent(const char* tag, Code* code, String* name) { |
703 #ifdef ENABLE_LOGGING_AND_PROFILING | 712 #ifdef ENABLE_LOGGING_AND_PROFILING |
704 if (logfile_ == NULL || !FLAG_log_code) return; | 713 if (logfile_ == NULL || !FLAG_log_code) return; |
705 LogMessageBuilder msg; | 714 LogMessageBuilder msg; |
706 SmartPointer<char> str = | 715 SmartPointer<char> str = |
707 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 716 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
708 msg.Append("code-creation,%s,0x%x,%d,\"%s\"\n", tag, | 717 msg.Append("code-creation,%s,0x%x,%d,\"%s\"\n", tag, |
709 reinterpret_cast<unsigned int>(code->address()), | 718 reinterpret_cast<unsigned int>(code->address()), |
710 code->instruction_size(), *str); | 719 CodeObjectSize(code), *str); |
711 msg.WriteToLogFile(); | 720 msg.WriteToLogFile(); |
712 #endif | 721 #endif |
713 } | 722 } |
714 | 723 |
715 | 724 |
716 void Logger::CodeCreateEvent(const char* tag, Code* code, String* name, | 725 void Logger::CodeCreateEvent(const char* tag, Code* code, String* name, |
717 String* source, int line) { | 726 String* source, int line) { |
718 #ifdef ENABLE_LOGGING_AND_PROFILING | 727 #ifdef ENABLE_LOGGING_AND_PROFILING |
719 if (logfile_ == NULL || !FLAG_log_code) return; | 728 if (logfile_ == NULL || !FLAG_log_code) return; |
720 LogMessageBuilder msg; | 729 LogMessageBuilder msg; |
721 SmartPointer<char> str = | 730 SmartPointer<char> str = |
722 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 731 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
723 SmartPointer<char> sourcestr = | 732 SmartPointer<char> sourcestr = |
724 source->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 733 source->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
725 msg.Append("code-creation,%s,0x%x,%d,\"%s %s:%d\"\n", tag, | 734 msg.Append("code-creation,%s,0x%x,%d,\"%s %s:%d\"\n", tag, |
726 reinterpret_cast<unsigned int>(code->address()), | 735 reinterpret_cast<unsigned int>(code->address()), |
727 code->instruction_size(), *str, *sourcestr, line); | 736 CodeObjectSize(code), |
| 737 *str, *sourcestr, line); |
728 msg.WriteToLogFile(); | 738 msg.WriteToLogFile(); |
729 #endif | 739 #endif |
730 } | 740 } |
731 | 741 |
732 | 742 |
733 void Logger::CodeCreateEvent(const char* tag, Code* code, int args_count) { | 743 void Logger::CodeCreateEvent(const char* tag, Code* code, int args_count) { |
734 #ifdef ENABLE_LOGGING_AND_PROFILING | 744 #ifdef ENABLE_LOGGING_AND_PROFILING |
735 if (logfile_ == NULL || !FLAG_log_code) return; | 745 if (logfile_ == NULL || !FLAG_log_code) return; |
736 LogMessageBuilder msg; | 746 LogMessageBuilder msg; |
737 msg.Append("code-creation,%s,0x%x,%d,\"args_count: %d\"\n", tag, | 747 msg.Append("code-creation,%s,0x%x,%d,\"args_count: %d\"\n", tag, |
738 reinterpret_cast<unsigned int>(code->address()), | 748 reinterpret_cast<unsigned int>(code->address()), |
739 code->instruction_size(), | 749 CodeObjectSize(code), |
740 args_count); | 750 args_count); |
741 msg.WriteToLogFile(); | 751 msg.WriteToLogFile(); |
742 #endif | 752 #endif |
743 } | 753 } |
744 | 754 |
745 | 755 |
746 void Logger::CodeAllocateEvent(Code* code, Assembler* assem) { | 756 void Logger::CodeAllocateEvent(Code* code, Assembler* assem) { |
747 #ifdef ENABLE_LOGGING_AND_PROFILING | 757 #ifdef ENABLE_LOGGING_AND_PROFILING |
748 if (logfile_ == NULL || !FLAG_log_code) return; | 758 if (logfile_ == NULL || !FLAG_log_code) return; |
749 LogMessageBuilder msg; | 759 LogMessageBuilder msg; |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 if (FLAG_log_state_changes) { | 1128 if (FLAG_log_state_changes) { |
1119 LOG(UncheckedStringEvent("Leaving", StateToString(state_))); | 1129 LOG(UncheckedStringEvent("Leaving", StateToString(state_))); |
1120 if (previous_) { | 1130 if (previous_) { |
1121 LOG(UncheckedStringEvent("To", StateToString(previous_->state_))); | 1131 LOG(UncheckedStringEvent("To", StateToString(previous_->state_))); |
1122 } | 1132 } |
1123 } | 1133 } |
1124 } | 1134 } |
1125 #endif | 1135 #endif |
1126 | 1136 |
1127 } } // namespace v8::internal | 1137 } } // namespace v8::internal |
OLD | NEW |