Chromium Code Reviews| 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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 | 314 |
| 315 // Printing support. | 315 // Printing support. |
| 316 static void PrintIndex(StringStream* accumulator, | 316 static void PrintIndex(StringStream* accumulator, |
| 317 PrintMode mode, | 317 PrintMode mode, |
| 318 int index); | 318 int index); |
| 319 | 319 |
| 320 // Get the top handler from the current stack iterator. | 320 // Get the top handler from the current stack iterator. |
| 321 inline StackHandler* top_handler() const; | 321 inline StackHandler* top_handler() const; |
| 322 | 322 |
| 323 // Compute the stack frame type for the given state. | 323 // Compute the stack frame type for the given state. |
| 324 static Type ComputeType(Isolate* isolate, State* state); | 324 static Type ComputeType(const StackFrameIterator* iterator, State* state); |
| 325 | |
| 326 #ifdef DEBUG | |
| 327 bool is_safe_iteration() const; | |
| 328 #endif | |
| 325 | 329 |
| 326 private: | 330 private: |
| 327 const StackFrameIterator* iterator_; | 331 const StackFrameIterator* iterator_; |
| 328 Isolate* isolate_; | 332 Isolate* isolate_; |
| 329 State state_; | 333 State state_; |
| 330 | 334 |
| 331 // Fill in the state of the calling frame. | 335 // Fill in the state of the calling frame. |
| 332 virtual void ComputeCallerState(State* state) const = 0; | 336 virtual void ComputeCallerState(State* state) const = 0; |
| 333 | 337 |
| 334 // Get the type and the state of the calling frame. | 338 // Get the type and the state of the calling frame. |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 775 | 779 |
| 776 | 780 |
| 777 class StackFrameIterator BASE_EMBEDDED { | 781 class StackFrameIterator BASE_EMBEDDED { |
| 778 public: | 782 public: |
| 779 // An iterator that iterates over the isolate's current thread's stack, | 783 // An iterator that iterates over the isolate's current thread's stack, |
| 780 explicit StackFrameIterator(Isolate* isolate); | 784 explicit StackFrameIterator(Isolate* isolate); |
| 781 | 785 |
| 782 // An iterator that iterates over a given thread's stack. | 786 // An iterator that iterates over a given thread's stack. |
| 783 StackFrameIterator(Isolate* isolate, ThreadLocalTop* t); | 787 StackFrameIterator(Isolate* isolate, ThreadLocalTop* t); |
| 784 | 788 |
| 785 // An iterator that can start from a given FP address. | |
| 786 // If use_top, then work as usual, if fp isn't NULL, use it, | |
| 787 // otherwise, do nothing. | |
| 788 StackFrameIterator(Isolate* isolate, bool use_top, Address fp, Address sp); | |
| 789 | |
| 790 StackFrame* frame() const { | 789 StackFrame* frame() const { |
| 791 ASSERT(!done()); | 790 ASSERT(!done()); |
| 792 return frame_; | 791 return frame_; |
| 793 } | 792 } |
| 794 | 793 |
| 795 Isolate* isolate() const { return isolate_; } | 794 Isolate* isolate() const { return isolate_; } |
| 796 | 795 |
| 797 bool done() const { return frame_ == NULL; } | 796 bool done() const { return frame_ == NULL; } |
| 798 void Advance() { (this->*advance_)(); } | 797 void Advance() { (this->*advance_)(); } |
| 799 | 798 |
| 800 private: | 799 private: |
| 800 // An iterator that can start from a given FP address. | |
| 801 // If use_top, then work as usual, if fp isn't NULL, use it, | |
| 802 // otherwise, do nothing. This constructor is used to create | |
| 803 // StackFrameIterator for "safe" stack iteration. | |
| 804 StackFrameIterator(Isolate* isolate, bool use_top, Address fp, Address sp); | |
| 805 | |
| 801 // Go back to the first frame. | 806 // Go back to the first frame. |
| 802 void Reset(); | 807 void Reset(); |
| 803 | 808 |
| 804 Isolate* isolate_; | 809 Isolate* isolate_; |
| 805 #define DECLARE_SINGLETON(ignore, type) type type##_; | 810 #define DECLARE_SINGLETON(ignore, type) type type##_; |
| 806 STACK_FRAME_TYPE_LIST(DECLARE_SINGLETON) | 811 STACK_FRAME_TYPE_LIST(DECLARE_SINGLETON) |
| 807 #undef DECLARE_SINGLETON | 812 #undef DECLARE_SINGLETON |
| 808 StackFrame* frame_; | 813 StackFrame* frame_; |
| 809 StackHandler* handler_; | 814 StackHandler* handler_; |
| 810 ThreadLocalTop* thread_; | 815 ThreadLocalTop* thread_; |
| 811 Address fp_; | 816 Address fp_; |
| 812 Address sp_; | 817 Address sp_; |
| 813 void (StackFrameIterator::*advance_)(); | 818 void (StackFrameIterator::*advance_)(); |
| 819 const bool is_safe_iterator_; | |
|
loislo
2013/06/25 09:36:26
I'd call it 'can_use_heap_objects_'
yurys
2013/06/25 09:44:17
Done. Thank you.
| |
| 814 | 820 |
| 815 StackHandler* handler() const { | 821 StackHandler* handler() const { |
| 816 ASSERT(!done()); | 822 ASSERT(!done()); |
| 817 return handler_; | 823 return handler_; |
| 818 } | 824 } |
| 819 | 825 |
| 820 // Get the type-specific frame singleton in a given state. | 826 // Get the type-specific frame singleton in a given state. |
| 821 StackFrame* SingletonFor(StackFrame::Type type, StackFrame::State* state); | 827 StackFrame* SingletonFor(StackFrame::Type type, StackFrame::State* state); |
| 822 // A helper function, can return a NULL pointer. | 828 // A helper function, can return a NULL pointer. |
| 823 StackFrame* SingletonFor(StackFrame::Type type); | 829 StackFrame* SingletonFor(StackFrame::Type type); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 872 public: | 878 public: |
| 873 SafeStackFrameIterator(Isolate* isolate, | 879 SafeStackFrameIterator(Isolate* isolate, |
| 874 Address fp, Address sp, | 880 Address fp, Address sp, |
| 875 Address low_bound, Address high_bound); | 881 Address low_bound, Address high_bound); |
| 876 | 882 |
| 877 inline JavaScriptFrame* frame() const; | 883 inline JavaScriptFrame* frame() const; |
| 878 | 884 |
| 879 bool done() const { return iteration_done_ || iterator_.done(); } | 885 bool done() const { return iteration_done_ || iterator_.done(); } |
| 880 void Advance(); | 886 void Advance(); |
| 881 | 887 |
| 882 static bool is_active(Isolate* isolate); | |
| 883 | |
| 884 private: | 888 private: |
| 885 void AdvanceOneFrame(); | 889 void AdvanceOneFrame(); |
| 886 | 890 |
| 887 static bool IsWithinBounds( | 891 static bool IsWithinBounds( |
| 888 Address low_bound, Address high_bound, Address addr) { | 892 Address low_bound, Address high_bound, Address addr) { |
| 889 return low_bound <= addr && addr <= high_bound; | 893 return low_bound <= addr && addr <= high_bound; |
| 890 } | 894 } |
| 891 | 895 |
| 892 class StackAddressValidator { | 896 class StackAddressValidator { |
| 893 public: | 897 public: |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 914 | 918 |
| 915 bool IsValidStackAddress(Address addr) const { | 919 bool IsValidStackAddress(Address addr) const { |
| 916 return stack_validator_.IsValid(addr); | 920 return stack_validator_.IsValid(addr); |
| 917 } | 921 } |
| 918 bool CanIterateHandles(StackFrame* frame, StackHandler* handler); | 922 bool CanIterateHandles(StackFrame* frame, StackHandler* handler); |
| 919 bool IsValidFrame(StackFrame* frame) const; | 923 bool IsValidFrame(StackFrame* frame) const; |
| 920 bool IsValidCaller(StackFrame* frame); | 924 bool IsValidCaller(StackFrame* frame); |
| 921 static bool IsValidTop(Isolate* isolate, | 925 static bool IsValidTop(Isolate* isolate, |
| 922 Address low_bound, Address high_bound); | 926 Address low_bound, Address high_bound); |
| 923 | 927 |
| 924 // This is a nasty hack to make sure the active count is incremented | |
| 925 // before the constructor for the embedded iterator is invoked. This | |
| 926 // is needed because the constructor will start looking at frames | |
| 927 // right away and we need to make sure it doesn't start inspecting | |
| 928 // heap objects. | |
| 929 class ActiveCountMaintainer BASE_EMBEDDED { | |
| 930 public: | |
| 931 explicit ActiveCountMaintainer(Isolate* isolate); | |
| 932 ~ActiveCountMaintainer(); | |
| 933 private: | |
| 934 Isolate* isolate_; | |
| 935 }; | |
| 936 | |
| 937 ActiveCountMaintainer maintainer_; | |
| 938 StackAddressValidator stack_validator_; | 928 StackAddressValidator stack_validator_; |
| 939 const bool is_valid_top_; | 929 const bool is_valid_top_; |
| 940 const bool is_valid_fp_; | 930 const bool is_valid_fp_; |
| 941 bool iteration_done_; | 931 bool iteration_done_; |
| 942 StackFrameIterator iterator_; | 932 StackFrameIterator iterator_; |
| 943 }; | 933 }; |
| 944 | 934 |
| 945 | 935 |
| 946 class StackFrameLocator BASE_EMBEDDED { | 936 class StackFrameLocator BASE_EMBEDDED { |
| 947 public: | 937 public: |
| 948 explicit StackFrameLocator(Isolate* isolate) : iterator_(isolate) {} | 938 explicit StackFrameLocator(Isolate* isolate) : iterator_(isolate) {} |
| 949 | 939 |
| 950 // Find the nth JavaScript frame on the stack. The caller must | 940 // Find the nth JavaScript frame on the stack. The caller must |
| 951 // guarantee that such a frame exists. | 941 // guarantee that such a frame exists. |
| 952 JavaScriptFrame* FindJavaScriptFrame(int n); | 942 JavaScriptFrame* FindJavaScriptFrame(int n); |
| 953 | 943 |
| 954 private: | 944 private: |
| 955 StackFrameIterator iterator_; | 945 StackFrameIterator iterator_; |
| 956 }; | 946 }; |
| 957 | 947 |
| 958 | 948 |
| 959 // Reads all frames on the current stack and copies them into the current | 949 // Reads all frames on the current stack and copies them into the current |
| 960 // zone memory. | 950 // zone memory. |
| 961 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); | 951 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); |
| 962 | 952 |
| 963 } } // namespace v8::internal | 953 } } // namespace v8::internal |
| 964 | 954 |
| 965 #endif // V8_FRAMES_H_ | 955 #endif // V8_FRAMES_H_ |
| OLD | NEW |