Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 17 matching lines...) Expand all Loading... | |
| 28 #include <stdarg.h> | 28 #include <stdarg.h> |
| 29 | 29 |
| 30 #include "v8.h" | 30 #include "v8.h" |
| 31 | 31 |
| 32 #include "bootstrapper.h" | 32 #include "bootstrapper.h" |
| 33 #include "code-stubs.h" | 33 #include "code-stubs.h" |
| 34 #include "cpu-profiler.h" | 34 #include "cpu-profiler.h" |
| 35 #include "deoptimizer.h" | 35 #include "deoptimizer.h" |
| 36 #include "global-handles.h" | 36 #include "global-handles.h" |
| 37 #include "log.h" | 37 #include "log.h" |
| 38 #include "log-utils.h" | |
| 38 #include "macro-assembler.h" | 39 #include "macro-assembler.h" |
| 39 #include "platform.h" | 40 #include "platform.h" |
| 40 #include "runtime-profiler.h" | 41 #include "runtime-profiler.h" |
| 41 #include "serialize.h" | 42 #include "serialize.h" |
| 42 #include "string-stream.h" | 43 #include "string-stream.h" |
| 43 #include "vm-state-inl.h" | 44 #include "vm-state-inl.h" |
| 44 | 45 |
| 45 namespace v8 { | 46 namespace v8 { |
| 46 namespace internal { | 47 namespace internal { |
| 47 | 48 |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 582 | 583 |
| 583 #define DECLARE_EVENT(ignore1, name) name, | 584 #define DECLARE_EVENT(ignore1, name) name, |
| 584 static const char* const kLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = { | 585 static const char* const kLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = { |
| 585 LOG_EVENTS_AND_TAGS_LIST(DECLARE_EVENT) | 586 LOG_EVENTS_AND_TAGS_LIST(DECLARE_EVENT) |
| 586 }; | 587 }; |
| 587 #undef DECLARE_EVENT | 588 #undef DECLARE_EVENT |
| 588 | 589 |
| 589 | 590 |
| 590 void Logger::ProfilerBeginEvent() { | 591 void Logger::ProfilerBeginEvent() { |
| 591 if (!log_->IsEnabled()) return; | 592 if (!log_->IsEnabled()) return; |
| 592 LogMessageBuilder msg(this); | 593 Log::MessageBuilder msg(log_); |
| 593 msg.Append("profiler,\"begin\",%d\n", kSamplingIntervalMs); | 594 msg.Append("profiler,\"begin\",%d\n", kSamplingIntervalMs); |
| 594 msg.WriteToLogFile(); | 595 msg.WriteToLogFile(); |
| 595 } | 596 } |
| 596 | 597 |
| 597 | 598 |
| 598 void Logger::StringEvent(const char* name, const char* value) { | 599 void Logger::StringEvent(const char* name, const char* value) { |
| 599 if (FLAG_log) UncheckedStringEvent(name, value); | 600 if (FLAG_log) UncheckedStringEvent(name, value); |
| 600 } | 601 } |
| 601 | 602 |
| 602 | 603 |
| 603 void Logger::UncheckedStringEvent(const char* name, const char* value) { | 604 void Logger::UncheckedStringEvent(const char* name, const char* value) { |
| 604 if (!log_->IsEnabled()) return; | 605 if (!log_->IsEnabled()) return; |
| 605 LogMessageBuilder msg(this); | 606 Log::MessageBuilder msg(log_); |
| 606 msg.Append("%s,\"%s\"\n", name, value); | 607 msg.Append("%s,\"%s\"\n", name, value); |
| 607 msg.WriteToLogFile(); | 608 msg.WriteToLogFile(); |
| 608 } | 609 } |
| 609 | 610 |
| 610 | 611 |
| 611 void Logger::IntEvent(const char* name, int value) { | 612 void Logger::IntEvent(const char* name, int value) { |
| 612 if (FLAG_log) UncheckedIntEvent(name, value); | 613 if (FLAG_log) UncheckedIntEvent(name, value); |
| 613 } | 614 } |
| 614 | 615 |
| 615 | 616 |
| 616 void Logger::IntPtrTEvent(const char* name, intptr_t value) { | 617 void Logger::IntPtrTEvent(const char* name, intptr_t value) { |
| 617 if (FLAG_log) UncheckedIntPtrTEvent(name, value); | 618 if (FLAG_log) UncheckedIntPtrTEvent(name, value); |
| 618 } | 619 } |
| 619 | 620 |
| 620 | 621 |
| 621 void Logger::UncheckedIntEvent(const char* name, int value) { | 622 void Logger::UncheckedIntEvent(const char* name, int value) { |
| 622 if (!log_->IsEnabled()) return; | 623 if (!log_->IsEnabled()) return; |
| 623 LogMessageBuilder msg(this); | 624 Log::MessageBuilder msg(log_); |
| 624 msg.Append("%s,%d\n", name, value); | 625 msg.Append("%s,%d\n", name, value); |
| 625 msg.WriteToLogFile(); | 626 msg.WriteToLogFile(); |
| 626 } | 627 } |
| 627 | 628 |
| 628 | 629 |
| 629 void Logger::UncheckedIntPtrTEvent(const char* name, intptr_t value) { | 630 void Logger::UncheckedIntPtrTEvent(const char* name, intptr_t value) { |
| 630 if (!log_->IsEnabled()) return; | 631 if (!log_->IsEnabled()) return; |
| 631 LogMessageBuilder msg(this); | 632 Log::MessageBuilder msg(log_); |
| 632 msg.Append("%s,%" V8_PTR_PREFIX "d\n", name, value); | 633 msg.Append("%s,%" V8_PTR_PREFIX "d\n", name, value); |
| 633 msg.WriteToLogFile(); | 634 msg.WriteToLogFile(); |
| 634 } | 635 } |
| 635 | 636 |
| 636 | 637 |
| 637 void Logger::HandleEvent(const char* name, Object** location) { | 638 void Logger::HandleEvent(const char* name, Object** location) { |
| 638 if (!log_->IsEnabled() || !FLAG_log_handles) return; | 639 if (!log_->IsEnabled() || !FLAG_log_handles) return; |
| 639 LogMessageBuilder msg(this); | 640 Log::MessageBuilder msg(log_); |
| 640 msg.Append("%s,0x%" V8PRIxPTR "\n", name, location); | 641 msg.Append("%s,0x%" V8PRIxPTR "\n", name, location); |
| 641 msg.WriteToLogFile(); | 642 msg.WriteToLogFile(); |
| 642 } | 643 } |
| 643 | 644 |
| 644 | 645 |
| 645 // ApiEvent is private so all the calls come from the Logger class. It is the | 646 // ApiEvent is private so all the calls come from the Logger class. It is the |
| 646 // caller's responsibility to ensure that log is enabled and that | 647 // caller's responsibility to ensure that log is enabled and that |
| 647 // FLAG_log_api is true. | 648 // FLAG_log_api is true. |
| 648 void Logger::ApiEvent(const char* format, ...) { | 649 void Logger::ApiEvent(const char* format, ...) { |
| 649 ASSERT(log_->IsEnabled() && FLAG_log_api); | 650 ASSERT(log_->IsEnabled() && FLAG_log_api); |
| 650 LogMessageBuilder msg(this); | 651 Log::MessageBuilder msg(log_); |
| 651 va_list ap; | 652 va_list ap; |
| 652 va_start(ap, format); | 653 va_start(ap, format); |
| 653 msg.AppendVA(format, ap); | 654 msg.AppendVA(format, ap); |
| 654 va_end(ap); | 655 va_end(ap); |
| 655 msg.WriteToLogFile(); | 656 msg.WriteToLogFile(); |
| 656 } | 657 } |
| 657 | 658 |
| 658 | 659 |
| 659 void Logger::ApiNamedSecurityCheck(Object* key) { | 660 void Logger::ApiNamedSecurityCheck(Object* key) { |
| 660 if (!log_->IsEnabled() || !FLAG_log_api) return; | 661 if (!log_->IsEnabled() || !FLAG_log_api) return; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 679 } else { | 680 } else { |
| 680 ApiEvent("api,check-security,['no-name']\n"); | 681 ApiEvent("api,check-security,['no-name']\n"); |
| 681 } | 682 } |
| 682 } | 683 } |
| 683 | 684 |
| 684 | 685 |
| 685 void Logger::SharedLibraryEvent(const char* library_path, | 686 void Logger::SharedLibraryEvent(const char* library_path, |
| 686 uintptr_t start, | 687 uintptr_t start, |
| 687 uintptr_t end) { | 688 uintptr_t end) { |
| 688 if (!log_->IsEnabled() || !FLAG_prof) return; | 689 if (!log_->IsEnabled() || !FLAG_prof) return; |
| 689 LogMessageBuilder msg(this); | 690 Log::MessageBuilder msg(log_); |
| 690 msg.Append("shared-library,\"%s\",0x%08" V8PRIxPTR ",0x%08" V8PRIxPTR "\n", | 691 msg.Append("shared-library,\"%s\",0x%08" V8PRIxPTR ",0x%08" V8PRIxPTR "\n", |
| 691 library_path, | 692 library_path, |
| 692 start, | 693 start, |
| 693 end); | 694 end); |
| 694 msg.WriteToLogFile(); | 695 msg.WriteToLogFile(); |
| 695 } | 696 } |
| 696 | 697 |
| 697 | 698 |
| 698 void Logger::SharedLibraryEvent(const wchar_t* library_path, | 699 void Logger::SharedLibraryEvent(const wchar_t* library_path, |
| 699 uintptr_t start, | 700 uintptr_t start, |
| 700 uintptr_t end) { | 701 uintptr_t end) { |
| 701 if (!log_->IsEnabled() || !FLAG_prof) return; | 702 if (!log_->IsEnabled() || !FLAG_prof) return; |
| 702 LogMessageBuilder msg(this); | 703 Log::MessageBuilder msg(log_); |
| 703 msg.Append("shared-library,\"%ls\",0x%08" V8PRIxPTR ",0x%08" V8PRIxPTR "\n", | 704 msg.Append("shared-library,\"%ls\",0x%08" V8PRIxPTR ",0x%08" V8PRIxPTR "\n", |
| 704 library_path, | 705 library_path, |
| 705 start, | 706 start, |
| 706 end); | 707 end); |
| 707 msg.WriteToLogFile(); | 708 msg.WriteToLogFile(); |
| 708 } | 709 } |
| 709 | 710 |
| 710 | 711 |
| 711 void Logger::CodeDeoptEvent(Code* code) { | 712 void Logger::CodeDeoptEvent(Code* code) { |
| 712 if (!log_->IsEnabled()) return; | 713 if (!log_->IsEnabled()) return; |
| 713 ASSERT(FLAG_log_internal_timer_events); | 714 ASSERT(FLAG_log_internal_timer_events); |
| 714 LogMessageBuilder msg(this); | 715 Log::MessageBuilder msg(log_); |
| 715 int since_epoch = static_cast<int>(OS::Ticks() - epoch_); | 716 int since_epoch = static_cast<int>(OS::Ticks() - epoch_); |
| 716 msg.Append("code-deopt,%ld,%d\n", since_epoch, code->CodeSize()); | 717 msg.Append("code-deopt,%ld,%d\n", since_epoch, code->CodeSize()); |
| 717 msg.WriteToLogFile(); | 718 msg.WriteToLogFile(); |
| 718 } | 719 } |
| 719 | 720 |
| 720 | 721 |
| 721 void Logger::TimerEvent(StartEnd se, const char* name) { | 722 void Logger::TimerEvent(StartEnd se, const char* name) { |
| 722 if (!log_->IsEnabled()) return; | 723 if (!log_->IsEnabled()) return; |
| 723 ASSERT(FLAG_log_internal_timer_events); | 724 ASSERT(FLAG_log_internal_timer_events); |
| 724 LogMessageBuilder msg(this); | 725 Log::MessageBuilder msg(log_); |
| 725 int since_epoch = static_cast<int>(OS::Ticks() - epoch_); | 726 int since_epoch = static_cast<int>(OS::Ticks() - epoch_); |
| 726 const char* format = (se == START) ? "timer-event-start,\"%s\",%ld\n" | 727 const char* format = (se == START) ? "timer-event-start,\"%s\",%ld\n" |
| 727 : "timer-event-end,\"%s\",%ld\n"; | 728 : "timer-event-end,\"%s\",%ld\n"; |
| 728 msg.Append(format, name, since_epoch); | 729 msg.Append(format, name, since_epoch); |
| 729 msg.WriteToLogFile(); | 730 msg.WriteToLogFile(); |
| 730 } | 731 } |
| 731 | 732 |
| 732 | 733 |
| 733 void Logger::EnterExternal(Isolate* isolate) { | 734 void Logger::EnterExternal(Isolate* isolate) { |
| 734 LOG(isolate, TimerEvent(START, TimerEventScope::v8_external)); | 735 LOG(isolate, TimerEvent(START, TimerEventScope::v8_external)); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 755 "V8.RecompileParallel"; | 756 "V8.RecompileParallel"; |
| 756 const char* Logger::TimerEventScope::v8_compile_full_code = | 757 const char* Logger::TimerEventScope::v8_compile_full_code = |
| 757 "V8.CompileFullCode"; | 758 "V8.CompileFullCode"; |
| 758 const char* Logger::TimerEventScope::v8_execute = "V8.Execute"; | 759 const char* Logger::TimerEventScope::v8_execute = "V8.Execute"; |
| 759 const char* Logger::TimerEventScope::v8_external = "V8.External"; | 760 const char* Logger::TimerEventScope::v8_external = "V8.External"; |
| 760 | 761 |
| 761 | 762 |
| 762 void Logger::LogRegExpSource(Handle<JSRegExp> regexp) { | 763 void Logger::LogRegExpSource(Handle<JSRegExp> regexp) { |
| 763 // Prints "/" + re.source + "/" + | 764 // Prints "/" + re.source + "/" + |
| 764 // (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"") | 765 // (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"") |
| 765 LogMessageBuilder msg(this); | 766 Log::MessageBuilder msg(log_); |
| 766 | 767 |
| 767 Handle<Object> source = GetProperty(regexp, "source"); | 768 Handle<Object> source = GetProperty(regexp, "source"); |
| 768 if (!source->IsString()) { | 769 if (!source->IsString()) { |
| 769 msg.Append("no source"); | 770 msg.Append("no source"); |
| 770 return; | 771 return; |
| 771 } | 772 } |
| 772 | 773 |
| 773 switch (regexp->TypeTag()) { | 774 switch (regexp->TypeTag()) { |
| 774 case JSRegExp::ATOM: | 775 case JSRegExp::ATOM: |
| 775 msg.Append('a'); | 776 msg.Append('a'); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 796 if (multiline->IsTrue()) { | 797 if (multiline->IsTrue()) { |
| 797 msg.Append('m'); | 798 msg.Append('m'); |
| 798 } | 799 } |
| 799 | 800 |
| 800 msg.WriteToLogFile(); | 801 msg.WriteToLogFile(); |
| 801 } | 802 } |
| 802 | 803 |
| 803 | 804 |
| 804 void Logger::RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache) { | 805 void Logger::RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache) { |
| 805 if (!log_->IsEnabled() || !FLAG_log_regexp) return; | 806 if (!log_->IsEnabled() || !FLAG_log_regexp) return; |
| 806 LogMessageBuilder msg(this); | 807 Log::MessageBuilder msg(log_); |
| 807 msg.Append("regexp-compile,"); | 808 msg.Append("regexp-compile,"); |
| 808 LogRegExpSource(regexp); | 809 LogRegExpSource(regexp); |
| 809 msg.Append(in_cache ? ",hit\n" : ",miss\n"); | 810 msg.Append(in_cache ? ",hit\n" : ",miss\n"); |
| 810 msg.WriteToLogFile(); | 811 msg.WriteToLogFile(); |
| 811 } | 812 } |
| 812 | 813 |
| 813 | 814 |
| 814 void Logger::LogRuntime(Vector<const char> format, | 815 void Logger::LogRuntime(Vector<const char> format, |
| 815 JSArray* args) { | 816 JSArray* args) { |
| 816 if (!log_->IsEnabled() || !FLAG_log_runtime) return; | 817 if (!log_->IsEnabled() || !FLAG_log_runtime) return; |
| 817 HandleScope scope(isolate_); | 818 HandleScope scope(isolate_); |
| 818 LogMessageBuilder msg(this); | 819 Log::MessageBuilder msg(log_); |
| 819 for (int i = 0; i < format.length(); i++) { | 820 for (int i = 0; i < format.length(); i++) { |
| 820 char c = format[i]; | 821 char c = format[i]; |
| 821 if (c == '%' && i <= format.length() - 2) { | 822 if (c == '%' && i <= format.length() - 2) { |
| 822 i++; | 823 i++; |
| 823 ASSERT('0' <= format[i] && format[i] <= '9'); | 824 ASSERT('0' <= format[i] && format[i] <= '9'); |
| 824 MaybeObject* maybe = args->GetElement(format[i] - '0'); | 825 MaybeObject* maybe = args->GetElement(format[i] - '0'); |
| 825 Object* obj; | 826 Object* obj; |
| 826 if (!maybe->ToObject(&obj)) { | 827 if (!maybe->ToObject(&obj)) { |
| 827 msg.Append("<exception>"); | 828 msg.Append("<exception>"); |
| 828 continue; | 829 continue; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 909 | 910 |
| 910 | 911 |
| 911 void Logger::ApiEntryCall(const char* name) { | 912 void Logger::ApiEntryCall(const char* name) { |
| 912 if (!log_->IsEnabled() || !FLAG_log_api) return; | 913 if (!log_->IsEnabled() || !FLAG_log_api) return; |
| 913 ApiEvent("api,%s\n", name); | 914 ApiEvent("api,%s\n", name); |
| 914 } | 915 } |
| 915 | 916 |
| 916 | 917 |
| 917 void Logger::NewEvent(const char* name, void* object, size_t size) { | 918 void Logger::NewEvent(const char* name, void* object, size_t size) { |
| 918 if (!log_->IsEnabled() || !FLAG_log) return; | 919 if (!log_->IsEnabled() || !FLAG_log) return; |
| 919 LogMessageBuilder msg(this); | 920 Log::MessageBuilder msg(log_); |
| 920 msg.Append("new,%s,0x%" V8PRIxPTR ",%u\n", name, object, | 921 msg.Append("new,%s,0x%" V8PRIxPTR ",%u\n", name, object, |
| 921 static_cast<unsigned int>(size)); | 922 static_cast<unsigned int>(size)); |
| 922 msg.WriteToLogFile(); | 923 msg.WriteToLogFile(); |
| 923 } | 924 } |
| 924 | 925 |
| 925 | 926 |
| 926 void Logger::DeleteEvent(const char* name, void* object) { | 927 void Logger::DeleteEvent(const char* name, void* object) { |
| 927 if (!log_->IsEnabled() || !FLAG_log) return; | 928 if (!log_->IsEnabled() || !FLAG_log) return; |
| 928 LogMessageBuilder msg(this); | 929 Log::MessageBuilder msg(log_); |
| 929 msg.Append("delete,%s,0x%" V8PRIxPTR "\n", name, object); | 930 msg.Append("delete,%s,0x%" V8PRIxPTR "\n", name, object); |
| 930 msg.WriteToLogFile(); | 931 msg.WriteToLogFile(); |
| 931 } | 932 } |
| 932 | 933 |
| 933 | 934 |
| 934 void Logger::NewEventStatic(const char* name, void* object, size_t size) { | 935 void Logger::NewEventStatic(const char* name, void* object, size_t size) { |
| 935 Isolate::Current()->logger()->NewEvent(name, object, size); | 936 Isolate::Current()->logger()->NewEvent(name, object, size); |
| 936 } | 937 } |
| 937 | 938 |
| 938 | 939 |
| 939 void Logger::DeleteEventStatic(const char* name, void* object) { | 940 void Logger::DeleteEventStatic(const char* name, void* object) { |
| 940 Isolate::Current()->logger()->DeleteEvent(name, object); | 941 Isolate::Current()->logger()->DeleteEvent(name, object); |
| 941 } | 942 } |
| 942 | 943 |
| 944 | |
| 945 class CodeLogger { | |
|
yurys
2013/07/18 17:17:52
Delete this.
| |
| 946 public: | |
| 947 }; | |
| 948 | |
| 949 | |
| 943 void Logger::CallbackEventInternal(const char* prefix, Name* name, | 950 void Logger::CallbackEventInternal(const char* prefix, Name* name, |
| 944 Address entry_point) { | 951 Address entry_point) { |
| 945 if (!log_->IsEnabled() || !FLAG_log_code) return; | 952 if (!log_->IsEnabled() || !FLAG_log_code) return; |
| 946 LogMessageBuilder msg(this); | 953 Log::MessageBuilder msg(log_); |
| 947 msg.Append("%s,%s,-2,", | 954 msg.Append("%s,%s,-2,", |
| 948 kLogEventsNames[CODE_CREATION_EVENT], | 955 kLogEventsNames[CODE_CREATION_EVENT], |
| 949 kLogEventsNames[CALLBACK_TAG]); | 956 kLogEventsNames[CALLBACK_TAG]); |
| 950 msg.AppendAddress(entry_point); | 957 msg.AppendAddress(entry_point); |
| 951 if (name->IsString()) { | 958 if (name->IsString()) { |
| 952 SmartArrayPointer<char> str = | 959 SmartArrayPointer<char> str = |
| 953 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 960 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 954 msg.Append(",1,\"%s%s\"", prefix, *str); | 961 msg.Append(",1,\"%s%s\"", prefix, *str); |
| 955 } else { | 962 } else { |
| 956 Symbol* symbol = Symbol::cast(name); | 963 Symbol* symbol = Symbol::cast(name); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1016 JIT_LOG(CodeCreateEvent(code, script, name_buffer_->get(), | 1023 JIT_LOG(CodeCreateEvent(code, script, name_buffer_->get(), |
| 1017 name_buffer_->size())); | 1024 name_buffer_->size())); |
| 1018 if (!log_->IsEnabled()) return; | 1025 if (!log_->IsEnabled()) return; |
| 1019 LL_LOG(CodeCreateEvent(code, name_buffer_->get(), name_buffer_->size())); | 1026 LL_LOG(CodeCreateEvent(code, name_buffer_->get(), name_buffer_->size())); |
| 1020 if (Serializer::enabled()) { | 1027 if (Serializer::enabled()) { |
| 1021 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); | 1028 RegisterSnapshotCodeName(code, name_buffer_->get(), name_buffer_->size()); |
| 1022 } | 1029 } |
| 1023 } | 1030 } |
| 1024 | 1031 |
| 1025 | 1032 |
| 1026 void Logger::AppendCodeCreateHeader(LogMessageBuilder* msg, | 1033 static void AppendCodeCreateHeader(Log::MessageBuilder* msg, |
| 1027 LogEventsAndTags tag, | 1034 Logger::LogEventsAndTags tag, |
| 1028 Code* code) { | 1035 Code* code) { |
| 1029 ASSERT(msg); | 1036 ASSERT(msg); |
| 1030 msg->Append("%s,%s,%d,", | 1037 msg->Append("%s,%s,%d,", |
| 1031 kLogEventsNames[CODE_CREATION_EVENT], | 1038 kLogEventsNames[Logger::CODE_CREATION_EVENT], |
| 1032 kLogEventsNames[tag], | 1039 kLogEventsNames[tag], |
| 1033 code->kind()); | 1040 code->kind()); |
| 1034 msg->AppendAddress(code->address()); | 1041 msg->AppendAddress(code->address()); |
| 1035 msg->Append(",%d,", code->ExecutableSize()); | 1042 msg->Append(",%d,", code->ExecutableSize()); |
| 1036 } | 1043 } |
| 1037 | 1044 |
| 1038 | 1045 |
| 1039 void Logger::AppendSymbolName(LogMessageBuilder* msg, | |
| 1040 Symbol* symbol) { | |
| 1041 ASSERT(symbol); | |
| 1042 msg->Append("symbol("); | |
| 1043 if (!symbol->name()->IsUndefined()) { | |
| 1044 msg->Append("\""); | |
| 1045 msg->AppendDetailed(String::cast(symbol->name()), false); | |
| 1046 msg->Append("\" "); | |
| 1047 } | |
| 1048 msg->Append("hash %x)", symbol->Hash()); | |
| 1049 } | |
| 1050 | |
| 1051 | |
| 1052 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1046 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 1053 Code* code, | 1047 Code* code, |
| 1054 const char* comment) { | 1048 const char* comment) { |
| 1055 if (!is_logging_code_events()) return; | 1049 if (!is_logging_code_events()) return; |
| 1056 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) { | 1050 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) { |
| 1057 InitNameBuffer(tag); | 1051 InitNameBuffer(tag); |
| 1058 name_buffer_->AppendBytes(comment); | 1052 name_buffer_->AppendBytes(comment); |
| 1059 LogRecordedBuffer(code, NULL); | 1053 LogRecordedBuffer(code, NULL); |
| 1060 } | 1054 } |
| 1061 | 1055 |
| 1062 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1056 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1063 LogMessageBuilder msg(this); | 1057 Log::MessageBuilder msg(log_); |
| 1064 AppendCodeCreateHeader(&msg, tag, code); | 1058 AppendCodeCreateHeader(&msg, tag, code); |
| 1065 msg.AppendDoubleQuotedString(comment); | 1059 msg.AppendDoubleQuotedString(comment); |
| 1066 msg.Append('\n'); | 1060 msg.Append('\n'); |
| 1067 msg.WriteToLogFile(); | 1061 msg.WriteToLogFile(); |
| 1068 } | 1062 } |
| 1069 | 1063 |
| 1070 | 1064 |
| 1071 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1065 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 1072 Code* code, | 1066 Code* code, |
| 1073 Name* name) { | 1067 Name* name) { |
| 1074 if (!is_logging_code_events()) return; | 1068 if (!is_logging_code_events()) return; |
| 1075 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) { | 1069 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) { |
| 1076 InitNameBuffer(tag); | 1070 InitNameBuffer(tag); |
| 1077 AppendName(name); | 1071 AppendName(name); |
| 1078 LogRecordedBuffer(code, NULL); | 1072 LogRecordedBuffer(code, NULL); |
| 1079 } | 1073 } |
| 1080 | 1074 |
| 1081 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1075 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1082 LogMessageBuilder msg(this); | 1076 Log::MessageBuilder msg(log_); |
| 1083 AppendCodeCreateHeader(&msg, tag, code); | 1077 AppendCodeCreateHeader(&msg, tag, code); |
| 1084 if (name->IsString()) { | 1078 if (name->IsString()) { |
| 1085 msg.Append('"'); | 1079 msg.Append('"'); |
| 1086 msg.AppendDetailed(String::cast(name), false); | 1080 msg.AppendDetailed(String::cast(name), false); |
| 1087 msg.Append('"'); | 1081 msg.Append('"'); |
| 1088 } else { | 1082 } else { |
| 1089 AppendSymbolName(&msg, Symbol::cast(name)); | 1083 msg.AppendSymbolName(Symbol::cast(name)); |
| 1090 } | 1084 } |
| 1091 msg.Append('\n'); | 1085 msg.Append('\n'); |
| 1092 msg.WriteToLogFile(); | 1086 msg.WriteToLogFile(); |
| 1093 } | 1087 } |
| 1094 | 1088 |
| 1095 | 1089 |
| 1096 // ComputeMarker must only be used when SharedFunctionInfo is known. | 1090 // ComputeMarker must only be used when SharedFunctionInfo is known. |
| 1097 static const char* ComputeMarker(Code* code) { | 1091 static const char* ComputeMarker(Code* code) { |
| 1098 switch (code->kind()) { | 1092 switch (code->kind()) { |
| 1099 case Code::FUNCTION: return code->optimizable() ? "~" : ""; | 1093 case Code::FUNCTION: return code->optimizable() ? "~" : ""; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1114 name_buffer_->AppendBytes(ComputeMarker(code)); | 1108 name_buffer_->AppendBytes(ComputeMarker(code)); |
| 1115 AppendName(name); | 1109 AppendName(name); |
| 1116 LogRecordedBuffer(code, shared); | 1110 LogRecordedBuffer(code, shared); |
| 1117 } | 1111 } |
| 1118 | 1112 |
| 1119 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1113 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1120 if (code == isolate_->builtins()->builtin( | 1114 if (code == isolate_->builtins()->builtin( |
| 1121 Builtins::kLazyCompile)) | 1115 Builtins::kLazyCompile)) |
| 1122 return; | 1116 return; |
| 1123 | 1117 |
| 1124 LogMessageBuilder msg(this); | 1118 Log::MessageBuilder msg(log_); |
| 1125 AppendCodeCreateHeader(&msg, tag, code); | 1119 AppendCodeCreateHeader(&msg, tag, code); |
| 1126 if (name->IsString()) { | 1120 if (name->IsString()) { |
| 1127 SmartArrayPointer<char> str = | 1121 SmartArrayPointer<char> str = |
| 1128 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1122 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 1129 msg.Append("\"%s\"", *str); | 1123 msg.Append("\"%s\"", *str); |
| 1130 } else { | 1124 } else { |
| 1131 AppendSymbolName(&msg, Symbol::cast(name)); | 1125 msg.AppendSymbolName(Symbol::cast(name)); |
| 1132 } | 1126 } |
| 1133 msg.Append(','); | 1127 msg.Append(','); |
| 1134 msg.AppendAddress(shared->address()); | 1128 msg.AppendAddress(shared->address()); |
| 1135 msg.Append(",%s", ComputeMarker(code)); | 1129 msg.Append(",%s", ComputeMarker(code)); |
| 1136 msg.Append('\n'); | 1130 msg.Append('\n'); |
| 1137 msg.WriteToLogFile(); | 1131 msg.WriteToLogFile(); |
| 1138 } | 1132 } |
| 1139 | 1133 |
| 1140 | 1134 |
| 1141 // Although, it is possible to extract source and line from | 1135 // Although, it is possible to extract source and line from |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1158 name_buffer_->AppendBytes("symbol(hash "); | 1152 name_buffer_->AppendBytes("symbol(hash "); |
| 1159 name_buffer_->AppendHex(Name::cast(source)->Hash()); | 1153 name_buffer_->AppendHex(Name::cast(source)->Hash()); |
| 1160 name_buffer_->AppendByte(')'); | 1154 name_buffer_->AppendByte(')'); |
| 1161 } | 1155 } |
| 1162 name_buffer_->AppendByte(':'); | 1156 name_buffer_->AppendByte(':'); |
| 1163 name_buffer_->AppendInt(line); | 1157 name_buffer_->AppendInt(line); |
| 1164 LogRecordedBuffer(code, shared); | 1158 LogRecordedBuffer(code, shared); |
| 1165 } | 1159 } |
| 1166 | 1160 |
| 1167 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1161 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1168 LogMessageBuilder msg(this); | 1162 Log::MessageBuilder msg(log_); |
| 1169 AppendCodeCreateHeader(&msg, tag, code); | 1163 AppendCodeCreateHeader(&msg, tag, code); |
| 1170 SmartArrayPointer<char> name = | 1164 SmartArrayPointer<char> name = |
| 1171 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1165 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 1172 msg.Append("\"%s ", *name); | 1166 msg.Append("\"%s ", *name); |
| 1173 if (source->IsString()) { | 1167 if (source->IsString()) { |
| 1174 SmartArrayPointer<char> sourcestr = | 1168 SmartArrayPointer<char> sourcestr = |
| 1175 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1169 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 1176 msg.Append("%s", *sourcestr); | 1170 msg.Append("%s", *sourcestr); |
| 1177 } else { | 1171 } else { |
| 1178 AppendSymbolName(&msg, Symbol::cast(source)); | 1172 msg.AppendSymbolName(Symbol::cast(source)); |
| 1179 } | 1173 } |
| 1180 msg.Append(":%d\",", line); | 1174 msg.Append(":%d\",", line); |
| 1181 msg.AppendAddress(shared->address()); | 1175 msg.AppendAddress(shared->address()); |
| 1182 msg.Append(",%s", ComputeMarker(code)); | 1176 msg.Append(",%s", ComputeMarker(code)); |
| 1183 msg.Append('\n'); | 1177 msg.Append('\n'); |
| 1184 msg.WriteToLogFile(); | 1178 msg.WriteToLogFile(); |
| 1185 } | 1179 } |
| 1186 | 1180 |
| 1187 | 1181 |
| 1188 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) { | 1182 void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) { |
| 1189 if (!is_logging_code_events()) return; | 1183 if (!is_logging_code_events()) return; |
| 1190 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) { | 1184 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) { |
| 1191 InitNameBuffer(tag); | 1185 InitNameBuffer(tag); |
| 1192 name_buffer_->AppendInt(args_count); | 1186 name_buffer_->AppendInt(args_count); |
| 1193 LogRecordedBuffer(code, NULL); | 1187 LogRecordedBuffer(code, NULL); |
| 1194 } | 1188 } |
| 1195 | 1189 |
| 1196 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1190 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1197 LogMessageBuilder msg(this); | 1191 Log::MessageBuilder msg(log_); |
| 1198 AppendCodeCreateHeader(&msg, tag, code); | 1192 AppendCodeCreateHeader(&msg, tag, code); |
| 1199 msg.Append("\"args_count: %d\"", args_count); | 1193 msg.Append("\"args_count: %d\"", args_count); |
| 1200 msg.Append('\n'); | 1194 msg.Append('\n'); |
| 1201 msg.WriteToLogFile(); | 1195 msg.WriteToLogFile(); |
| 1202 } | 1196 } |
| 1203 | 1197 |
| 1204 | 1198 |
| 1205 void Logger::CodeMovingGCEvent() { | 1199 void Logger::CodeMovingGCEvent() { |
| 1206 if (!log_->IsEnabled() || !FLAG_ll_prof) return; | 1200 if (!log_->IsEnabled() || !FLAG_ll_prof) return; |
| 1207 LL_LOG(CodeMovingGCEvent()); | 1201 LL_LOG(CodeMovingGCEvent()); |
| 1208 OS::SignalCodeMovingGC(); | 1202 OS::SignalCodeMovingGC(); |
| 1209 } | 1203 } |
| 1210 | 1204 |
| 1211 | 1205 |
| 1212 void Logger::RegExpCodeCreateEvent(Code* code, String* source) { | 1206 void Logger::RegExpCodeCreateEvent(Code* code, String* source) { |
| 1213 if (!is_logging_code_events()) return; | 1207 if (!is_logging_code_events()) return; |
| 1214 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) { | 1208 if (FLAG_ll_prof || Serializer::enabled() || jit_logger_ != NULL) { |
| 1215 InitNameBuffer(REG_EXP_TAG); | 1209 InitNameBuffer(REG_EXP_TAG); |
| 1216 name_buffer_->AppendString(source); | 1210 name_buffer_->AppendString(source); |
| 1217 LogRecordedBuffer(code, NULL); | 1211 LogRecordedBuffer(code, NULL); |
| 1218 } | 1212 } |
| 1219 | 1213 |
| 1220 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1214 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1221 LogMessageBuilder msg(this); | 1215 Log::MessageBuilder msg(log_); |
| 1222 AppendCodeCreateHeader(&msg, REG_EXP_TAG, code); | 1216 AppendCodeCreateHeader(&msg, REG_EXP_TAG, code); |
| 1223 msg.Append('"'); | 1217 msg.Append('"'); |
| 1224 msg.AppendDetailed(source, false); | 1218 msg.AppendDetailed(source, false); |
| 1225 msg.Append('"'); | 1219 msg.Append('"'); |
| 1226 msg.Append('\n'); | 1220 msg.Append('\n'); |
| 1227 msg.WriteToLogFile(); | 1221 msg.WriteToLogFile(); |
| 1228 } | 1222 } |
| 1229 | 1223 |
| 1230 | 1224 |
| 1231 void Logger::CodeMoveEvent(Address from, Address to) { | 1225 void Logger::CodeMoveEvent(Address from, Address to) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1279 JIT_LOG(EndCodePosInfoEvent(code, jit_handler_data)); | 1273 JIT_LOG(EndCodePosInfoEvent(code, jit_handler_data)); |
| 1280 } | 1274 } |
| 1281 | 1275 |
| 1282 | 1276 |
| 1283 void Logger::SnapshotPositionEvent(Address addr, int pos) { | 1277 void Logger::SnapshotPositionEvent(Address addr, int pos) { |
| 1284 if (!log_->IsEnabled()) return; | 1278 if (!log_->IsEnabled()) return; |
| 1285 LL_LOG(SnapshotPositionEvent(addr, pos)); | 1279 LL_LOG(SnapshotPositionEvent(addr, pos)); |
| 1286 if (Serializer::enabled() && address_to_name_map_ != NULL) { | 1280 if (Serializer::enabled() && address_to_name_map_ != NULL) { |
| 1287 const char* code_name = address_to_name_map_->Lookup(addr); | 1281 const char* code_name = address_to_name_map_->Lookup(addr); |
| 1288 if (code_name == NULL) return; // Not a code object. | 1282 if (code_name == NULL) return; // Not a code object. |
| 1289 LogMessageBuilder msg(this); | 1283 Log::MessageBuilder msg(log_); |
| 1290 msg.Append("%s,%d,", kLogEventsNames[SNAPSHOT_CODE_NAME_EVENT], pos); | 1284 msg.Append("%s,%d,", kLogEventsNames[SNAPSHOT_CODE_NAME_EVENT], pos); |
| 1291 msg.AppendDoubleQuotedString(code_name); | 1285 msg.AppendDoubleQuotedString(code_name); |
| 1292 msg.Append("\n"); | 1286 msg.Append("\n"); |
| 1293 msg.WriteToLogFile(); | 1287 msg.WriteToLogFile(); |
| 1294 } | 1288 } |
| 1295 if (!FLAG_log_snapshot_positions) return; | 1289 if (!FLAG_log_snapshot_positions) return; |
| 1296 LogMessageBuilder msg(this); | 1290 Log::MessageBuilder msg(log_); |
| 1297 msg.Append("%s,", kLogEventsNames[SNAPSHOT_POSITION_EVENT]); | 1291 msg.Append("%s,", kLogEventsNames[SNAPSHOT_POSITION_EVENT]); |
| 1298 msg.AppendAddress(addr); | 1292 msg.AppendAddress(addr); |
| 1299 msg.Append(",%d", pos); | 1293 msg.Append(",%d", pos); |
| 1300 msg.Append('\n'); | 1294 msg.Append('\n'); |
| 1301 msg.WriteToLogFile(); | 1295 msg.WriteToLogFile(); |
| 1302 } | 1296 } |
| 1303 | 1297 |
| 1304 | 1298 |
| 1305 void Logger::SharedFunctionInfoMoveEvent(Address from, Address to) { | 1299 void Logger::SharedFunctionInfoMoveEvent(Address from, Address to) { |
| 1306 MoveEventInternal(SHARED_FUNC_MOVE_EVENT, from, to); | 1300 MoveEventInternal(SHARED_FUNC_MOVE_EVENT, from, to); |
| 1307 } | 1301 } |
| 1308 | 1302 |
| 1309 | 1303 |
| 1310 void Logger::MoveEventInternal(LogEventsAndTags event, | 1304 void Logger::MoveEventInternal(LogEventsAndTags event, |
| 1311 Address from, | 1305 Address from, |
| 1312 Address to) { | 1306 Address to) { |
| 1313 if (!log_->IsEnabled() || !FLAG_log_code) return; | 1307 if (!log_->IsEnabled() || !FLAG_log_code) return; |
| 1314 LogMessageBuilder msg(this); | 1308 Log::MessageBuilder msg(log_); |
| 1315 msg.Append("%s,", kLogEventsNames[event]); | 1309 msg.Append("%s,", kLogEventsNames[event]); |
| 1316 msg.AppendAddress(from); | 1310 msg.AppendAddress(from); |
| 1317 msg.Append(','); | 1311 msg.Append(','); |
| 1318 msg.AppendAddress(to); | 1312 msg.AppendAddress(to); |
| 1319 msg.Append('\n'); | 1313 msg.Append('\n'); |
| 1320 msg.WriteToLogFile(); | 1314 msg.WriteToLogFile(); |
| 1321 } | 1315 } |
| 1322 | 1316 |
| 1323 | 1317 |
| 1324 void Logger::DeleteEventInternal(LogEventsAndTags event, Address from) { | 1318 void Logger::DeleteEventInternal(LogEventsAndTags event, Address from) { |
| 1325 if (!log_->IsEnabled() || !FLAG_log_code) return; | 1319 if (!log_->IsEnabled() || !FLAG_log_code) return; |
| 1326 LogMessageBuilder msg(this); | 1320 Log::MessageBuilder msg(log_); |
| 1327 msg.Append("%s,", kLogEventsNames[event]); | 1321 msg.Append("%s,", kLogEventsNames[event]); |
| 1328 msg.AppendAddress(from); | 1322 msg.AppendAddress(from); |
| 1329 msg.Append('\n'); | 1323 msg.Append('\n'); |
| 1330 msg.WriteToLogFile(); | 1324 msg.WriteToLogFile(); |
| 1331 } | 1325 } |
| 1332 | 1326 |
| 1333 | 1327 |
| 1334 void Logger::ResourceEvent(const char* name, const char* tag) { | 1328 void Logger::ResourceEvent(const char* name, const char* tag) { |
| 1335 if (!log_->IsEnabled() || !FLAG_log) return; | 1329 if (!log_->IsEnabled() || !FLAG_log) return; |
| 1336 LogMessageBuilder msg(this); | 1330 Log::MessageBuilder msg(log_); |
| 1337 msg.Append("%s,%s,", name, tag); | 1331 msg.Append("%s,%s,", name, tag); |
| 1338 | 1332 |
| 1339 uint32_t sec, usec; | 1333 uint32_t sec, usec; |
| 1340 if (OS::GetUserTime(&sec, &usec) != -1) { | 1334 if (OS::GetUserTime(&sec, &usec) != -1) { |
| 1341 msg.Append("%d,%d,", sec, usec); | 1335 msg.Append("%d,%d,", sec, usec); |
| 1342 } | 1336 } |
| 1343 msg.Append("%.0f", OS::TimeCurrentMillis()); | 1337 msg.Append("%.0f", OS::TimeCurrentMillis()); |
| 1344 | 1338 |
| 1345 msg.Append('\n'); | 1339 msg.Append('\n'); |
| 1346 msg.WriteToLogFile(); | 1340 msg.WriteToLogFile(); |
| 1347 } | 1341 } |
| 1348 | 1342 |
| 1349 | 1343 |
| 1350 void Logger::SuspectReadEvent(Name* name, Object* obj) { | 1344 void Logger::SuspectReadEvent(Name* name, Object* obj) { |
| 1351 if (!log_->IsEnabled() || !FLAG_log_suspect) return; | 1345 if (!log_->IsEnabled() || !FLAG_log_suspect) return; |
| 1352 LogMessageBuilder msg(this); | 1346 Log::MessageBuilder msg(log_); |
| 1353 String* class_name = obj->IsJSObject() | 1347 String* class_name = obj->IsJSObject() |
| 1354 ? JSObject::cast(obj)->class_name() | 1348 ? JSObject::cast(obj)->class_name() |
| 1355 : isolate_->heap()->empty_string(); | 1349 : isolate_->heap()->empty_string(); |
| 1356 msg.Append("suspect-read,"); | 1350 msg.Append("suspect-read,"); |
| 1357 msg.Append(class_name); | 1351 msg.Append(class_name); |
| 1358 msg.Append(','); | 1352 msg.Append(','); |
| 1359 if (name->IsString()) { | 1353 if (name->IsString()) { |
| 1360 msg.Append('"'); | 1354 msg.Append('"'); |
| 1361 msg.Append(String::cast(name)); | 1355 msg.Append(String::cast(name)); |
| 1362 msg.Append('"'); | 1356 msg.Append('"'); |
| 1363 } else { | 1357 } else { |
| 1364 AppendSymbolName(&msg, Symbol::cast(name)); | 1358 msg.AppendSymbolName(Symbol::cast(name)); |
| 1365 } | 1359 } |
| 1366 msg.Append('\n'); | 1360 msg.Append('\n'); |
| 1367 msg.WriteToLogFile(); | 1361 msg.WriteToLogFile(); |
| 1368 } | 1362 } |
| 1369 | 1363 |
| 1370 | 1364 |
| 1371 void Logger::HeapSampleBeginEvent(const char* space, const char* kind) { | 1365 void Logger::HeapSampleBeginEvent(const char* space, const char* kind) { |
| 1372 if (!log_->IsEnabled() || !FLAG_log_gc) return; | 1366 if (!log_->IsEnabled() || !FLAG_log_gc) return; |
| 1373 LogMessageBuilder msg(this); | 1367 Log::MessageBuilder msg(log_); |
| 1374 // Using non-relative system time in order to be able to synchronize with | 1368 // Using non-relative system time in order to be able to synchronize with |
| 1375 // external memory profiling events (e.g. DOM memory size). | 1369 // external memory profiling events (e.g. DOM memory size). |
| 1376 msg.Append("heap-sample-begin,\"%s\",\"%s\",%.0f\n", | 1370 msg.Append("heap-sample-begin,\"%s\",\"%s\",%.0f\n", |
| 1377 space, kind, OS::TimeCurrentMillis()); | 1371 space, kind, OS::TimeCurrentMillis()); |
| 1378 msg.WriteToLogFile(); | 1372 msg.WriteToLogFile(); |
| 1379 } | 1373 } |
| 1380 | 1374 |
| 1381 | 1375 |
| 1382 void Logger::HeapSampleEndEvent(const char* space, const char* kind) { | 1376 void Logger::HeapSampleEndEvent(const char* space, const char* kind) { |
| 1383 if (!log_->IsEnabled() || !FLAG_log_gc) return; | 1377 if (!log_->IsEnabled() || !FLAG_log_gc) return; |
| 1384 LogMessageBuilder msg(this); | 1378 Log::MessageBuilder msg(log_); |
| 1385 msg.Append("heap-sample-end,\"%s\",\"%s\"\n", space, kind); | 1379 msg.Append("heap-sample-end,\"%s\",\"%s\"\n", space, kind); |
| 1386 msg.WriteToLogFile(); | 1380 msg.WriteToLogFile(); |
| 1387 } | 1381 } |
| 1388 | 1382 |
| 1389 | 1383 |
| 1390 void Logger::HeapSampleItemEvent(const char* type, int number, int bytes) { | 1384 void Logger::HeapSampleItemEvent(const char* type, int number, int bytes) { |
| 1391 if (!log_->IsEnabled() || !FLAG_log_gc) return; | 1385 if (!log_->IsEnabled() || !FLAG_log_gc) return; |
| 1392 LogMessageBuilder msg(this); | 1386 Log::MessageBuilder msg(log_); |
| 1393 msg.Append("heap-sample-item,%s,%d,%d\n", type, number, bytes); | 1387 msg.Append("heap-sample-item,%s,%d,%d\n", type, number, bytes); |
| 1394 msg.WriteToLogFile(); | 1388 msg.WriteToLogFile(); |
| 1395 } | 1389 } |
| 1396 | 1390 |
| 1397 | 1391 |
| 1398 void Logger::DebugTag(const char* call_site_tag) { | 1392 void Logger::DebugTag(const char* call_site_tag) { |
| 1399 if (!log_->IsEnabled() || !FLAG_log) return; | 1393 if (!log_->IsEnabled() || !FLAG_log) return; |
| 1400 LogMessageBuilder msg(this); | 1394 Log::MessageBuilder msg(log_); |
| 1401 msg.Append("debug-tag,%s\n", call_site_tag); | 1395 msg.Append("debug-tag,%s\n", call_site_tag); |
| 1402 msg.WriteToLogFile(); | 1396 msg.WriteToLogFile(); |
| 1403 } | 1397 } |
| 1404 | 1398 |
| 1405 | 1399 |
| 1406 void Logger::DebugEvent(const char* event_type, Vector<uint16_t> parameter) { | 1400 void Logger::DebugEvent(const char* event_type, Vector<uint16_t> parameter) { |
| 1407 if (!log_->IsEnabled() || !FLAG_log) return; | 1401 if (!log_->IsEnabled() || !FLAG_log) return; |
| 1408 StringBuilder s(parameter.length() + 1); | 1402 StringBuilder s(parameter.length() + 1); |
| 1409 for (int i = 0; i < parameter.length(); ++i) { | 1403 for (int i = 0; i < parameter.length(); ++i) { |
| 1410 s.AddCharacter(static_cast<char>(parameter[i])); | 1404 s.AddCharacter(static_cast<char>(parameter[i])); |
| 1411 } | 1405 } |
| 1412 char* parameter_string = s.Finalize(); | 1406 char* parameter_string = s.Finalize(); |
| 1413 LogMessageBuilder msg(this); | 1407 Log::MessageBuilder msg(log_); |
| 1414 msg.Append("debug-queue-event,%s,%15.3f,%s\n", | 1408 msg.Append("debug-queue-event,%s,%15.3f,%s\n", |
| 1415 event_type, | 1409 event_type, |
| 1416 OS::TimeCurrentMillis(), | 1410 OS::TimeCurrentMillis(), |
| 1417 parameter_string); | 1411 parameter_string); |
| 1418 DeleteArray(parameter_string); | 1412 DeleteArray(parameter_string); |
| 1419 msg.WriteToLogFile(); | 1413 msg.WriteToLogFile(); |
| 1420 } | 1414 } |
| 1421 | 1415 |
| 1422 | 1416 |
| 1423 void Logger::TickEvent(TickSample* sample, bool overflow) { | 1417 void Logger::TickEvent(TickSample* sample, bool overflow) { |
| 1424 if (!log_->IsEnabled() || !FLAG_prof) return; | 1418 if (!log_->IsEnabled() || !FLAG_prof) return; |
| 1425 LogMessageBuilder msg(this); | 1419 Log::MessageBuilder msg(log_); |
| 1426 msg.Append("%s,", kLogEventsNames[TICK_EVENT]); | 1420 msg.Append("%s,", kLogEventsNames[TICK_EVENT]); |
| 1427 msg.AppendAddress(sample->pc); | 1421 msg.AppendAddress(sample->pc); |
| 1428 msg.Append(",%ld", static_cast<int>(OS::Ticks() - epoch_)); | 1422 msg.Append(",%ld", static_cast<int>(OS::Ticks() - epoch_)); |
| 1429 if (sample->has_external_callback) { | 1423 if (sample->has_external_callback) { |
| 1430 msg.Append(",1,"); | 1424 msg.Append(",1,"); |
| 1431 msg.AppendAddress(sample->external_callback); | 1425 msg.AppendAddress(sample->external_callback); |
| 1432 } else { | 1426 } else { |
| 1433 msg.Append(",0,"); | 1427 msg.Append(",0,"); |
| 1434 msg.AppendAddress(sample->tos); | 1428 msg.AppendAddress(sample->tos); |
| 1435 } | 1429 } |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1971 | 1965 |
| 1972 if (jit_logger_) { | 1966 if (jit_logger_) { |
| 1973 delete jit_logger_; | 1967 delete jit_logger_; |
| 1974 jit_logger_ = NULL; | 1968 jit_logger_ = NULL; |
| 1975 } | 1969 } |
| 1976 | 1970 |
| 1977 return log_->Close(); | 1971 return log_->Close(); |
| 1978 } | 1972 } |
| 1979 | 1973 |
| 1980 } } // namespace v8::internal | 1974 } } // namespace v8::internal |
| OLD | NEW |