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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 return IsValidStackAddress(frame->sp()) && IsValidStackAddress(frame->fp()) && | 223 return IsValidStackAddress(frame->sp()) && IsValidStackAddress(frame->fp()) && |
224 // JavaScriptFrame uses function shared info to advance, hence it must | 224 // JavaScriptFrame uses function shared info to advance, hence it must |
225 // point to a valid function object. | 225 // point to a valid function object. |
226 (!frame->is_java_script() || | 226 (!frame->is_java_script() || |
227 reinterpret_cast<JavaScriptFrame*>(frame)->is_at_function()); | 227 reinterpret_cast<JavaScriptFrame*>(frame)->is_at_function()); |
228 } | 228 } |
229 | 229 |
230 | 230 |
231 bool SafeStackFrameIterator::IsValidCaller(StackFrame* frame) { | 231 bool SafeStackFrameIterator::IsValidCaller(StackFrame* frame) { |
232 StackFrame::State state; | 232 StackFrame::State state; |
| 233 if (frame->is_entry() || frame->is_entry_construct()) { |
| 234 // See EntryFrame::GetCallerState. It computes the caller FP address |
| 235 // and calls ExitFrame::GetStateForFramePointer on it. We need to be |
| 236 // sure that caller FP address is valid. |
| 237 Address caller_fp = Memory::Address_at( |
| 238 frame->fp() + EntryFrameConstants::kCallerFPOffset); |
| 239 if (!IsValidStackAddress(caller_fp)) { |
| 240 return false; |
| 241 } |
| 242 } else if (frame->is_arguments_adaptor()) { |
| 243 // See ArgumentsAdaptorFrame::GetCallerStackPointer. It assumes that |
| 244 // the number of arguments is stored on stack as Smi. We need to check |
| 245 // that it really an Smi. |
| 246 Object* number_of_args = reinterpret_cast<ArgumentsAdaptorFrame*>(frame)-> |
| 247 GetExpression(0); |
| 248 if (!number_of_args->IsSmi()) { |
| 249 return false; |
| 250 } |
| 251 } |
233 frame->ComputeCallerState(&state); | 252 frame->ComputeCallerState(&state); |
234 return IsValidStackAddress(state.sp) && IsValidStackAddress(state.fp) && | 253 return IsValidStackAddress(state.sp) && IsValidStackAddress(state.fp) && |
235 iterator_.SingletonFor(frame->GetCallerState(&state)) != NULL; | 254 iterator_.SingletonFor(frame->GetCallerState(&state)) != NULL; |
236 } | 255 } |
237 | 256 |
238 | 257 |
239 void SafeStackFrameIterator::Reset() { | 258 void SafeStackFrameIterator::Reset() { |
240 if (is_working_iterator_) { | 259 if (is_working_iterator_) { |
241 iterator_.Reset(); | 260 iterator_.Reset(); |
242 iteration_done_ = false; | 261 iteration_done_ = false; |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 reg_code[i++] = r; | 723 reg_code[i++] = r; |
705 | 724 |
706 ASSERT(i == kNumJSCallerSaved); | 725 ASSERT(i == kNumJSCallerSaved); |
707 } | 726 } |
708 ASSERT(0 <= n && n < kNumJSCallerSaved); | 727 ASSERT(0 <= n && n < kNumJSCallerSaved); |
709 return reg_code[n]; | 728 return reg_code[n]; |
710 } | 729 } |
711 | 730 |
712 | 731 |
713 } } // namespace v8::internal | 732 } } // namespace v8::internal |
OLD | NEW |