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

Side by Side Diff: src/log.cc

Issue 40290: Experimental: Merge 1395:1441 from bleeding_edge branch to the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/global/
Patch Set: Created 11 years, 9 months 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/macro-assembler-ia32.cc » ('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 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 static bool paused_; 130 static bool paused_;
131 }; 131 };
132 132
133 bool Profiler::paused_ = false; 133 bool Profiler::paused_ = false;
134 134
135 135
136 // 136 //
137 // StackTracer implementation 137 // StackTracer implementation
138 // 138 //
139 void StackTracer::Trace(TickSample* sample) { 139 void StackTracer::Trace(TickSample* sample) {
140 // Assuming that stack grows from lower addresses 140 if (sample->state == GC) {
141 if (sample->state != GC 141 sample->frames_count = 0;
142 && (sample->sp < sample->fp && sample->fp < low_stack_bound_)) { 142 return;
143 sample->InitStack(1); 143 }
144
145 // If c_entry_fp is available, this means that we are inside a C++
146 // function and sample->fp value isn't reliable due to FPO.
147 if (Top::c_entry_fp(Top::GetCurrentThread()) != NULL) {
148 SafeStackTraceFrameIterator it(
149 reinterpret_cast<Address>(sample->sp),
150 reinterpret_cast<Address>(low_stack_bound_));
151 int i = 0;
152 while (!it.done() && i < TickSample::kMaxFramesCount) {
153 sample->stack[i++] = it.frame()->pc();
154 it.Advance();
155 }
156 sample->frames_count = i;
157 } else if (sample->sp < sample->fp && sample->fp < low_stack_bound_) {
158 // The check assumes that stack grows from lower addresses.
144 sample->stack[0] = Memory::Address_at( 159 sample->stack[0] = Memory::Address_at(
145 (Address)(sample->fp + StandardFrameConstants::kCallerPCOffset)); 160 (Address)(sample->fp + StandardFrameConstants::kCallerPCOffset));
161 sample->frames_count = 1;
146 } else { 162 } else {
147 // GC runs or FP seems to be in some intermediate state, 163 // FP seems to be in some intermediate state,
148 // better discard this sample 164 // better discard this sample
149 sample->InitStack(0); 165 sample->frames_count = 0;
150 } 166 }
151 } 167 }
152 168
153 169
154 // 170 //
155 // Ticker used to provide ticks to the profiler and the sliding state 171 // Ticker used to provide ticks to the profiler and the sliding state
156 // window. 172 // window.
157 // 173 //
158 class Ticker: public Sampler { 174 class Ticker: public Sampler {
159 public: 175 public:
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 #ifdef ENABLE_LOGGING_AND_PROFILING 696 #ifdef ENABLE_LOGGING_AND_PROFILING
681 if (logfile_ == NULL || !FLAG_log) return; 697 if (logfile_ == NULL || !FLAG_log) return;
682 LogMessageBuilder msg; 698 LogMessageBuilder msg;
683 msg.Append("delete,%s,0x%x\n", name, 699 msg.Append("delete,%s,0x%x\n", name,
684 reinterpret_cast<unsigned int>(object)); 700 reinterpret_cast<unsigned int>(object));
685 msg.WriteToLogFile(); 701 msg.WriteToLogFile();
686 #endif 702 #endif
687 } 703 }
688 704
689 705
690 #ifdef ENABLE_LOGGING_AND_PROFILING
691 int Logger::CodeObjectSize(Code* code) {
692 // Check that the assumptions about the layout of the code object holds.
693 ASSERT_EQ(reinterpret_cast<unsigned int>(code->instruction_start()) -
694 reinterpret_cast<unsigned int>(code->address()),
695 Code::kHeaderSize);
696 return code->instruction_size() + Code::kHeaderSize;
697 }
698 #endif
699
700
701 void Logger::CodeCreateEvent(const char* tag, Code* code, const char* comment) { 706 void Logger::CodeCreateEvent(const char* tag, Code* code, const char* comment) {
702 #ifdef ENABLE_LOGGING_AND_PROFILING 707 #ifdef ENABLE_LOGGING_AND_PROFILING
703 if (logfile_ == NULL || !FLAG_log_code) return; 708 if (logfile_ == NULL || !FLAG_log_code) return;
704 LogMessageBuilder msg; 709 LogMessageBuilder msg;
705 msg.Append("code-creation,%s,0x%x,%d,\"", tag, 710 msg.Append("code-creation,%s,0x%x,%d,\"", tag,
706 reinterpret_cast<unsigned int>(code->address()), 711 reinterpret_cast<unsigned int>(code->address()),
707 CodeObjectSize(code)); 712 code->ExecutableSize());
708 for (const char* p = comment; *p != '\0'; p++) { 713 for (const char* p = comment; *p != '\0'; p++) {
709 if (*p == '"') { 714 if (*p == '"') {
710 msg.Append('\\'); 715 msg.Append('\\');
711 } 716 }
712 msg.Append(*p); 717 msg.Append(*p);
713 } 718 }
714 msg.Append('"'); 719 msg.Append('"');
715 msg.Append('\n'); 720 msg.Append('\n');
716 msg.WriteToLogFile(); 721 msg.WriteToLogFile();
717 #endif 722 #endif
718 } 723 }
719 724
720 725
721 void Logger::CodeCreateEvent(const char* tag, Code* code, String* name) { 726 void Logger::CodeCreateEvent(const char* tag, Code* code, String* name) {
722 #ifdef ENABLE_LOGGING_AND_PROFILING 727 #ifdef ENABLE_LOGGING_AND_PROFILING
723 if (logfile_ == NULL || !FLAG_log_code) return; 728 if (logfile_ == NULL || !FLAG_log_code) return;
724 LogMessageBuilder msg; 729 LogMessageBuilder msg;
725 SmartPointer<char> str = 730 SmartPointer<char> str =
726 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 731 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
727 msg.Append("code-creation,%s,0x%x,%d,\"%s\"\n", tag, 732 msg.Append("code-creation,%s,0x%x,%d,\"%s\"\n", tag,
728 reinterpret_cast<unsigned int>(code->address()), 733 reinterpret_cast<unsigned int>(code->address()),
729 CodeObjectSize(code), *str); 734 code->ExecutableSize(), *str);
730 msg.WriteToLogFile(); 735 msg.WriteToLogFile();
731 #endif 736 #endif
732 } 737 }
733 738
734 739
735 void Logger::CodeCreateEvent(const char* tag, Code* code, String* name, 740 void Logger::CodeCreateEvent(const char* tag, Code* code, String* name,
736 String* source, int line) { 741 String* source, int line) {
737 #ifdef ENABLE_LOGGING_AND_PROFILING 742 #ifdef ENABLE_LOGGING_AND_PROFILING
738 if (logfile_ == NULL || !FLAG_log_code) return; 743 if (logfile_ == NULL || !FLAG_log_code) return;
739 LogMessageBuilder msg; 744 LogMessageBuilder msg;
740 SmartPointer<char> str = 745 SmartPointer<char> str =
741 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 746 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
742 SmartPointer<char> sourcestr = 747 SmartPointer<char> sourcestr =
743 source->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 748 source->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
744 msg.Append("code-creation,%s,0x%x,%d,\"%s %s:%d\"\n", tag, 749 msg.Append("code-creation,%s,0x%x,%d,\"%s %s:%d\"\n", tag,
745 reinterpret_cast<unsigned int>(code->address()), 750 reinterpret_cast<unsigned int>(code->address()),
746 CodeObjectSize(code), 751 code->ExecutableSize(),
747 *str, *sourcestr, line); 752 *str, *sourcestr, line);
748 msg.WriteToLogFile(); 753 msg.WriteToLogFile();
749 #endif 754 #endif
750 } 755 }
751 756
752 757
753 void Logger::CodeCreateEvent(const char* tag, Code* code, int args_count) { 758 void Logger::CodeCreateEvent(const char* tag, Code* code, int args_count) {
754 #ifdef ENABLE_LOGGING_AND_PROFILING 759 #ifdef ENABLE_LOGGING_AND_PROFILING
755 if (logfile_ == NULL || !FLAG_log_code) return; 760 if (logfile_ == NULL || !FLAG_log_code) return;
756 LogMessageBuilder msg; 761 LogMessageBuilder msg;
757 msg.Append("code-creation,%s,0x%x,%d,\"args_count: %d\"\n", tag, 762 msg.Append("code-creation,%s,0x%x,%d,\"args_count: %d\"\n", tag,
758 reinterpret_cast<unsigned int>(code->address()), 763 reinterpret_cast<unsigned int>(code->address()),
759 CodeObjectSize(code), 764 code->ExecutableSize(),
760 args_count); 765 args_count);
761 msg.WriteToLogFile(); 766 msg.WriteToLogFile();
762 #endif 767 #endif
763 } 768 }
764 769
765 770
766 void Logger::CodeAllocateEvent(Code* code, Assembler* assem) { 771 void Logger::CodeAllocateEvent(Code* code, Assembler* assem) {
767 #ifdef ENABLE_LOGGING_AND_PROFILING 772 #ifdef ENABLE_LOGGING_AND_PROFILING
768 if (logfile_ == NULL || !FLAG_log_code) return; 773 if (logfile_ == NULL || !FLAG_log_code) return;
769 LogMessageBuilder msg; 774 LogMessageBuilder msg;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 930
926 #ifdef ENABLE_LOGGING_AND_PROFILING 931 #ifdef ENABLE_LOGGING_AND_PROFILING
927 void Logger::TickEvent(TickSample* sample, bool overflow) { 932 void Logger::TickEvent(TickSample* sample, bool overflow) {
928 if (logfile_ == NULL || !FLAG_prof) return; 933 if (logfile_ == NULL || !FLAG_prof) return;
929 LogMessageBuilder msg; 934 LogMessageBuilder msg;
930 msg.Append("tick,0x%x,0x%x,%d", sample->pc, sample->sp, 935 msg.Append("tick,0x%x,0x%x,%d", sample->pc, sample->sp,
931 static_cast<int>(sample->state)); 936 static_cast<int>(sample->state));
932 if (overflow) { 937 if (overflow) {
933 msg.Append(",overflow"); 938 msg.Append(",overflow");
934 } 939 }
935 if (*(sample->stack)) { 940 for (int i = 0; i < sample->frames_count; ++i) {
936 for (size_t i = 0; sample->stack[i]; ++i) { 941 msg.Append(",%p", sample->stack[i]);
937 msg.Append(",0x%x", reinterpret_cast<unsigned int>(sample->stack[i]));
938 }
939 } 942 }
940 msg.Append('\n'); 943 msg.Append('\n');
941 msg.WriteToLogFile(); 944 msg.WriteToLogFile();
942 } 945 }
943 946
944 947
945 bool Logger::IsProfilerPaused() { 948 bool Logger::IsProfilerPaused() {
946 return profiler_->paused(); 949 return profiler_->paused();
947 } 950 }
948 951
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 if (FLAG_log_state_changes) { 1141 if (FLAG_log_state_changes) {
1139 LOG(UncheckedStringEvent("Leaving", StateToString(state_))); 1142 LOG(UncheckedStringEvent("Leaving", StateToString(state_)));
1140 if (previous_) { 1143 if (previous_) {
1141 LOG(UncheckedStringEvent("To", StateToString(previous_->state_))); 1144 LOG(UncheckedStringEvent("To", StateToString(previous_->state_)));
1142 } 1145 }
1143 } 1146 }
1144 } 1147 }
1145 #endif 1148 #endif
1146 1149
1147 } } // namespace v8::internal 1150 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log.h ('k') | src/macro-assembler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698