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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 StackFrameIterator::StackFrameIterator() | 67 StackFrameIterator::StackFrameIterator() |
68 : STACK_FRAME_TYPE_LIST(INITIALIZE_SINGLETON) | 68 : STACK_FRAME_TYPE_LIST(INITIALIZE_SINGLETON) |
69 frame_(NULL), handler_(NULL), thread_(Top::GetCurrentThread()) { | 69 frame_(NULL), handler_(NULL), thread_(Top::GetCurrentThread()) { |
70 Reset(); | 70 Reset(); |
71 } | 71 } |
72 StackFrameIterator::StackFrameIterator(ThreadLocalTop* t) | 72 StackFrameIterator::StackFrameIterator(ThreadLocalTop* t) |
73 : STACK_FRAME_TYPE_LIST(INITIALIZE_SINGLETON) | 73 : STACK_FRAME_TYPE_LIST(INITIALIZE_SINGLETON) |
74 frame_(NULL), handler_(NULL), thread_(t) { | 74 frame_(NULL), handler_(NULL), thread_(t) { |
75 Reset(); | 75 Reset(); |
76 } | 76 } |
| 77 StackFrameIterator::StackFrameIterator(bool reset) |
| 78 : STACK_FRAME_TYPE_LIST(INITIALIZE_SINGLETON) |
| 79 frame_(NULL), handler_(NULL), thread_(Top::GetCurrentThread()) { |
| 80 if (reset) Reset(); |
| 81 } |
77 #undef INITIALIZE_SINGLETON | 82 #undef INITIALIZE_SINGLETON |
78 | 83 |
79 | 84 |
80 void StackFrameIterator::Advance() { | 85 void StackFrameIterator::Advance() { |
81 ASSERT(!done()); | 86 ASSERT(!done()); |
82 // Compute the state of the calling frame before restoring | 87 // Compute the state of the calling frame before restoring |
83 // callee-saved registers and unwinding handlers. This allows the | 88 // callee-saved registers and unwinding handlers. This allows the |
84 // frame code that computes the caller state to access the top | 89 // frame code that computes the caller state to access the top |
85 // handler and the value of any callee-saved register if needed. | 90 // handler and the value of any callee-saved register if needed. |
86 StackFrame::State state; | 91 StackFrame::State state; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 result->state_ = *state; | 129 result->state_ = *state; |
125 return result; | 130 return result; |
126 | 131 |
127 #undef FRAME_TYPE_CASE | 132 #undef FRAME_TYPE_CASE |
128 } | 133 } |
129 | 134 |
130 | 135 |
131 // ------------------------------------------------------------------------- | 136 // ------------------------------------------------------------------------- |
132 | 137 |
133 | 138 |
134 JavaScriptFrameIterator::JavaScriptFrameIterator(StackFrame::Id id) { | 139 StackTraceFrameIterator::StackTraceFrameIterator() { |
| 140 if (!done() && !frame()->function()->IsJSFunction()) Advance(); |
| 141 } |
| 142 |
| 143 |
| 144 void StackTraceFrameIterator::Advance() { |
135 while (true) { | 145 while (true) { |
136 Advance(); | 146 JavaScriptFrameIterator::Advance(); |
137 if (frame()->id() == id) return; | 147 if (done()) return; |
| 148 if (frame()->function()->IsJSFunction()) return; |
138 } | 149 } |
139 } | 150 } |
140 | 151 |
141 | 152 |
142 void JavaScriptFrameIterator::Advance() { | 153 // ------------------------------------------------------------------------- |
143 do { | 154 |
144 iterator_.Advance(); | 155 |
145 } while (!iterator_.done() && !iterator_.frame()->is_java_script()); | 156 SafeStackFrameIterator::SafeStackFrameIterator( |
| 157 Address low_bound, Address high_bound) : |
| 158 low_bound_(low_bound), high_bound_(high_bound), |
| 159 is_working_iterator_(IsInBounds(low_bound, high_bound, |
| 160 Top::c_entry_fp(Top::GetCurrentThread()))), |
| 161 iteration_done_(!is_working_iterator_), iterator_(is_working_iterator_) { |
146 } | 162 } |
147 | 163 |
148 | 164 |
149 void JavaScriptFrameIterator::AdvanceToArgumentsFrame() { | 165 void SafeStackFrameIterator::Advance() { |
150 if (!frame()->has_adapted_arguments()) return; | 166 ASSERT(is_working_iterator_); |
151 iterator_.Advance(); | 167 ASSERT(!done()); |
152 ASSERT(iterator_.frame()->is_arguments_adaptor()); | 168 StackFrame* frame = iterator_.frame(); |
| 169 iteration_done_ = |
| 170 !IsGoodStackAddress(frame->sp()) || !IsGoodStackAddress(frame->fp()); |
| 171 if (!iteration_done_) { |
| 172 iterator_.Advance(); |
| 173 if (!iterator_.done()) { |
| 174 // Check that we have actually moved to the previous frame in the stack |
| 175 StackFrame* prev_frame = iterator_.frame(); |
| 176 iteration_done_ = |
| 177 prev_frame->sp() < frame->sp() || prev_frame->fp() < frame->fp(); |
| 178 } |
| 179 } |
153 } | 180 } |
154 | 181 |
155 | 182 |
156 void JavaScriptFrameIterator::Reset() { | 183 void SafeStackFrameIterator::Reset() { |
157 iterator_.Reset(); | 184 if (is_working_iterator_) { |
158 Advance(); | 185 iterator_.Reset(); |
| 186 iteration_done_ = false; |
| 187 } |
159 } | 188 } |
160 | 189 |
161 | 190 |
162 // ------------------------------------------------------------------------- | 191 // ------------------------------------------------------------------------- |
| 192 |
| 193 |
| 194 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 195 SafeStackTraceFrameIterator::SafeStackTraceFrameIterator( |
| 196 Address low_bound, Address high_bound) : |
| 197 SafeJavaScriptFrameIterator(low_bound, high_bound) { |
| 198 if (!done() && !frame()->function()->IsJSFunction()) Advance(); |
| 199 } |
| 200 |
| 201 |
| 202 void SafeStackTraceFrameIterator::Advance() { |
| 203 while (true) { |
| 204 SafeJavaScriptFrameIterator::Advance(); |
| 205 if (done()) return; |
| 206 if (frame()->function()->IsJSFunction()) return; |
| 207 } |
| 208 } |
| 209 #endif |
| 210 |
| 211 |
| 212 // ------------------------------------------------------------------------- |
163 | 213 |
164 | 214 |
165 void StackHandler::Cook(Code* code) { | 215 void StackHandler::Cook(Code* code) { |
166 ASSERT(MarkCompactCollector::IsCompacting()); | 216 ASSERT(MarkCompactCollector::IsCompacting()); |
167 ASSERT(code->contains(pc())); | 217 ASSERT(code->contains(pc())); |
168 set_pc(AddressFrom<Address>(pc() - code->instruction_start())); | 218 set_pc(AddressFrom<Address>(pc() - code->instruction_start())); |
169 } | 219 } |
170 | 220 |
171 | 221 |
172 void StackHandler::Uncook(Code* code) { | 222 void StackHandler::Uncook(Code* code) { |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 reg_code[i++] = r; | 639 reg_code[i++] = r; |
590 | 640 |
591 ASSERT(i == kNumJSCallerSaved); | 641 ASSERT(i == kNumJSCallerSaved); |
592 } | 642 } |
593 ASSERT(0 <= n && n < kNumJSCallerSaved); | 643 ASSERT(0 <= n && n < kNumJSCallerSaved); |
594 return reg_code[n]; | 644 return reg_code[n]; |
595 } | 645 } |
596 | 646 |
597 | 647 |
598 } } // namespace v8::internal | 648 } } // namespace v8::internal |
OLD | NEW |