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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 | 196 |
197 // Printing support. | 197 // Printing support. |
198 enum PrintMode { OVERVIEW, DETAILS }; | 198 enum PrintMode { OVERVIEW, DETAILS }; |
199 virtual void Print(StringStream* accumulator, | 199 virtual void Print(StringStream* accumulator, |
200 PrintMode mode, | 200 PrintMode mode, |
201 int index) const { } | 201 int index) const { } |
202 | 202 |
203 protected: | 203 protected: |
204 struct State { | 204 struct State { |
| 205 State() : sp(NULL), fp(NULL), pc_address(NULL) { } |
205 Address sp; | 206 Address sp; |
206 Address fp; | 207 Address fp; |
207 Address* pc_address; | 208 Address* pc_address; |
208 }; | 209 }; |
209 | 210 |
210 explicit StackFrame(StackFrameIterator* iterator) : iterator_(iterator) { } | 211 explicit StackFrame(StackFrameIterator* iterator) : iterator_(iterator) { } |
211 virtual ~StackFrame() { } | 212 virtual ~StackFrame() { } |
212 | 213 |
213 // Compute the stack pointer for the calling frame. | 214 // Compute the stack pointer for the calling frame. |
214 virtual Address GetCallerStackPointer() const = 0; | 215 virtual Address GetCallerStackPointer() const = 0; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 312 |
312 static ExitFrame* cast(StackFrame* frame) { | 313 static ExitFrame* cast(StackFrame* frame) { |
313 ASSERT(frame->is_exit()); | 314 ASSERT(frame->is_exit()); |
314 return static_cast<ExitFrame*>(frame); | 315 return static_cast<ExitFrame*>(frame); |
315 } | 316 } |
316 | 317 |
317 // Compute the state and type of an exit frame given a frame | 318 // Compute the state and type of an exit frame given a frame |
318 // pointer. Used when constructing the first stack frame seen by an | 319 // pointer. Used when constructing the first stack frame seen by an |
319 // iterator and the frames following entry frames. | 320 // iterator and the frames following entry frames. |
320 static Type GetStateForFramePointer(Address fp, State* state); | 321 static Type GetStateForFramePointer(Address fp, State* state); |
| 322 static Address ComputeStackPointer(Address fp); |
| 323 static void FillState(Address fp, Address sp, State* state); |
321 | 324 |
322 protected: | 325 protected: |
323 explicit ExitFrame(StackFrameIterator* iterator) : StackFrame(iterator) { } | 326 explicit ExitFrame(StackFrameIterator* iterator) : StackFrame(iterator) { } |
324 | 327 |
325 virtual Address GetCallerStackPointer() const; | 328 virtual Address GetCallerStackPointer() const; |
326 | 329 |
327 private: | 330 private: |
328 virtual void ComputeCallerState(State* state) const; | 331 virtual void ComputeCallerState(State* state) const; |
329 | 332 |
330 friend class StackFrameIterator; | 333 friend class StackFrameIterator; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 protected: | 439 protected: |
437 explicit JavaScriptFrame(StackFrameIterator* iterator) | 440 explicit JavaScriptFrame(StackFrameIterator* iterator) |
438 : StandardFrame(iterator) { } | 441 : StandardFrame(iterator) { } |
439 | 442 |
440 virtual Address GetCallerStackPointer() const; | 443 virtual Address GetCallerStackPointer() const; |
441 | 444 |
442 private: | 445 private: |
443 inline Object* function_slot_object() const; | 446 inline Object* function_slot_object() const; |
444 | 447 |
445 friend class StackFrameIterator; | 448 friend class StackFrameIterator; |
| 449 friend class StackTracer; |
446 }; | 450 }; |
447 | 451 |
448 | 452 |
449 // Arguments adaptor frames are automatically inserted below | 453 // Arguments adaptor frames are automatically inserted below |
450 // JavaScript frames when the actual number of parameters does not | 454 // JavaScript frames when the actual number of parameters does not |
451 // match the formal number of parameters. | 455 // match the formal number of parameters. |
452 class ArgumentsAdaptorFrame: public JavaScriptFrame { | 456 class ArgumentsAdaptorFrame: public JavaScriptFrame { |
453 public: | 457 public: |
454 virtual Type type() const { return ARGUMENTS_ADAPTOR; } | 458 virtual Type type() const { return ARGUMENTS_ADAPTOR; } |
455 | 459 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 void Reset(); | 651 void Reset(); |
648 | 652 |
649 static bool is_active() { return active_count_ > 0; } | 653 static bool is_active() { return active_count_ > 0; } |
650 | 654 |
651 static bool IsWithinBounds( | 655 static bool IsWithinBounds( |
652 Address low_bound, Address high_bound, Address addr) { | 656 Address low_bound, Address high_bound, Address addr) { |
653 return low_bound <= addr && addr <= high_bound; | 657 return low_bound <= addr && addr <= high_bound; |
654 } | 658 } |
655 | 659 |
656 private: | 660 private: |
| 661 class StackAddressValidator { |
| 662 public: |
| 663 StackAddressValidator(Address low_bound, Address high_bound) |
| 664 : low_bound_(low_bound), high_bound_(high_bound) { } |
| 665 bool IsValid(Address addr) const { |
| 666 return IsWithinBounds(low_bound_, high_bound_, addr); |
| 667 } |
| 668 private: |
| 669 Address low_bound_; |
| 670 Address high_bound_; |
| 671 }; |
| 672 |
| 673 class ExitFrameValidator { |
| 674 public: |
| 675 explicit ExitFrameValidator(const StackAddressValidator& validator) |
| 676 : validator_(validator) { } |
| 677 ExitFrameValidator(Address low_bound, Address high_bound) |
| 678 : validator_(low_bound, high_bound) { } |
| 679 bool IsValidFP(Address fp); |
| 680 private: |
| 681 StackAddressValidator validator_; |
| 682 }; |
| 683 |
657 bool IsValidStackAddress(Address addr) const { | 684 bool IsValidStackAddress(Address addr) const { |
658 return IsWithinBounds(low_bound_, high_bound_, addr); | 685 return stack_validator_.IsValid(addr); |
659 } | 686 } |
660 bool CanIterateHandles(StackFrame* frame, StackHandler* handler); | 687 bool CanIterateHandles(StackFrame* frame, StackHandler* handler); |
661 bool IsValidFrame(StackFrame* frame) const; | 688 bool IsValidFrame(StackFrame* frame) const; |
662 bool IsValidCaller(StackFrame* frame); | 689 bool IsValidCaller(StackFrame* frame); |
| 690 static bool IsValidTop(Address low_bound, Address high_bound); |
663 | 691 |
664 // This is a nasty hack to make sure the active count is incremented | 692 // This is a nasty hack to make sure the active count is incremented |
665 // before the constructor for the embedded iterator is invoked. This | 693 // before the constructor for the embedded iterator is invoked. This |
666 // is needed because the constructor will start looking at frames | 694 // is needed because the constructor will start looking at frames |
667 // right away and we need to make sure it doesn't start inspecting | 695 // right away and we need to make sure it doesn't start inspecting |
668 // heap objects. | 696 // heap objects. |
669 class ActiveCountMaintainer BASE_EMBEDDED { | 697 class ActiveCountMaintainer BASE_EMBEDDED { |
670 public: | 698 public: |
671 ActiveCountMaintainer() { active_count_++; } | 699 ActiveCountMaintainer() { active_count_++; } |
672 ~ActiveCountMaintainer() { active_count_--; } | 700 ~ActiveCountMaintainer() { active_count_--; } |
673 }; | 701 }; |
674 | 702 |
675 ActiveCountMaintainer maintainer_; | 703 ActiveCountMaintainer maintainer_; |
676 static int active_count_; | 704 static int active_count_; |
677 Address low_bound_; | 705 StackAddressValidator stack_validator_; |
678 Address high_bound_; | |
679 const bool is_valid_top_; | 706 const bool is_valid_top_; |
680 const bool is_valid_fp_; | 707 const bool is_valid_fp_; |
681 const bool is_working_iterator_; | 708 const bool is_working_iterator_; |
682 bool iteration_done_; | 709 bool iteration_done_; |
683 StackFrameIterator iterator_; | 710 StackFrameIterator iterator_; |
684 }; | 711 }; |
685 | 712 |
686 | 713 |
687 #ifdef ENABLE_LOGGING_AND_PROFILING | 714 #ifdef ENABLE_LOGGING_AND_PROFILING |
688 typedef JavaScriptFrameIteratorTemp<SafeStackFrameIterator> | 715 typedef JavaScriptFrameIteratorTemp<SafeStackFrameIterator> |
(...skipping 20 matching lines...) Expand all Loading... |
709 }; | 736 }; |
710 | 737 |
711 | 738 |
712 // Reads all frames on the current stack and copies them into the current | 739 // Reads all frames on the current stack and copies them into the current |
713 // zone memory. | 740 // zone memory. |
714 Vector<StackFrame*> CreateStackMap(); | 741 Vector<StackFrame*> CreateStackMap(); |
715 | 742 |
716 } } // namespace v8::internal | 743 } } // namespace v8::internal |
717 | 744 |
718 #endif // V8_FRAMES_H_ | 745 #endif // V8_FRAMES_H_ |
OLD | NEW |