| 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 10 matching lines...) Expand all Loading... |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_FRAMES_H_ | 28 #ifndef V8_FRAMES_H_ |
| 29 #define V8_FRAMES_H_ | 29 #define V8_FRAMES_H_ |
| 30 | 30 |
| 31 #include "handles.h" |
| 32 |
| 31 namespace v8 { | 33 namespace v8 { |
| 32 namespace internal { | 34 namespace internal { |
| 33 | 35 |
| 34 typedef uint32_t RegList; | 36 typedef uint32_t RegList; |
| 35 | 37 |
| 36 // Get the number of registers in a given register list. | 38 // Get the number of registers in a given register list. |
| 37 int NumRegs(RegList list); | 39 int NumRegs(RegList list); |
| 38 | 40 |
| 39 // Return the code of the n-th saved register available to JavaScript. | 41 // Return the code of the n-th saved register available to JavaScript. |
| 40 int JSCallerSavedCode(int n); | 42 int JSCallerSavedCode(int n); |
| 41 | 43 |
| 42 | 44 |
| 43 // Forward declarations. | 45 // Forward declarations. |
| 44 class StackFrameIterator; | 46 class StackFrameIterator; |
| 45 class ThreadLocalTop; | 47 class ThreadLocalTop; |
| 46 class Isolate; | 48 class Isolate; |
| 47 | 49 |
| 48 class PcToCodeCache { | 50 class PcToCodeCache { |
| 49 public: | 51 public: |
| 50 struct PcToCodeCacheEntry { | 52 struct PcToCodeCacheEntry { |
| 51 Address pc; | 53 Address pc; |
| 52 Code* code; | 54 Code* code; |
| 55 uint8_t* safepoint_entry; |
| 53 }; | 56 }; |
| 54 | 57 |
| 55 explicit PcToCodeCache(Isolate* isolate) : isolate_(isolate) {} | 58 explicit PcToCodeCache(Isolate* isolate) : isolate_(isolate) { |
| 59 Flush(); |
| 60 } |
| 56 | 61 |
| 57 Code* GcSafeFindCodeForPc(Address pc); | 62 Code* GcSafeFindCodeForPc(Address pc); |
| 58 Code* GcSafeCastToCode(HeapObject* object, Address pc); | 63 Code* GcSafeCastToCode(HeapObject* object, Address pc); |
| 59 | 64 |
| 60 void Flush() { | 65 void Flush() { |
| 61 memset(&cache_[0], 0, sizeof(cache_)); | 66 memset(&cache_[0], 0, sizeof(cache_)); |
| 62 } | 67 } |
| 63 | 68 |
| 64 PcToCodeCacheEntry* GetCacheEntry(Address pc); | 69 PcToCodeCacheEntry* GetCacheEntry(Address pc); |
| 65 | 70 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 116 |
| 112 DISALLOW_IMPLICIT_CONSTRUCTORS(StackHandler); | 117 DISALLOW_IMPLICIT_CONSTRUCTORS(StackHandler); |
| 113 }; | 118 }; |
| 114 | 119 |
| 115 | 120 |
| 116 #define STACK_FRAME_TYPE_LIST(V) \ | 121 #define STACK_FRAME_TYPE_LIST(V) \ |
| 117 V(ENTRY, EntryFrame) \ | 122 V(ENTRY, EntryFrame) \ |
| 118 V(ENTRY_CONSTRUCT, EntryConstructFrame) \ | 123 V(ENTRY_CONSTRUCT, EntryConstructFrame) \ |
| 119 V(EXIT, ExitFrame) \ | 124 V(EXIT, ExitFrame) \ |
| 120 V(JAVA_SCRIPT, JavaScriptFrame) \ | 125 V(JAVA_SCRIPT, JavaScriptFrame) \ |
| 126 V(OPTIMIZED, OptimizedFrame) \ |
| 121 V(INTERNAL, InternalFrame) \ | 127 V(INTERNAL, InternalFrame) \ |
| 122 V(CONSTRUCT, ConstructFrame) \ | 128 V(CONSTRUCT, ConstructFrame) \ |
| 123 V(ARGUMENTS_ADAPTOR, ArgumentsAdaptorFrame) | 129 V(ARGUMENTS_ADAPTOR, ArgumentsAdaptorFrame) |
| 124 | 130 |
| 125 | 131 |
| 126 // Abstract base class for all stack frames. | 132 // Abstract base class for all stack frames. |
| 127 class StackFrame BASE_EMBEDDED { | 133 class StackFrame BASE_EMBEDDED { |
| 128 public: | 134 public: |
| 129 #define DECLARE_TYPE(type, ignore) type, | 135 #define DECLARE_TYPE(type, ignore) type, |
| 130 enum Type { | 136 enum Type { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 154 // Copy constructor; it breaks the connection to host iterator. | 160 // Copy constructor; it breaks the connection to host iterator. |
| 155 StackFrame(const StackFrame& original) { | 161 StackFrame(const StackFrame& original) { |
| 156 this->state_ = original.state_; | 162 this->state_ = original.state_; |
| 157 this->iterator_ = NULL; | 163 this->iterator_ = NULL; |
| 158 } | 164 } |
| 159 | 165 |
| 160 // Type testers. | 166 // Type testers. |
| 161 bool is_entry() const { return type() == ENTRY; } | 167 bool is_entry() const { return type() == ENTRY; } |
| 162 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; } | 168 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; } |
| 163 bool is_exit() const { return type() == EXIT; } | 169 bool is_exit() const { return type() == EXIT; } |
| 164 bool is_java_script() const { return type() == JAVA_SCRIPT; } | 170 bool is_optimized() const { return type() == OPTIMIZED; } |
| 165 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } | 171 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } |
| 166 bool is_internal() const { return type() == INTERNAL; } | 172 bool is_internal() const { return type() == INTERNAL; } |
| 167 bool is_construct() const { return type() == CONSTRUCT; } | 173 bool is_construct() const { return type() == CONSTRUCT; } |
| 168 virtual bool is_standard() const { return false; } | 174 virtual bool is_standard() const { return false; } |
| 169 | 175 |
| 176 bool is_java_script() const { |
| 177 Type type = this->type(); |
| 178 return (type == JAVA_SCRIPT) || (type == OPTIMIZED); |
| 179 } |
| 180 |
| 170 // Accessors. | 181 // Accessors. |
| 171 Address sp() const { return state_.sp; } | 182 Address sp() const { return state_.sp; } |
| 172 Address fp() const { return state_.fp; } | 183 Address fp() const { return state_.fp; } |
| 173 Address caller_sp() const { return GetCallerStackPointer(); } | 184 Address caller_sp() const { return GetCallerStackPointer(); } |
| 174 | 185 |
| 175 Address pc() const { return *pc_address(); } | 186 Address pc() const { return *pc_address(); } |
| 176 void set_pc(Address pc) { *pc_address() = pc; } | 187 void set_pc(Address pc) { *pc_address() = pc; } |
| 177 | 188 |
| 178 virtual void SetCallerFp(Address caller_fp) = 0; | 189 virtual void SetCallerFp(Address caller_fp) = 0; |
| 179 | 190 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 193 virtual Code* unchecked_code() const = 0; | 204 virtual Code* unchecked_code() const = 0; |
| 194 | 205 |
| 195 // Get the code associated with this frame. | 206 // Get the code associated with this frame. |
| 196 Code* LookupCode(Isolate* isolate) const { | 207 Code* LookupCode(Isolate* isolate) const { |
| 197 return GetContainingCode(isolate, pc()); | 208 return GetContainingCode(isolate, pc()); |
| 198 } | 209 } |
| 199 | 210 |
| 200 // Get the code object that contains the given pc. | 211 // Get the code object that contains the given pc. |
| 201 static inline Code* GetContainingCode(Isolate* isolate, Address pc); | 212 static inline Code* GetContainingCode(Isolate* isolate, Address pc); |
| 202 | 213 |
| 214 // Get the code object containing the given pc and fill in the |
| 215 // safepoint entry and the number of stack slots. The pc must be at |
| 216 // a safepoint. |
| 217 static Code* GetSafepointData(Address pc, |
| 218 uint8_t** safepoint_entry, |
| 219 unsigned* stack_slots); |
| 220 |
| 203 virtual void Iterate(ObjectVisitor* v) const = 0; | 221 virtual void Iterate(ObjectVisitor* v) const = 0; |
| 204 static void IteratePc(ObjectVisitor* v, Address* pc_address, Code* holder); | 222 static void IteratePc(ObjectVisitor* v, Address* pc_address, Code* holder); |
| 205 | 223 |
| 206 | 224 |
| 207 // Printing support. | 225 // Printing support. |
| 208 enum PrintMode { OVERVIEW, DETAILS }; | 226 enum PrintMode { OVERVIEW, DETAILS }; |
| 209 virtual void Print(StringStream* accumulator, | 227 virtual void Print(StringStream* accumulator, |
| 210 PrintMode mode, | 228 PrintMode mode, |
| 211 int index) const { } | 229 int index) const { } |
| 212 | 230 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 // Determines if the standard frame for the given frame pointer is a | 407 // Determines if the standard frame for the given frame pointer is a |
| 390 // construct frame. | 408 // construct frame. |
| 391 static inline bool IsConstructFrame(Address fp); | 409 static inline bool IsConstructFrame(Address fp); |
| 392 | 410 |
| 393 private: | 411 private: |
| 394 friend class StackFrame; | 412 friend class StackFrame; |
| 395 friend class StackFrameIterator; | 413 friend class StackFrameIterator; |
| 396 }; | 414 }; |
| 397 | 415 |
| 398 | 416 |
| 417 class FrameSummary BASE_EMBEDDED { |
| 418 public: |
| 419 FrameSummary(Object* receiver, |
| 420 JSFunction* function, |
| 421 Code* code, |
| 422 int offset, |
| 423 bool is_constructor) |
| 424 : receiver_(receiver), |
| 425 function_(function), |
| 426 code_(code), |
| 427 offset_(offset), |
| 428 is_constructor_(is_constructor) { } |
| 429 Handle<Object> receiver() { return receiver_; } |
| 430 Handle<JSFunction> function() { return function_; } |
| 431 Handle<Code> code() { return code_; } |
| 432 Address pc() { return reinterpret_cast<Address>(*code_) + offset_; } |
| 433 int offset() { return offset_; } |
| 434 bool is_constructor() { return is_constructor_; } |
| 435 |
| 436 void Print(); |
| 437 |
| 438 private: |
| 439 Handle<Object> receiver_; |
| 440 Handle<JSFunction> function_; |
| 441 Handle<Code> code_; |
| 442 int offset_; |
| 443 bool is_constructor_; |
| 444 }; |
| 445 |
| 446 |
| 399 class JavaScriptFrame: public StandardFrame { | 447 class JavaScriptFrame: public StandardFrame { |
| 400 public: | 448 public: |
| 401 virtual Type type() const { return JAVA_SCRIPT; } | 449 virtual Type type() const { return JAVA_SCRIPT; } |
| 402 | 450 |
| 403 // Accessors. | 451 // Accessors. |
| 404 inline Object* function() const; | 452 inline Object* function() const; |
| 405 inline Object* receiver() const; | 453 inline Object* receiver() const; |
| 406 inline void set_receiver(Object* value); | 454 inline void set_receiver(Object* value); |
| 407 | 455 |
| 408 // Access the parameters. | 456 // Access the parameters. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 427 virtual void Iterate(ObjectVisitor* v) const; | 475 virtual void Iterate(ObjectVisitor* v) const; |
| 428 | 476 |
| 429 // Printing support. | 477 // Printing support. |
| 430 virtual void Print(StringStream* accumulator, | 478 virtual void Print(StringStream* accumulator, |
| 431 PrintMode mode, | 479 PrintMode mode, |
| 432 int index) const; | 480 int index) const; |
| 433 | 481 |
| 434 // Determine the code for the frame. | 482 // Determine the code for the frame. |
| 435 virtual Code* unchecked_code() const; | 483 virtual Code* unchecked_code() const; |
| 436 | 484 |
| 485 // Return a list with JSFunctions of this frame. |
| 486 virtual void GetFunctions(List<JSFunction*>* functions); |
| 487 |
| 488 // Build a list with summaries for this frame including all inlined frames. |
| 489 virtual void Summarize(List<FrameSummary>* frames); |
| 490 |
| 437 static JavaScriptFrame* cast(StackFrame* frame) { | 491 static JavaScriptFrame* cast(StackFrame* frame) { |
| 438 ASSERT(frame->is_java_script()); | 492 ASSERT(frame->is_java_script()); |
| 439 return static_cast<JavaScriptFrame*>(frame); | 493 return static_cast<JavaScriptFrame*>(frame); |
| 440 } | 494 } |
| 441 | 495 |
| 442 protected: | 496 protected: |
| 443 explicit JavaScriptFrame(StackFrameIterator* iterator) | 497 explicit JavaScriptFrame(StackFrameIterator* iterator) |
| 444 : StandardFrame(iterator) { } | 498 : StandardFrame(iterator) { } |
| 445 | 499 |
| 446 virtual Address GetCallerStackPointer() const; | 500 virtual Address GetCallerStackPointer() const; |
| 447 | 501 |
| 502 // Garbage collection support. Iterates over incoming arguments, |
| 503 // receiver, and any callee-saved registers. |
| 504 void IterateArguments(ObjectVisitor* v) const; |
| 505 |
| 448 private: | 506 private: |
| 449 inline Object* function_slot_object() const; | 507 inline Object* function_slot_object() const; |
| 450 | 508 |
| 451 friend class StackFrameIterator; | 509 friend class StackFrameIterator; |
| 452 friend class StackTracer; | 510 friend class StackTracer; |
| 453 }; | 511 }; |
| 454 | 512 |
| 455 | 513 |
| 514 class OptimizedFrame : public JavaScriptFrame { |
| 515 public: |
| 516 virtual Type type() const { return OPTIMIZED; } |
| 517 |
| 518 // GC support. |
| 519 virtual void Iterate(ObjectVisitor* v) const; |
| 520 |
| 521 // Return a list with JSFunctions of this frame. |
| 522 // The functions are ordered bottom-to-top (i.e. functions.last() |
| 523 // is the top-most activation) |
| 524 virtual void GetFunctions(List<JSFunction*>* functions); |
| 525 |
| 526 virtual void Summarize(List<FrameSummary>* frames); |
| 527 |
| 528 DeoptimizationInputData* GetDeoptimizationData(int* deopt_index); |
| 529 |
| 530 protected: |
| 531 explicit OptimizedFrame(StackFrameIterator* iterator) |
| 532 : JavaScriptFrame(iterator) { } |
| 533 |
| 534 private: |
| 535 friend class StackFrameIterator; |
| 536 }; |
| 537 |
| 538 |
| 456 // Arguments adaptor frames are automatically inserted below | 539 // Arguments adaptor frames are automatically inserted below |
| 457 // JavaScript frames when the actual number of parameters does not | 540 // JavaScript frames when the actual number of parameters does not |
| 458 // match the formal number of parameters. | 541 // match the formal number of parameters. |
| 459 class ArgumentsAdaptorFrame: public JavaScriptFrame { | 542 class ArgumentsAdaptorFrame: public JavaScriptFrame { |
| 460 public: | 543 public: |
| 461 virtual Type type() const { return ARGUMENTS_ADAPTOR; } | 544 virtual Type type() const { return ARGUMENTS_ADAPTOR; } |
| 462 | 545 |
| 463 // Determine the code for the frame. | 546 // Determine the code for the frame. |
| 464 virtual Code* unchecked_code() const; | 547 virtual Code* unchecked_code() const; |
| 465 | 548 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 public: | 616 public: |
| 534 // An iterator that iterates over the current thread's stack. | 617 // An iterator that iterates over the current thread's stack. |
| 535 StackFrameIterator(); | 618 StackFrameIterator(); |
| 536 | 619 |
| 537 // An iterator that iterates over a given thread's stack. | 620 // An iterator that iterates over a given thread's stack. |
| 538 explicit StackFrameIterator(ThreadLocalTop* thread); | 621 explicit StackFrameIterator(ThreadLocalTop* thread); |
| 539 | 622 |
| 540 // An iterator that can start from a given FP address. | 623 // An iterator that can start from a given FP address. |
| 541 // If use_top, then work as usual, if fp isn't NULL, use it, | 624 // If use_top, then work as usual, if fp isn't NULL, use it, |
| 542 // otherwise, do nothing. | 625 // otherwise, do nothing. |
| 543 StackFrameIterator(bool use_top, Address fp, Address sp); | 626 StackFrameIterator(Isolate* isolate, bool use_top, Address fp, Address sp); |
| 544 | 627 |
| 545 StackFrame* frame() const { | 628 StackFrame* frame() const { |
| 546 ASSERT(!done()); | 629 ASSERT(!done()); |
| 547 return frame_; | 630 return frame_; |
| 548 } | 631 } |
| 549 | 632 |
| 550 bool done() const { return frame_ == NULL; } | 633 bool done() const { return frame_ == NULL; } |
| 551 void Advance() { (this->*advance_)(); } | 634 void Advance() { (this->*advance_)(); } |
| 552 | 635 |
| 553 // Go back to the first frame. | 636 // Go back to the first frame. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 | 679 |
| 597 // Skip frames until the frame with the given id is reached. | 680 // Skip frames until the frame with the given id is reached. |
| 598 explicit JavaScriptFrameIteratorTemp(StackFrame::Id id); | 681 explicit JavaScriptFrameIteratorTemp(StackFrame::Id id); |
| 599 | 682 |
| 600 JavaScriptFrameIteratorTemp(Address fp, Address sp, | 683 JavaScriptFrameIteratorTemp(Address fp, Address sp, |
| 601 Address low_bound, Address high_bound) : | 684 Address low_bound, Address high_bound) : |
| 602 iterator_(fp, sp, low_bound, high_bound) { | 685 iterator_(fp, sp, low_bound, high_bound) { |
| 603 if (!done()) Advance(); | 686 if (!done()) Advance(); |
| 604 } | 687 } |
| 605 | 688 |
| 689 JavaScriptFrameIteratorTemp(Isolate* isolate, |
| 690 Address fp, Address sp, |
| 691 Address low_bound, Address high_bound) : |
| 692 iterator_(isolate, fp, sp, low_bound, high_bound) { |
| 693 if (!done()) Advance(); |
| 694 } |
| 695 |
| 606 inline JavaScriptFrame* frame() const; | 696 inline JavaScriptFrame* frame() const; |
| 607 | 697 |
| 608 bool done() const { return iterator_.done(); } | 698 bool done() const { return iterator_.done(); } |
| 609 void Advance(); | 699 void Advance(); |
| 610 | 700 |
| 611 // Advance to the frame holding the arguments for the current | 701 // Advance to the frame holding the arguments for the current |
| 612 // frame. This only affects the current frame if it has adapted | 702 // frame. This only affects the current frame if it has adapted |
| 613 // arguments. | 703 // arguments. |
| 614 void AdvanceToArgumentsFrame(); | 704 void AdvanceToArgumentsFrame(); |
| 615 | 705 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 633 StackTraceFrameIterator(); | 723 StackTraceFrameIterator(); |
| 634 void Advance(); | 724 void Advance(); |
| 635 | 725 |
| 636 private: | 726 private: |
| 637 bool IsValidFrame(); | 727 bool IsValidFrame(); |
| 638 }; | 728 }; |
| 639 | 729 |
| 640 | 730 |
| 641 class SafeStackFrameIterator BASE_EMBEDDED { | 731 class SafeStackFrameIterator BASE_EMBEDDED { |
| 642 public: | 732 public: |
| 643 SafeStackFrameIterator(Address fp, Address sp, | 733 SafeStackFrameIterator(Isolate* isolate, |
| 734 Address fp, Address sp, |
| 644 Address low_bound, Address high_bound); | 735 Address low_bound, Address high_bound); |
| 645 | 736 |
| 646 StackFrame* frame() const { | 737 StackFrame* frame() const { |
| 647 ASSERT(is_working_iterator_); | 738 ASSERT(is_working_iterator_); |
| 648 return iterator_.frame(); | 739 return iterator_.frame(); |
| 649 } | 740 } |
| 650 | 741 |
| 651 bool done() const { return iteration_done_ ? true : iterator_.done(); } | 742 bool done() const { return iteration_done_ ? true : iterator_.done(); } |
| 652 | 743 |
| 653 void Advance(); | 744 void Advance(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 683 private: | 774 private: |
| 684 StackAddressValidator validator_; | 775 StackAddressValidator validator_; |
| 685 }; | 776 }; |
| 686 | 777 |
| 687 bool IsValidStackAddress(Address addr) const { | 778 bool IsValidStackAddress(Address addr) const { |
| 688 return stack_validator_.IsValid(addr); | 779 return stack_validator_.IsValid(addr); |
| 689 } | 780 } |
| 690 bool CanIterateHandles(StackFrame* frame, StackHandler* handler); | 781 bool CanIterateHandles(StackFrame* frame, StackHandler* handler); |
| 691 bool IsValidFrame(StackFrame* frame) const; | 782 bool IsValidFrame(StackFrame* frame) const; |
| 692 bool IsValidCaller(StackFrame* frame); | 783 bool IsValidCaller(StackFrame* frame); |
| 693 static bool IsValidTop(Address low_bound, Address high_bound); | 784 static bool IsValidTop(Isolate* isolate, |
| 785 Address low_bound, Address high_bound); |
| 694 | 786 |
| 695 // This is a nasty hack to make sure the active count is incremented | 787 // This is a nasty hack to make sure the active count is incremented |
| 696 // before the constructor for the embedded iterator is invoked. This | 788 // before the constructor for the embedded iterator is invoked. This |
| 697 // is needed because the constructor will start looking at frames | 789 // is needed because the constructor will start looking at frames |
| 698 // right away and we need to make sure it doesn't start inspecting | 790 // right away and we need to make sure it doesn't start inspecting |
| 699 // heap objects. | 791 // heap objects. |
| 700 class ActiveCountMaintainer BASE_EMBEDDED { | 792 class ActiveCountMaintainer BASE_EMBEDDED { |
| 701 public: | 793 public: |
| 702 ActiveCountMaintainer() { active_count_++; } | 794 ActiveCountMaintainer() { active_count_++; } |
| 703 ~ActiveCountMaintainer() { active_count_--; } | 795 ~ActiveCountMaintainer() { active_count_--; } |
| 704 }; | 796 }; |
| 705 | 797 |
| 706 ActiveCountMaintainer maintainer_; | 798 ActiveCountMaintainer maintainer_; |
| 799 // TODO(isolates): this is dangerous. |
| 707 static int active_count_; | 800 static int active_count_; |
| 708 StackAddressValidator stack_validator_; | 801 StackAddressValidator stack_validator_; |
| 709 const bool is_valid_top_; | 802 const bool is_valid_top_; |
| 710 const bool is_valid_fp_; | 803 const bool is_valid_fp_; |
| 711 const bool is_working_iterator_; | 804 const bool is_working_iterator_; |
| 712 bool iteration_done_; | 805 bool iteration_done_; |
| 713 StackFrameIterator iterator_; | 806 StackFrameIterator iterator_; |
| 714 }; | 807 }; |
| 715 | 808 |
| 716 | 809 |
| 717 #ifdef ENABLE_LOGGING_AND_PROFILING | 810 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 718 typedef JavaScriptFrameIteratorTemp<SafeStackFrameIterator> | 811 typedef JavaScriptFrameIteratorTemp<SafeStackFrameIterator> |
| 719 SafeJavaScriptFrameIterator; | 812 SafeJavaScriptFrameIterator; |
| 720 | 813 |
| 721 | 814 |
| 722 class SafeStackTraceFrameIterator: public SafeJavaScriptFrameIterator { | 815 class SafeStackTraceFrameIterator: public SafeJavaScriptFrameIterator { |
| 723 public: | 816 public: |
| 724 explicit SafeStackTraceFrameIterator(Address fp, Address sp, | 817 explicit SafeStackTraceFrameIterator(Isolate* isolate, |
| 818 Address fp, Address sp, |
| 725 Address low_bound, Address high_bound); | 819 Address low_bound, Address high_bound); |
| 726 void Advance(); | 820 void Advance(); |
| 727 }; | 821 }; |
| 728 #endif | 822 #endif |
| 729 | 823 |
| 730 | 824 |
| 731 class StackFrameLocator BASE_EMBEDDED { | 825 class StackFrameLocator BASE_EMBEDDED { |
| 732 public: | 826 public: |
| 733 // Find the nth JavaScript frame on the stack. The caller must | 827 // Find the nth JavaScript frame on the stack. The caller must |
| 734 // guarantee that such a frame exists. | 828 // guarantee that such a frame exists. |
| 735 JavaScriptFrame* FindJavaScriptFrame(int n); | 829 JavaScriptFrame* FindJavaScriptFrame(int n); |
| 736 | 830 |
| 737 private: | 831 private: |
| 738 StackFrameIterator iterator_; | 832 StackFrameIterator iterator_; |
| 739 }; | 833 }; |
| 740 | 834 |
| 741 | 835 |
| 742 // Reads all frames on the current stack and copies them into the current | 836 // Reads all frames on the current stack and copies them into the current |
| 743 // zone memory. | 837 // zone memory. |
| 744 Vector<StackFrame*> CreateStackMap(); | 838 Vector<StackFrame*> CreateStackMap(); |
| 745 | 839 |
| 746 } } // namespace v8::internal | 840 } } // namespace v8::internal |
| 747 | 841 |
| 748 #endif // V8_FRAMES_H_ | 842 #endif // V8_FRAMES_H_ |
| OLD | NEW |