OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 } | 282 } |
283 | 283 |
284 | 284 |
285 SafeStackFrameIterator::SafeStackFrameIterator( | 285 SafeStackFrameIterator::SafeStackFrameIterator( |
286 Isolate* isolate, | 286 Isolate* isolate, |
287 Address fp, Address sp, Address low_bound, Address high_bound) : | 287 Address fp, Address sp, Address low_bound, Address high_bound) : |
288 maintainer_(isolate), | 288 maintainer_(isolate), |
289 stack_validator_(low_bound, high_bound), | 289 stack_validator_(low_bound, high_bound), |
290 is_valid_top_(IsValidTop(isolate, low_bound, high_bound)), | 290 is_valid_top_(IsValidTop(isolate, low_bound, high_bound)), |
291 is_valid_fp_(IsWithinBounds(low_bound, high_bound, fp)), | 291 is_valid_fp_(IsWithinBounds(low_bound, high_bound, fp)), |
292 is_working_iterator_(is_valid_top_ || is_valid_fp_), | 292 iteration_done_(!is_valid_top_ && !is_valid_fp_), |
293 iteration_done_(!is_working_iterator_), | |
294 iterator_(isolate, is_valid_top_, is_valid_fp_ ? fp : NULL, sp) { | 293 iterator_(isolate, is_valid_top_, is_valid_fp_ ? fp : NULL, sp) { |
295 } | 294 } |
296 | 295 |
297 bool SafeStackFrameIterator::is_active(Isolate* isolate) { | 296 bool SafeStackFrameIterator::is_active(Isolate* isolate) { |
298 return isolate->safe_stack_iterator_counter() > 0; | 297 return isolate->safe_stack_iterator_counter() > 0; |
299 } | 298 } |
300 | 299 |
301 | 300 |
302 bool SafeStackFrameIterator::IsValidTop(Isolate* isolate, | 301 bool SafeStackFrameIterator::IsValidTop(Isolate* isolate, |
303 Address low_bound, Address high_bound) { | 302 Address low_bound, Address high_bound) { |
304 ThreadLocalTop* top = isolate->thread_local_top(); | 303 ThreadLocalTop* top = isolate->thread_local_top(); |
305 Address fp = Isolate::c_entry_fp(top); | 304 Address fp = Isolate::c_entry_fp(top); |
306 ExitFrameValidator validator(low_bound, high_bound); | 305 ExitFrameValidator validator(low_bound, high_bound); |
307 if (!validator.IsValidFP(fp)) return false; | 306 if (!validator.IsValidFP(fp)) return false; |
308 return Isolate::handler(top) != NULL; | 307 return Isolate::handler(top) != NULL; |
309 } | 308 } |
310 | 309 |
311 | 310 |
312 void SafeStackFrameIterator::Advance() { | 311 void SafeStackFrameIterator::Advance() { |
313 ASSERT(is_working_iterator_); | |
314 ASSERT(!done()); | 312 ASSERT(!done()); |
315 StackFrame* last_frame = iterator_.frame(); | 313 StackFrame* last_frame = iterator_.frame(); |
316 Address last_sp = last_frame->sp(), last_fp = last_frame->fp(); | 314 Address last_sp = last_frame->sp(), last_fp = last_frame->fp(); |
317 // Before advancing to the next stack frame, perform pointer validity tests | 315 // Before advancing to the next stack frame, perform pointer validity tests |
318 iteration_done_ = !IsValidFrame(last_frame) || | 316 iteration_done_ = !IsValidFrame(last_frame) || |
319 !CanIterateHandles(last_frame, iterator_.handler()) || | 317 !CanIterateHandles(last_frame, iterator_.handler()) || |
320 !IsValidCaller(last_frame); | 318 !IsValidCaller(last_frame); |
321 if (iteration_done_) return; | 319 if (iteration_done_) return; |
322 | 320 |
323 iterator_.Advance(); | 321 iterator_.Advance(); |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 | 555 |
558 StackFrame::Type ExitFrame::GetStateForFramePointer(Address fp, State* state) { | 556 StackFrame::Type ExitFrame::GetStateForFramePointer(Address fp, State* state) { |
559 if (fp == 0) return NONE; | 557 if (fp == 0) return NONE; |
560 Address sp = ComputeStackPointer(fp); | 558 Address sp = ComputeStackPointer(fp); |
561 FillState(fp, sp, state); | 559 FillState(fp, sp, state); |
562 ASSERT(*state->pc_address != NULL); | 560 ASSERT(*state->pc_address != NULL); |
563 return EXIT; | 561 return EXIT; |
564 } | 562 } |
565 | 563 |
566 | 564 |
| 565 Address ExitFrame::ComputeStackPointer(Address fp) { |
| 566 return Memory::Address_at(fp + ExitFrameConstants::kSPOffset); |
| 567 } |
| 568 |
| 569 |
567 void ExitFrame::FillState(Address fp, Address sp, State* state) { | 570 void ExitFrame::FillState(Address fp, Address sp, State* state) { |
568 state->sp = sp; | 571 state->sp = sp; |
569 state->fp = fp; | 572 state->fp = fp; |
570 state->pc_address = ResolveReturnAddressLocation( | 573 state->pc_address = ResolveReturnAddressLocation( |
571 reinterpret_cast<Address*>(sp - 1 * kPointerSize)); | 574 reinterpret_cast<Address*>(sp - 1 * kPointerSize)); |
572 } | 575 } |
573 | 576 |
574 | 577 |
575 Address StandardFrame::GetExpressionAddress(int n) const { | 578 Address StandardFrame::GetExpressionAddress(int n) const { |
576 const int offset = StandardFrameConstants::kExpressionsOffset; | 579 const int offset = StandardFrameConstants::kExpressionsOffset; |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 ZoneList<StackFrame*> list(10, zone); | 1636 ZoneList<StackFrame*> list(10, zone); |
1634 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1637 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
1635 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1638 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
1636 list.Add(frame, zone); | 1639 list.Add(frame, zone); |
1637 } | 1640 } |
1638 return list.ToVector(); | 1641 return list.ToVector(); |
1639 } | 1642 } |
1640 | 1643 |
1641 | 1644 |
1642 } } // namespace v8::internal | 1645 } } // namespace v8::internal |
OLD | NEW |