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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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->InitStack(0); |
142 && (sample->sp < sample->fp && sample->fp < low_stack_bound_)) { | 142 return; |
| 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 // Pass 1: Calculate depth |
| 152 int depth = 0; |
| 153 while (!it.done() && depth <= kMaxStackFrames) { |
| 154 ++depth; |
| 155 it.Advance(); |
| 156 } |
| 157 // Pass 2: Save stack |
| 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_) { |
| 166 // The check assumes that stack grows from lower addresses |
143 sample->InitStack(1); | 167 sample->InitStack(1); |
144 sample->stack[0] = Memory::Address_at( | 168 sample->stack[0] = Memory::Address_at( |
145 (Address)(sample->fp + StandardFrameConstants::kCallerPCOffset)); | 169 (Address)(sample->fp + StandardFrameConstants::kCallerPCOffset)); |
146 } else { | 170 } else { |
147 // GC runs or FP seems to be in some intermediate state, | 171 // FP seems to be in some intermediate state, |
148 // better discard this sample | 172 // better discard this sample |
149 sample->InitStack(0); | 173 sample->InitStack(0); |
150 } | 174 } |
151 } | 175 } |
152 | 176 |
153 | 177 |
154 // | 178 // |
155 // Ticker used to provide ticks to the profiler and the sliding state | 179 // Ticker used to provide ticks to the profiler and the sliding state |
156 // window. | 180 // window. |
157 // | 181 // |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 if (FLAG_log_state_changes) { | 1162 if (FLAG_log_state_changes) { |
1139 LOG(UncheckedStringEvent("Leaving", StateToString(state_))); | 1163 LOG(UncheckedStringEvent("Leaving", StateToString(state_))); |
1140 if (previous_) { | 1164 if (previous_) { |
1141 LOG(UncheckedStringEvent("To", StateToString(previous_->state_))); | 1165 LOG(UncheckedStringEvent("To", StateToString(previous_->state_))); |
1142 } | 1166 } |
1143 } | 1167 } |
1144 } | 1168 } |
1145 #endif | 1169 #endif |
1146 | 1170 |
1147 } } // namespace v8::internal | 1171 } } // namespace v8::internal |
OLD | NEW |