| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // Opaque data type for identifying stack frames. Used extensively | 113 // Opaque data type for identifying stack frames. Used extensively |
| 114 // by the debugger. | 114 // by the debugger. |
| 115 // ID_MIN_VALUE and ID_MAX_VALUE are specified to ensure that enumeration type | 115 // ID_MIN_VALUE and ID_MAX_VALUE are specified to ensure that enumeration type |
| 116 // has correct value range (see Issue 830 for more details). | 116 // has correct value range (see Issue 830 for more details). |
| 117 enum Id { | 117 enum Id { |
| 118 ID_MIN_VALUE = kMinInt, | 118 ID_MIN_VALUE = kMinInt, |
| 119 ID_MAX_VALUE = kMaxInt, | 119 ID_MAX_VALUE = kMaxInt, |
| 120 NO_ID = 0 | 120 NO_ID = 0 |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 struct State { |
| 124 State() : sp(NULL), fp(NULL), pc_address(NULL) { } |
| 125 Address sp; |
| 126 Address fp; |
| 127 Address* pc_address; |
| 128 }; |
| 129 |
| 123 // Copy constructor; it breaks the connection to host iterator. | 130 // Copy constructor; it breaks the connection to host iterator. |
| 124 StackFrame(const StackFrame& original) { | 131 StackFrame(const StackFrame& original) { |
| 125 this->state_ = original.state_; | 132 this->state_ = original.state_; |
| 126 this->iterator_ = NULL; | 133 this->iterator_ = NULL; |
| 127 } | 134 } |
| 128 | 135 |
| 129 // Type testers. | 136 // Type testers. |
| 130 bool is_entry() const { return type() == ENTRY; } | 137 bool is_entry() const { return type() == ENTRY; } |
| 131 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; } | 138 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; } |
| 132 bool is_exit() const { return type() == EXIT; } | 139 bool is_exit() const { return type() == EXIT; } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 179 |
| 173 virtual void Iterate(ObjectVisitor* v) const { } | 180 virtual void Iterate(ObjectVisitor* v) const { } |
| 174 | 181 |
| 175 // Printing support. | 182 // Printing support. |
| 176 enum PrintMode { OVERVIEW, DETAILS }; | 183 enum PrintMode { OVERVIEW, DETAILS }; |
| 177 virtual void Print(StringStream* accumulator, | 184 virtual void Print(StringStream* accumulator, |
| 178 PrintMode mode, | 185 PrintMode mode, |
| 179 int index) const { } | 186 int index) const { } |
| 180 | 187 |
| 181 protected: | 188 protected: |
| 182 struct State { | |
| 183 Address sp; | |
| 184 Address fp; | |
| 185 Address* pc_address; | |
| 186 }; | |
| 187 | |
| 188 explicit StackFrame(StackFrameIterator* iterator) : iterator_(iterator) { } | 189 explicit StackFrame(StackFrameIterator* iterator) : iterator_(iterator) { } |
| 189 virtual ~StackFrame() { } | 190 virtual ~StackFrame() { } |
| 190 | 191 |
| 191 // Compute the stack pointer for the calling frame. | 192 // Compute the stack pointer for the calling frame. |
| 192 virtual Address GetCallerStackPointer() const = 0; | 193 virtual Address GetCallerStackPointer() const = 0; |
| 193 | 194 |
| 194 // Printing support. | 195 // Printing support. |
| 195 static void PrintIndex(StringStream* accumulator, | 196 static void PrintIndex(StringStream* accumulator, |
| 196 PrintMode mode, | 197 PrintMode mode, |
| 197 int index); | 198 int index); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 294 |
| 294 static ExitFrame* cast(StackFrame* frame) { | 295 static ExitFrame* cast(StackFrame* frame) { |
| 295 ASSERT(frame->is_exit()); | 296 ASSERT(frame->is_exit()); |
| 296 return static_cast<ExitFrame*>(frame); | 297 return static_cast<ExitFrame*>(frame); |
| 297 } | 298 } |
| 298 | 299 |
| 299 // Compute the state and type of an exit frame given a frame | 300 // Compute the state and type of an exit frame given a frame |
| 300 // pointer. Used when constructing the first stack frame seen by an | 301 // pointer. Used when constructing the first stack frame seen by an |
| 301 // iterator and the frames following entry frames. | 302 // iterator and the frames following entry frames. |
| 302 static Type GetStateForFramePointer(Address fp, State* state); | 303 static Type GetStateForFramePointer(Address fp, State* state); |
| 304 static Address ComputeStackPointer(Address fp); |
| 305 static void FillState(Address fp, Address sp, State* state); |
| 303 | 306 |
| 304 protected: | 307 protected: |
| 305 explicit ExitFrame(StackFrameIterator* iterator) : StackFrame(iterator) { } | 308 explicit ExitFrame(StackFrameIterator* iterator) : StackFrame(iterator) { } |
| 306 | 309 |
| 307 virtual Address GetCallerStackPointer() const; | 310 virtual Address GetCallerStackPointer() const; |
| 308 | 311 |
| 309 private: | 312 private: |
| 310 virtual void ComputeCallerState(State* state) const; | 313 virtual void ComputeCallerState(State* state) const; |
| 311 | 314 |
| 312 friend class StackFrameIterator; | 315 friend class StackFrameIterator; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 // A shortcoming is that caller's SP value will be calculated incorrectly | 429 // A shortcoming is that caller's SP value will be calculated incorrectly |
| 427 // (see GetCallerStackPointer implementation), but it is not used for stack | 430 // (see GetCallerStackPointer implementation), but it is not used for stack |
| 428 // sampling. | 431 // sampling. |
| 429 void DisableHeapAccess() { disable_heap_access_ = true; } | 432 void DisableHeapAccess() { disable_heap_access_ = true; } |
| 430 | 433 |
| 431 private: | 434 private: |
| 432 bool disable_heap_access_; | 435 bool disable_heap_access_; |
| 433 inline Object* function_slot_object() const; | 436 inline Object* function_slot_object() const; |
| 434 | 437 |
| 435 friend class StackFrameIterator; | 438 friend class StackFrameIterator; |
| 439 friend class StackTracer; |
| 436 }; | 440 }; |
| 437 | 441 |
| 438 | 442 |
| 439 // Arguments adaptor frames are automatically inserted below | 443 // Arguments adaptor frames are automatically inserted below |
| 440 // JavaScript frames when the actual number of parameters does not | 444 // JavaScript frames when the actual number of parameters does not |
| 441 // match the formal number of parameters. | 445 // match the formal number of parameters. |
| 442 class ArgumentsAdaptorFrame: public JavaScriptFrame { | 446 class ArgumentsAdaptorFrame: public JavaScriptFrame { |
| 443 public: | 447 public: |
| 444 virtual Type type() const { return ARGUMENTS_ADAPTOR; } | 448 virtual Type type() const { return ARGUMENTS_ADAPTOR; } |
| 445 | 449 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 | 639 |
| 636 void Advance(); | 640 void Advance(); |
| 637 void Reset(); | 641 void Reset(); |
| 638 | 642 |
| 639 static bool IsWithinBounds( | 643 static bool IsWithinBounds( |
| 640 Address low_bound, Address high_bound, Address addr) { | 644 Address low_bound, Address high_bound, Address addr) { |
| 641 return low_bound <= addr && addr <= high_bound; | 645 return low_bound <= addr && addr <= high_bound; |
| 642 } | 646 } |
| 643 | 647 |
| 644 private: | 648 private: |
| 649 class StackAddressValidator { |
| 650 public: |
| 651 StackAddressValidator(Address low_bound, Address high_bound) |
| 652 : low_bound_(low_bound), high_bound_(high_bound) { } |
| 653 bool IsValid(Address addr) const { |
| 654 return IsWithinBounds(low_bound_, high_bound_, addr); |
| 655 } |
| 656 private: |
| 657 Address low_bound_; |
| 658 Address high_bound_; |
| 659 }; |
| 660 |
| 661 class ExitFrameValidator { |
| 662 public: |
| 663 explicit ExitFrameValidator(const StackAddressValidator& validator) |
| 664 : validator_(validator) { } |
| 665 ExitFrameValidator(Address low_bound, Address high_bound) |
| 666 : validator_(low_bound, high_bound) { } |
| 667 bool IsValidFP(Address fp); |
| 668 private: |
| 669 StackAddressValidator validator_; |
| 670 }; |
| 671 |
| 645 bool IsValidStackAddress(Address addr) const { | 672 bool IsValidStackAddress(Address addr) const { |
| 646 return IsWithinBounds(low_bound_, high_bound_, addr); | 673 return stack_validator_.IsValid(addr); |
| 647 } | 674 } |
| 648 bool CanIterateHandles(StackFrame* frame, StackHandler* handler); | 675 bool CanIterateHandles(StackFrame* frame, StackHandler* handler); |
| 649 bool IsValidFrame(StackFrame* frame) const; | 676 bool IsValidFrame(StackFrame* frame) const; |
| 650 bool IsValidCaller(StackFrame* frame); | 677 bool IsValidCaller(StackFrame* frame); |
| 678 static bool IsValidTop(Address low_bound, Address high_bound); |
| 651 | 679 |
| 652 Address low_bound_; | 680 StackAddressValidator stack_validator_; |
| 653 Address high_bound_; | |
| 654 const bool is_valid_top_; | 681 const bool is_valid_top_; |
| 655 const bool is_valid_fp_; | 682 const bool is_valid_fp_; |
| 656 const bool is_working_iterator_; | 683 const bool is_working_iterator_; |
| 657 bool iteration_done_; | 684 bool iteration_done_; |
| 658 StackFrameIterator iterator_; | 685 StackFrameIterator iterator_; |
| 659 }; | 686 }; |
| 660 | 687 |
| 661 | 688 |
| 662 #ifdef ENABLE_LOGGING_AND_PROFILING | 689 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 663 typedef JavaScriptFrameIteratorTemp<SafeStackFrameIterator> | 690 typedef JavaScriptFrameIteratorTemp<SafeStackFrameIterator> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 684 }; | 711 }; |
| 685 | 712 |
| 686 | 713 |
| 687 // Reads all frames on the current stack and copies them into the current | 714 // Reads all frames on the current stack and copies them into the current |
| 688 // zone memory. | 715 // zone memory. |
| 689 Vector<StackFrame*> CreateStackMap(); | 716 Vector<StackFrame*> CreateStackMap(); |
| 690 | 717 |
| 691 } } // namespace v8::internal | 718 } } // namespace v8::internal |
| 692 | 719 |
| 693 #endif // V8_FRAMES_H_ | 720 #endif // V8_FRAMES_H_ |
| OLD | NEW |