| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 iterator_(is_valid_top_, is_valid_fp_ ? fp : NULL, sp) { | 201 iterator_(is_valid_top_, is_valid_fp_ ? fp : NULL, sp) { |
| 202 } | 202 } |
| 203 | 203 |
| 204 | 204 |
| 205 void SafeStackFrameIterator::Advance() { | 205 void SafeStackFrameIterator::Advance() { |
| 206 ASSERT(is_working_iterator_); | 206 ASSERT(is_working_iterator_); |
| 207 ASSERT(!done()); | 207 ASSERT(!done()); |
| 208 StackFrame* last_frame = iterator_.frame(); | 208 StackFrame* last_frame = iterator_.frame(); |
| 209 Address last_sp = last_frame->sp(), last_fp = last_frame->fp(); | 209 Address last_sp = last_frame->sp(), last_fp = last_frame->fp(); |
| 210 // Before advancing to the next stack frame, perform pointer validity tests | 210 // Before advancing to the next stack frame, perform pointer validity tests |
| 211 iteration_done_ = !IsValidFrame(last_frame) || !IsValidCaller(last_frame); | 211 iteration_done_ = !IsValidFrame(last_frame) || |
| 212 !CanIterateHandles(last_frame, iterator_.handler()) || |
| 213 !IsValidCaller(last_frame); |
| 212 if (iteration_done_) return; | 214 if (iteration_done_) return; |
| 213 | 215 |
| 214 iterator_.Advance(); | 216 iterator_.Advance(); |
| 215 if (iterator_.done()) return; | 217 if (iterator_.done()) return; |
| 216 // Check that we have actually moved to the previous frame in the stack | 218 // Check that we have actually moved to the previous frame in the stack |
| 217 StackFrame* prev_frame = iterator_.frame(); | 219 StackFrame* prev_frame = iterator_.frame(); |
| 218 iteration_done_ = prev_frame->sp() < last_sp || prev_frame->fp() < last_fp; | 220 iteration_done_ = prev_frame->sp() < last_sp || prev_frame->fp() < last_fp; |
| 219 } | 221 } |
| 220 | 222 |
| 221 | 223 |
| 224 bool SafeStackFrameIterator::CanIterateHandles(StackFrame* frame, |
| 225 StackHandler* handler) { |
| 226 // If StackIterator iterates over StackHandles, verify that |
| 227 // StackHandlerIterator can be instantiated (see StackHandlerIterator |
| 228 // constructor.) |
| 229 return !is_valid_top_ || (frame->sp() <= handler->address()); |
| 230 } |
| 231 |
| 232 |
| 222 bool SafeStackFrameIterator::IsValidFrame(StackFrame* frame) const { | 233 bool SafeStackFrameIterator::IsValidFrame(StackFrame* frame) const { |
| 223 return IsValidStackAddress(frame->sp()) && IsValidStackAddress(frame->fp()) && | 234 return IsValidStackAddress(frame->sp()) && IsValidStackAddress(frame->fp()) && |
| 224 // JavaScriptFrame uses function shared info to advance, hence it must | 235 // JavaScriptFrame uses function shared info to advance, hence it must |
| 225 // point to a valid function object. | 236 // point to a valid function object. |
| 226 (!frame->is_java_script() || | 237 (!frame->is_java_script() || |
| 227 reinterpret_cast<JavaScriptFrame*>(frame)->is_at_function()); | 238 reinterpret_cast<JavaScriptFrame*>(frame)->is_at_function()); |
| 228 } | 239 } |
| 229 | 240 |
| 230 | 241 |
| 231 bool SafeStackFrameIterator::IsValidCaller(StackFrame* frame) { | 242 bool SafeStackFrameIterator::IsValidCaller(StackFrame* frame) { |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 reg_code[i++] = r; | 734 reg_code[i++] = r; |
| 724 | 735 |
| 725 ASSERT(i == kNumJSCallerSaved); | 736 ASSERT(i == kNumJSCallerSaved); |
| 726 } | 737 } |
| 727 ASSERT(0 <= n && n < kNumJSCallerSaved); | 738 ASSERT(0 <= n && n < kNumJSCallerSaved); |
| 728 return reg_code[n]; | 739 return reg_code[n]; |
| 729 } | 740 } |
| 730 | 741 |
| 731 | 742 |
| 732 } } // namespace v8::internal | 743 } } // namespace v8::internal |
| OLD | NEW |