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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 #ifdef ENABLE_LOGGING_AND_PROFILING | 704 #ifdef ENABLE_LOGGING_AND_PROFILING |
705 if (logfile_ == NULL || !FLAG_log) return; | 705 if (logfile_ == NULL || !FLAG_log) return; |
706 LogMessageBuilder msg; | 706 LogMessageBuilder msg; |
707 msg.Append("delete,%s,0x%x\n", name, | 707 msg.Append("delete,%s,0x%x\n", name, |
708 reinterpret_cast<unsigned int>(object)); | 708 reinterpret_cast<unsigned int>(object)); |
709 msg.WriteToLogFile(); | 709 msg.WriteToLogFile(); |
710 #endif | 710 #endif |
711 } | 711 } |
712 | 712 |
713 | 713 |
714 #ifdef ENABLE_LOGGING_AND_PROFILING | |
715 int Logger::CodeObjectSize(Code* code) { | |
716 // Check that the assumptions about the layout of the code object holds. | |
717 ASSERT_EQ(reinterpret_cast<unsigned int>(code->instruction_start()) - | |
718 reinterpret_cast<unsigned int>(code->address()), | |
719 Code::kHeaderSize); | |
720 return code->instruction_size() + Code::kHeaderSize; | |
721 } | |
722 #endif | |
723 | |
724 | |
725 void Logger::CodeCreateEvent(const char* tag, Code* code, const char* comment) { | 714 void Logger::CodeCreateEvent(const char* tag, Code* code, const char* comment) { |
726 #ifdef ENABLE_LOGGING_AND_PROFILING | 715 #ifdef ENABLE_LOGGING_AND_PROFILING |
727 if (logfile_ == NULL || !FLAG_log_code) return; | 716 if (logfile_ == NULL || !FLAG_log_code) return; |
728 LogMessageBuilder msg; | 717 LogMessageBuilder msg; |
729 msg.Append("code-creation,%s,0x%x,%d,\"", tag, | 718 msg.Append("code-creation,%s,0x%x,%d,\"", tag, |
730 reinterpret_cast<unsigned int>(code->address()), | 719 reinterpret_cast<unsigned int>(code->address()), |
731 CodeObjectSize(code)); | 720 code->ExecutableSize()); |
732 for (const char* p = comment; *p != '\0'; p++) { | 721 for (const char* p = comment; *p != '\0'; p++) { |
733 if (*p == '"') { | 722 if (*p == '"') { |
734 msg.Append('\\'); | 723 msg.Append('\\'); |
735 } | 724 } |
736 msg.Append(*p); | 725 msg.Append(*p); |
737 } | 726 } |
738 msg.Append('"'); | 727 msg.Append('"'); |
739 msg.Append('\n'); | 728 msg.Append('\n'); |
740 msg.WriteToLogFile(); | 729 msg.WriteToLogFile(); |
741 #endif | 730 #endif |
742 } | 731 } |
743 | 732 |
744 | 733 |
745 void Logger::CodeCreateEvent(const char* tag, Code* code, String* name) { | 734 void Logger::CodeCreateEvent(const char* tag, Code* code, String* name) { |
746 #ifdef ENABLE_LOGGING_AND_PROFILING | 735 #ifdef ENABLE_LOGGING_AND_PROFILING |
747 if (logfile_ == NULL || !FLAG_log_code) return; | 736 if (logfile_ == NULL || !FLAG_log_code) return; |
748 LogMessageBuilder msg; | 737 LogMessageBuilder msg; |
749 SmartPointer<char> str = | 738 SmartPointer<char> str = |
750 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 739 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
751 msg.Append("code-creation,%s,0x%x,%d,\"%s\"\n", tag, | 740 msg.Append("code-creation,%s,0x%x,%d,\"%s\"\n", tag, |
752 reinterpret_cast<unsigned int>(code->address()), | 741 reinterpret_cast<unsigned int>(code->address()), |
753 CodeObjectSize(code), *str); | 742 code->ExecutableSize(), *str); |
754 msg.WriteToLogFile(); | 743 msg.WriteToLogFile(); |
755 #endif | 744 #endif |
756 } | 745 } |
757 | 746 |
758 | 747 |
759 void Logger::CodeCreateEvent(const char* tag, Code* code, String* name, | 748 void Logger::CodeCreateEvent(const char* tag, Code* code, String* name, |
760 String* source, int line) { | 749 String* source, int line) { |
761 #ifdef ENABLE_LOGGING_AND_PROFILING | 750 #ifdef ENABLE_LOGGING_AND_PROFILING |
762 if (logfile_ == NULL || !FLAG_log_code) return; | 751 if (logfile_ == NULL || !FLAG_log_code) return; |
763 LogMessageBuilder msg; | 752 LogMessageBuilder msg; |
764 SmartPointer<char> str = | 753 SmartPointer<char> str = |
765 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 754 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
766 SmartPointer<char> sourcestr = | 755 SmartPointer<char> sourcestr = |
767 source->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 756 source->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
768 msg.Append("code-creation,%s,0x%x,%d,\"%s %s:%d\"\n", tag, | 757 msg.Append("code-creation,%s,0x%x,%d,\"%s %s:%d\"\n", tag, |
769 reinterpret_cast<unsigned int>(code->address()), | 758 reinterpret_cast<unsigned int>(code->address()), |
770 CodeObjectSize(code), | 759 code->ExecutableSize(), |
771 *str, *sourcestr, line); | 760 *str, *sourcestr, line); |
772 msg.WriteToLogFile(); | 761 msg.WriteToLogFile(); |
773 #endif | 762 #endif |
774 } | 763 } |
775 | 764 |
776 | 765 |
777 void Logger::CodeCreateEvent(const char* tag, Code* code, int args_count) { | 766 void Logger::CodeCreateEvent(const char* tag, Code* code, int args_count) { |
778 #ifdef ENABLE_LOGGING_AND_PROFILING | 767 #ifdef ENABLE_LOGGING_AND_PROFILING |
779 if (logfile_ == NULL || !FLAG_log_code) return; | 768 if (logfile_ == NULL || !FLAG_log_code) return; |
780 LogMessageBuilder msg; | 769 LogMessageBuilder msg; |
781 msg.Append("code-creation,%s,0x%x,%d,\"args_count: %d\"\n", tag, | 770 msg.Append("code-creation,%s,0x%x,%d,\"args_count: %d\"\n", tag, |
782 reinterpret_cast<unsigned int>(code->address()), | 771 reinterpret_cast<unsigned int>(code->address()), |
783 CodeObjectSize(code), | 772 code->ExecutableSize(), |
784 args_count); | 773 args_count); |
785 msg.WriteToLogFile(); | 774 msg.WriteToLogFile(); |
786 #endif | 775 #endif |
787 } | 776 } |
788 | 777 |
789 | 778 |
790 void Logger::CodeAllocateEvent(Code* code, Assembler* assem) { | 779 void Logger::CodeAllocateEvent(Code* code, Assembler* assem) { |
791 #ifdef ENABLE_LOGGING_AND_PROFILING | 780 #ifdef ENABLE_LOGGING_AND_PROFILING |
792 if (logfile_ == NULL || !FLAG_log_code) return; | 781 if (logfile_ == NULL || !FLAG_log_code) return; |
793 LogMessageBuilder msg; | 782 LogMessageBuilder msg; |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 if (FLAG_log_state_changes) { | 1151 if (FLAG_log_state_changes) { |
1163 LOG(UncheckedStringEvent("Leaving", StateToString(state_))); | 1152 LOG(UncheckedStringEvent("Leaving", StateToString(state_))); |
1164 if (previous_) { | 1153 if (previous_) { |
1165 LOG(UncheckedStringEvent("To", StateToString(previous_->state_))); | 1154 LOG(UncheckedStringEvent("To", StateToString(previous_->state_))); |
1166 } | 1155 } |
1167 } | 1156 } |
1168 } | 1157 } |
1169 #endif | 1158 #endif |
1170 | 1159 |
1171 } } // namespace v8::internal | 1160 } } // namespace v8::internal |
OLD | NEW |