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

Side by Side Diff: src/log.cc

Issue 40219: Get rid or heap allocation in stack sampler to avoid deadlocks. (Closed)
Patch Set: CHECK(a > b) -> CHECK_GT 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.h » ('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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (sample->state == GC) { 140 if (sample->state == GC) {
141 sample->InitStack(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 // 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 146 // function and sample->fp value isn't reliable due to FPO.
147 if (Top::c_entry_fp(Top::GetCurrentThread()) != NULL) { 147 if (Top::c_entry_fp(Top::GetCurrentThread()) != NULL) {
148 SafeStackTraceFrameIterator it( 148 SafeStackTraceFrameIterator it(
149 reinterpret_cast<Address>(sample->sp), 149 reinterpret_cast<Address>(sample->sp),
150 reinterpret_cast<Address>(low_stack_bound_)); 150 reinterpret_cast<Address>(low_stack_bound_));
151 // Pass 1: Calculate depth 151 int i = 0;
152 int depth = 0; 152 while (!it.done() && i < TickSample::kMaxFramesCount) {
153 while (!it.done() && depth <= kMaxStackFrames) { 153 sample->stack[i++] = it.frame()->pc();
154 ++depth;
155 it.Advance(); 154 it.Advance();
156 } 155 }
157 // Pass 2: Save stack 156 sample->frames_count = i;
158 sample->InitStack(depth);
159 if (depth > 0) {
160 it.Reset();
161 for (int i = 0; i < depth && !it.done(); ++i, it.Advance()) {
162 sample->stack[i] = it.frame()->pc();
163 }
164 }
165 } else if (sample->sp < sample->fp && sample->fp < low_stack_bound_) { 157 } else if (sample->sp < sample->fp && sample->fp < low_stack_bound_) {
166 // The check assumes that stack grows from lower addresses 158 // The check assumes that stack grows from lower addresses.
167 sample->InitStack(1);
168 sample->stack[0] = Memory::Address_at( 159 sample->stack[0] = Memory::Address_at(
169 (Address)(sample->fp + StandardFrameConstants::kCallerPCOffset)); 160 (Address)(sample->fp + StandardFrameConstants::kCallerPCOffset));
161 sample->frames_count = 1;
170 } else { 162 } else {
171 // FP seems to be in some intermediate state, 163 // FP seems to be in some intermediate state,
172 // better discard this sample 164 // better discard this sample
173 sample->InitStack(0); 165 sample->frames_count = 0;
174 } 166 }
175 } 167 }
176 168
177 169
178 // 170 //
179 // 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
180 // window. 172 // window.
181 // 173 //
182 class Ticker: public Sampler { 174 class Ticker: public Sampler {
183 public: 175 public:
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 930
939 #ifdef ENABLE_LOGGING_AND_PROFILING 931 #ifdef ENABLE_LOGGING_AND_PROFILING
940 void Logger::TickEvent(TickSample* sample, bool overflow) { 932 void Logger::TickEvent(TickSample* sample, bool overflow) {
941 if (logfile_ == NULL || !FLAG_prof) return; 933 if (logfile_ == NULL || !FLAG_prof) return;
942 LogMessageBuilder msg; 934 LogMessageBuilder msg;
943 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,
944 static_cast<int>(sample->state)); 936 static_cast<int>(sample->state));
945 if (overflow) { 937 if (overflow) {
946 msg.Append(",overflow"); 938 msg.Append(",overflow");
947 } 939 }
948 if (*(sample->stack)) { 940 for (int i = 0; i < sample->frames_count; ++i) {
949 for (size_t i = 0; sample->stack[i]; ++i) { 941 msg.Append(",%p", sample->stack[i]);
950 msg.Append(",0x%x", reinterpret_cast<unsigned int>(sample->stack[i]));
951 }
952 } 942 }
953 msg.Append('\n'); 943 msg.Append('\n');
954 msg.WriteToLogFile(); 944 msg.WriteToLogFile();
955 } 945 }
956 946
957 947
958 bool Logger::IsProfilerPaused() { 948 bool Logger::IsProfilerPaused() {
959 return profiler_->paused(); 949 return profiler_->paused();
960 } 950 }
961 951
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 if (FLAG_log_state_changes) { 1141 if (FLAG_log_state_changes) {
1152 LOG(UncheckedStringEvent("Leaving", StateToString(state_))); 1142 LOG(UncheckedStringEvent("Leaving", StateToString(state_)));
1153 if (previous_) { 1143 if (previous_) {
1154 LOG(UncheckedStringEvent("To", StateToString(previous_->state_))); 1144 LOG(UncheckedStringEvent("To", StateToString(previous_->state_)));
1155 } 1145 }
1156 } 1146 }
1157 } 1147 }
1158 #endif 1148 #endif
1159 1149
1160 } } // namespace v8::internal 1150 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log.h ('k') | src/platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698