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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 | 789 |
790 | 790 |
791 class StackFrameIteratorBase BASE_EMBEDDED { | 791 class StackFrameIteratorBase BASE_EMBEDDED { |
792 public: | 792 public: |
793 Isolate* isolate() const { return isolate_; } | 793 Isolate* isolate() const { return isolate_; } |
794 | 794 |
795 bool done() const { return frame_ == NULL; } | 795 bool done() const { return frame_ == NULL; } |
796 | 796 |
797 protected: | 797 protected: |
798 // An iterator that iterates over a given thread's stack. | 798 // An iterator that iterates over a given thread's stack. |
799 StackFrameIteratorBase(Isolate* isolate, bool can_access_heap_objects); | 799 StackFrameIteratorBase(Isolate* isolate, |
800 | 800 bool can_access_heap_objects, |
| 801 bool allow_builtins_on_stack); |
801 Isolate* isolate_; | 802 Isolate* isolate_; |
802 #define DECLARE_SINGLETON(ignore, type) type type##_; | 803 #define DECLARE_SINGLETON(ignore, type) type type##_; |
803 STACK_FRAME_TYPE_LIST(DECLARE_SINGLETON) | 804 STACK_FRAME_TYPE_LIST(DECLARE_SINGLETON) |
804 #undef DECLARE_SINGLETON | 805 #undef DECLARE_SINGLETON |
805 StackFrame* frame_; | 806 StackFrame* frame_; |
806 StackHandler* handler_; | 807 StackHandler* handler_; |
807 const bool can_access_heap_objects_; | 808 const bool can_access_heap_objects_; |
| 809 const bool allow_builtins_on_stack_; |
808 | 810 |
809 StackHandler* handler() const { | 811 StackHandler* handler() const { |
810 ASSERT(!done()); | 812 ASSERT(!done()); |
811 return handler_; | 813 return handler_; |
812 } | 814 } |
813 | 815 |
814 // Get the type-specific frame singleton in a given state. | 816 // Get the type-specific frame singleton in a given state. |
815 StackFrame* SingletonFor(StackFrame::Type type, StackFrame::State* state); | 817 StackFrame* SingletonFor(StackFrame::Type type, StackFrame::State* state); |
816 // A helper function, can return a NULL pointer. | 818 // A helper function, can return a NULL pointer. |
817 StackFrame* SingletonFor(StackFrame::Type type); | 819 StackFrame* SingletonFor(StackFrame::Type type); |
818 | 820 |
819 private: | 821 private: |
820 friend class StackFrame; | 822 friend class StackFrame; |
821 DISALLOW_COPY_AND_ASSIGN(StackFrameIteratorBase); | 823 DISALLOW_COPY_AND_ASSIGN(StackFrameIteratorBase); |
822 }; | 824 }; |
823 | 825 |
824 | 826 |
825 class StackFrameIterator: public StackFrameIteratorBase { | 827 class StackFrameIterator: public StackFrameIteratorBase { |
826 public: | 828 public: |
827 // An iterator that iterates over the isolate's current thread's stack, | 829 // An iterator that iterates over the isolate's current thread's stack, |
828 explicit StackFrameIterator(Isolate* isolate); | 830 StackFrameIterator(Isolate* isolate, bool allow_builtins_on_stack = false); |
829 // An iterator that iterates over a given thread's stack. | 831 // An iterator that iterates over a given thread's stack. |
830 StackFrameIterator(Isolate* isolate, ThreadLocalTop* t); | 832 StackFrameIterator(Isolate* isolate, ThreadLocalTop* t); |
831 | 833 |
832 StackFrame* frame() const { | 834 StackFrame* frame() const { |
833 ASSERT(!done()); | 835 ASSERT(!done()); |
834 return frame_; | 836 return frame_; |
835 } | 837 } |
836 void Advance(); | 838 void Advance(); |
837 | 839 |
838 private: | 840 private: |
839 // Go back to the first frame. | 841 // Go back to the first frame. |
840 void Reset(ThreadLocalTop* top); | 842 void Reset(ThreadLocalTop* top); |
841 | 843 |
842 DISALLOW_COPY_AND_ASSIGN(StackFrameIterator); | 844 DISALLOW_COPY_AND_ASSIGN(StackFrameIterator); |
843 }; | 845 }; |
844 | 846 |
845 | 847 |
846 // Iterator that supports iterating through all JavaScript frames. | 848 // Iterator that supports iterating through all JavaScript frames. |
847 class JavaScriptFrameIterator BASE_EMBEDDED { | 849 class JavaScriptFrameIterator BASE_EMBEDDED { |
848 public: | 850 public: |
849 inline explicit JavaScriptFrameIterator(Isolate* isolate); | 851 inline JavaScriptFrameIterator(Isolate* isolate, |
| 852 bool allow_builtins_on_stack = false); |
850 inline JavaScriptFrameIterator(Isolate* isolate, ThreadLocalTop* top); | 853 inline JavaScriptFrameIterator(Isolate* isolate, ThreadLocalTop* top); |
851 // Skip frames until the frame with the given id is reached. | 854 // Skip frames until the frame with the given id is reached. |
852 JavaScriptFrameIterator(Isolate* isolate, StackFrame::Id id); | 855 JavaScriptFrameIterator(Isolate* isolate, StackFrame::Id id); |
853 | 856 |
854 inline JavaScriptFrame* frame() const; | 857 inline JavaScriptFrame* frame() const; |
855 | 858 |
856 bool done() const { return iterator_.done(); } | 859 bool done() const { return iterator_.done(); } |
857 void Advance(); | 860 void Advance(); |
858 | 861 |
859 // Advance to the frame holding the arguments for the current | 862 // Advance to the frame holding the arguments for the current |
860 // frame. This only affects the current frame if it has adapted | 863 // frame. This only affects the current frame if it has adapted |
861 // arguments. | 864 // arguments. |
862 void AdvanceToArgumentsFrame(); | 865 void AdvanceToArgumentsFrame(); |
863 | 866 |
864 private: | 867 private: |
865 StackFrameIterator iterator_; | 868 StackFrameIterator iterator_; |
866 }; | 869 }; |
867 | 870 |
868 | 871 |
869 // NOTE: The stack trace frame iterator is an iterator that only | 872 // NOTE: The stack trace frame iterator is an iterator that only |
870 // traverse proper JavaScript frames; that is JavaScript frames that | 873 // traverse proper JavaScript frames; that is JavaScript frames that |
871 // have proper JavaScript functions. This excludes the problematic | 874 // have proper JavaScript functions. This excludes the problematic |
872 // functions in runtime.js. | 875 // functions in runtime.js. |
873 class StackTraceFrameIterator: public JavaScriptFrameIterator { | 876 class StackTraceFrameIterator: public JavaScriptFrameIterator { |
874 public: | 877 public: |
875 explicit StackTraceFrameIterator(Isolate* isolate); | 878 StackTraceFrameIterator(Isolate* isolate, |
| 879 bool allow_builtins_on_stack = false); |
876 void Advance(); | 880 void Advance(); |
877 | 881 |
878 private: | 882 private: |
879 bool IsValidFrame(); | 883 bool IsValidFrame(); |
880 }; | 884 }; |
881 | 885 |
882 | 886 |
883 class SafeStackFrameIterator: public StackFrameIteratorBase { | 887 class SafeStackFrameIterator: public StackFrameIteratorBase { |
884 public: | 888 public: |
885 SafeStackFrameIterator(Isolate* isolate, | 889 SafeStackFrameIterator(Isolate* isolate, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 }; | 933 }; |
930 | 934 |
931 | 935 |
932 // Reads all frames on the current stack and copies them into the current | 936 // Reads all frames on the current stack and copies them into the current |
933 // zone memory. | 937 // zone memory. |
934 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); | 938 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); |
935 | 939 |
936 } } // namespace v8::internal | 940 } } // namespace v8::internal |
937 | 941 |
938 #endif // V8_FRAMES_H_ | 942 #endif // V8_FRAMES_H_ |
OLD | NEW |