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

Side by Side Diff: src/log.cc

Issue 50052: Support profiler stack sampling in any situation. (Closed)
Patch Set: Fixes according to comments 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
« no previous file with comments | « src/log.h ('k') | src/platform-win32.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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (sample->state == GC) { 140 if (sample->state == GC) {
141 sample->frames_count = 0; 141 sample->frames_count = 0;
142 return; 142 return;
143 } 143 }
144 144
145 // If c_entry_fp is available, this means that we are inside a C++ 145 SafeStackTraceFrameIterator it(
146 // function and sample->fp value isn't reliable due to FPO. 146 reinterpret_cast<Address>(sample->fp),
147 if (Top::c_entry_fp(Top::GetCurrentThread()) != NULL) { 147 reinterpret_cast<Address>(sample->sp),
148 SafeStackTraceFrameIterator it( 148 reinterpret_cast<Address>(sample->sp),
149 reinterpret_cast<Address>(sample->sp), 149 reinterpret_cast<Address>(low_stack_bound_));
150 reinterpret_cast<Address>(low_stack_bound_)); 150 int i = 0;
151 int i = 0; 151 while (!it.done() && i < TickSample::kMaxFramesCount) {
152 while (!it.done() && i < TickSample::kMaxFramesCount) { 152 sample->stack[i++] = it.frame()->pc();
153 sample->stack[i++] = it.frame()->pc(); 153 it.Advance();
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.
159 sample->stack[0] = Memory::Address_at(
160 (Address)(sample->fp + StandardFrameConstants::kCallerPCOffset));
161 sample->frames_count = 1;
162 } else {
163 // FP seems to be in some intermediate state,
164 // better discard this sample
165 sample->frames_count = 0;
166 } 154 }
155 sample->frames_count = i;
167 } 156 }
168 157
169 158
170 // 159 //
171 // Ticker used to provide ticks to the profiler and the sliding state 160 // Ticker used to provide ticks to the profiler and the sliding state
172 // window. 161 // window.
173 // 162 //
174 class Ticker: public Sampler { 163 class Ticker: public Sampler {
175 public: 164 public:
176 explicit Ticker(int interval, unsigned int low_stack_bound): 165 explicit Ticker(int interval, unsigned int low_stack_bound):
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 #ifdef ENABLE_LOGGING_AND_PROFILING 918 #ifdef ENABLE_LOGGING_AND_PROFILING
930 void Logger::TickEvent(TickSample* sample, bool overflow) { 919 void Logger::TickEvent(TickSample* sample, bool overflow) {
931 if (logfile_ == NULL || !FLAG_prof) return; 920 if (logfile_ == NULL || !FLAG_prof) return;
932 LogMessageBuilder msg; 921 LogMessageBuilder msg;
933 msg.Append("tick,0x%x,0x%x,%d", sample->pc, sample->sp, 922 msg.Append("tick,0x%x,0x%x,%d", sample->pc, sample->sp,
934 static_cast<int>(sample->state)); 923 static_cast<int>(sample->state));
935 if (overflow) { 924 if (overflow) {
936 msg.Append(",overflow"); 925 msg.Append(",overflow");
937 } 926 }
938 for (int i = 0; i < sample->frames_count; ++i) { 927 for (int i = 0; i < sample->frames_count; ++i) {
939 msg.Append(",%p", sample->stack[i]); 928 msg.Append(",0x%x", reinterpret_cast<uint32_t>(sample->stack[i]));
940 } 929 }
941 msg.Append('\n'); 930 msg.Append('\n');
942 msg.WriteToLogFile(); 931 msg.WriteToLogFile();
943 } 932 }
944 933
945 934
946 bool Logger::IsProfilerPaused() { 935 bool Logger::IsProfilerPaused() {
947 return profiler_->paused(); 936 return profiler_->paused();
948 } 937 }
949 938
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 if (FLAG_log_state_changes) { 1128 if (FLAG_log_state_changes) {
1140 LOG(UncheckedStringEvent("Leaving", StateToString(state_))); 1129 LOG(UncheckedStringEvent("Leaving", StateToString(state_)));
1141 if (previous_) { 1130 if (previous_) {
1142 LOG(UncheckedStringEvent("To", StateToString(previous_->state_))); 1131 LOG(UncheckedStringEvent("To", StateToString(previous_->state_)));
1143 } 1132 }
1144 } 1133 }
1145 } 1134 }
1146 #endif 1135 #endif
1147 1136
1148 } } // namespace v8::internal 1137 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log.h ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698