OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_FRAMES_H_ | 5 #ifndef V8_FRAMES_H_ |
6 #define V8_FRAMES_H_ | 6 #define V8_FRAMES_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/handles.h" | 9 #include "src/handles.h" |
10 #include "src/safepoint-table.h" | 10 #include "src/safepoint-table.h" |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 inline explicit ExitFrame(StackFrameIteratorBase* iterator); | 633 inline explicit ExitFrame(StackFrameIteratorBase* iterator); |
634 | 634 |
635 Address GetCallerStackPointer() const override; | 635 Address GetCallerStackPointer() const override; |
636 | 636 |
637 private: | 637 private: |
638 void ComputeCallerState(State* state) const override; | 638 void ComputeCallerState(State* state) const override; |
639 | 639 |
640 friend class StackFrameIteratorBase; | 640 friend class StackFrameIteratorBase; |
641 }; | 641 }; |
642 | 642 |
| 643 class FrameSummary BASE_EMBEDDED { |
| 644 public: |
| 645 FrameSummary(Object* receiver, JSFunction* function, |
| 646 AbstractCode* abstract_code, int code_offset, |
| 647 bool is_constructor); |
643 | 648 |
644 class StandardFrame: public StackFrame { | 649 Handle<Object> receiver() { return receiver_; } |
| 650 Handle<JSFunction> function() { return function_; } |
| 651 Handle<AbstractCode> abstract_code() { return abstract_code_; } |
| 652 int code_offset() { return code_offset_; } |
| 653 bool is_constructor() { return is_constructor_; } |
| 654 |
| 655 void Print(); |
| 656 |
| 657 private: |
| 658 Handle<Object> receiver_; |
| 659 Handle<JSFunction> function_; |
| 660 Handle<AbstractCode> abstract_code_; |
| 661 int code_offset_; |
| 662 bool is_constructor_; |
| 663 }; |
| 664 |
| 665 class StandardFrame : public StackFrame { |
645 public: | 666 public: |
646 // Testers. | 667 // Testers. |
647 bool is_standard() const override { return true; } | 668 bool is_standard() const override { return true; } |
648 | 669 |
649 // Accessors. | 670 // Accessors. |
650 inline Object* context() const; | 671 inline Object* context() const; |
651 | 672 |
652 // Access the expressions in the stack frame including locals. | 673 // Access the expressions in the stack frame including locals. |
653 inline Object* GetExpression(int index) const; | 674 inline Object* GetExpression(int index) const; |
654 inline void SetExpression(int index, Object* value); | 675 inline void SetExpression(int index, Object* value); |
655 int ComputeExpressionsCount() const; | 676 int ComputeExpressionsCount() const; |
656 | 677 |
657 void SetCallerFp(Address caller_fp) override; | 678 void SetCallerFp(Address caller_fp) override; |
658 | 679 |
659 static StandardFrame* cast(StackFrame* frame) { | 680 static StandardFrame* cast(StackFrame* frame) { |
660 DCHECK(frame->is_standard()); | 681 DCHECK(frame->is_standard()); |
661 return static_cast<StandardFrame*>(frame); | 682 return static_cast<StandardFrame*>(frame); |
662 } | 683 } |
663 | 684 |
| 685 // Build a list with summaries for this frame including all inlined frames. |
| 686 virtual void Summarize(List<FrameSummary>* frames) const; |
| 687 |
| 688 // Accessors. |
| 689 virtual JSFunction* function() const; |
| 690 virtual Object* receiver() const; |
| 691 |
664 protected: | 692 protected: |
665 inline explicit StandardFrame(StackFrameIteratorBase* iterator); | 693 inline explicit StandardFrame(StackFrameIteratorBase* iterator); |
666 | 694 |
667 void ComputeCallerState(State* state) const override; | 695 void ComputeCallerState(State* state) const override; |
668 | 696 |
669 // Accessors. | 697 // Accessors. |
670 inline Address caller_fp() const; | 698 inline Address caller_fp() const; |
671 inline Address caller_pc() const; | 699 inline Address caller_pc() const; |
672 | 700 |
673 // Computes the address of the PC field in the standard frame given | 701 // Computes the address of the PC field in the standard frame given |
(...skipping 21 matching lines...) Expand all Loading... |
695 | 723 |
696 // Used by OptimizedFrames and StubFrames. | 724 // Used by OptimizedFrames and StubFrames. |
697 void IterateCompiledFrame(ObjectVisitor* v) const; | 725 void IterateCompiledFrame(ObjectVisitor* v) const; |
698 | 726 |
699 private: | 727 private: |
700 friend class StackFrame; | 728 friend class StackFrame; |
701 friend class SafeStackFrameIterator; | 729 friend class SafeStackFrameIterator; |
702 }; | 730 }; |
703 | 731 |
704 | 732 |
705 class FrameSummary BASE_EMBEDDED { | |
706 public: | |
707 FrameSummary(Object* receiver, JSFunction* function, | |
708 AbstractCode* abstract_code, int code_offset, | |
709 bool is_constructor); | |
710 | |
711 Handle<Object> receiver() { return receiver_; } | |
712 Handle<JSFunction> function() { return function_; } | |
713 Handle<AbstractCode> abstract_code() { return abstract_code_; } | |
714 int code_offset() { return code_offset_; } | |
715 bool is_constructor() { return is_constructor_; } | |
716 | |
717 void Print(); | |
718 | |
719 private: | |
720 Handle<Object> receiver_; | |
721 Handle<JSFunction> function_; | |
722 Handle<AbstractCode> abstract_code_; | |
723 int code_offset_; | |
724 bool is_constructor_; | |
725 }; | |
726 | |
727 class JavaScriptFrame : public StandardFrame { | 733 class JavaScriptFrame : public StandardFrame { |
728 public: | 734 public: |
729 Type type() const override { return JAVA_SCRIPT; } | 735 Type type() const override { return JAVA_SCRIPT; } |
730 | 736 |
731 // Accessors. | 737 JSFunction* function() const override; |
732 inline JSFunction* function() const; | 738 Object* receiver() const override; |
733 inline Object* receiver() const; | 739 |
734 inline void set_receiver(Object* value); | 740 inline void set_receiver(Object* value); |
735 | 741 |
736 // Access the parameters. | 742 // Access the parameters. |
737 inline Address GetParameterSlot(int index) const; | 743 inline Address GetParameterSlot(int index) const; |
738 inline Object* GetParameter(int index) const; | 744 inline Object* GetParameter(int index) const; |
739 inline int ComputeParametersCount() const { | 745 inline int ComputeParametersCount() const { |
740 return GetNumberOfIncomingArguments(); | 746 return GetNumberOfIncomingArguments(); |
741 } | 747 } |
742 | 748 |
743 // Access the operand stack. | 749 // Access the operand stack. |
(...skipping 26 matching lines...) Expand all Loading... |
770 // Printing support. | 776 // Printing support. |
771 void Print(StringStream* accumulator, PrintMode mode, | 777 void Print(StringStream* accumulator, PrintMode mode, |
772 int index) const override; | 778 int index) const override; |
773 | 779 |
774 // Determine the code for the frame. | 780 // Determine the code for the frame. |
775 Code* unchecked_code() const override; | 781 Code* unchecked_code() const override; |
776 | 782 |
777 // Return a list with JSFunctions of this frame. | 783 // Return a list with JSFunctions of this frame. |
778 virtual void GetFunctions(List<JSFunction*>* functions) const; | 784 virtual void GetFunctions(List<JSFunction*>* functions) const; |
779 | 785 |
780 // Build a list with summaries for this frame including all inlined frames. | 786 void Summarize(List<FrameSummary>* frames) const override; |
781 virtual void Summarize(List<FrameSummary>* frames); | |
782 | 787 |
783 // Lookup exception handler for current {pc}, returns -1 if none found. Also | 788 // Lookup exception handler for current {pc}, returns -1 if none found. Also |
784 // returns data associated with the handler site specific to the frame type: | 789 // returns data associated with the handler site specific to the frame type: |
785 // - JavaScriptFrame : Data is the stack depth at entry of the try-block. | 790 // - JavaScriptFrame : Data is the stack depth at entry of the try-block. |
786 // - OptimizedFrame : Data is the stack slot count of the entire frame. | 791 // - OptimizedFrame : Data is the stack slot count of the entire frame. |
787 // - InterpretedFrame: Data is the register index holding the context. | 792 // - InterpretedFrame: Data is the register index holding the context. |
788 virtual int LookupExceptionHandlerInTable( | 793 virtual int LookupExceptionHandlerInTable( |
789 int* data, HandlerTable::CatchPrediction* prediction); | 794 int* data, HandlerTable::CatchPrediction* prediction); |
790 | 795 |
791 // Architecture-specific register description. | 796 // Architecture-specific register description. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 Type type() const override { return OPTIMIZED; } | 854 Type type() const override { return OPTIMIZED; } |
850 | 855 |
851 // GC support. | 856 // GC support. |
852 void Iterate(ObjectVisitor* v) const override; | 857 void Iterate(ObjectVisitor* v) const override; |
853 | 858 |
854 // Return a list with JSFunctions of this frame. | 859 // Return a list with JSFunctions of this frame. |
855 // The functions are ordered bottom-to-top (i.e. functions.last() | 860 // The functions are ordered bottom-to-top (i.e. functions.last() |
856 // is the top-most activation) | 861 // is the top-most activation) |
857 void GetFunctions(List<JSFunction*>* functions) const override; | 862 void GetFunctions(List<JSFunction*>* functions) const override; |
858 | 863 |
859 void Summarize(List<FrameSummary>* frames) override; | 864 void Summarize(List<FrameSummary>* frames) const override; |
860 | 865 |
861 // Lookup exception handler for current {pc}, returns -1 if none found. | 866 // Lookup exception handler for current {pc}, returns -1 if none found. |
862 int LookupExceptionHandlerInTable( | 867 int LookupExceptionHandlerInTable( |
863 int* data, HandlerTable::CatchPrediction* prediction) override; | 868 int* data, HandlerTable::CatchPrediction* prediction) override; |
864 | 869 |
865 DeoptimizationInputData* GetDeoptimizationData(int* deopt_index) const; | 870 DeoptimizationInputData* GetDeoptimizationData(int* deopt_index) const; |
866 | 871 |
867 static int StackSlotOffsetRelativeToFp(int slot_index); | 872 static int StackSlotOffsetRelativeToFp(int slot_index); |
868 | 873 |
869 protected: | 874 protected: |
(...skipping 25 matching lines...) Expand all Loading... |
895 Object* GetBytecodeArray() const; | 900 Object* GetBytecodeArray() const; |
896 | 901 |
897 // Updates the frame's BytecodeArray with |bytecode_array|. Used by the | 902 // Updates the frame's BytecodeArray with |bytecode_array|. Used by the |
898 // debugger to swap execution onto a BytecodeArray patched with breakpoints. | 903 // debugger to swap execution onto a BytecodeArray patched with breakpoints. |
899 void PatchBytecodeArray(Object* bytecode_array); | 904 void PatchBytecodeArray(Object* bytecode_array); |
900 | 905 |
901 // Access to the interpreter register file for this frame. | 906 // Access to the interpreter register file for this frame. |
902 Object* GetInterpreterRegister(int register_index) const; | 907 Object* GetInterpreterRegister(int register_index) const; |
903 | 908 |
904 // Build a list with summaries for this frame including all inlined frames. | 909 // Build a list with summaries for this frame including all inlined frames. |
905 void Summarize(List<FrameSummary>* frames) override; | 910 void Summarize(List<FrameSummary>* frames) const override; |
906 | 911 |
907 protected: | 912 protected: |
908 inline explicit InterpretedFrame(StackFrameIteratorBase* iterator); | 913 inline explicit InterpretedFrame(StackFrameIteratorBase* iterator); |
909 | 914 |
910 Address GetExpressionAddress(int n) const override; | 915 Address GetExpressionAddress(int n) const override; |
911 | 916 |
912 private: | 917 private: |
913 friend class StackFrameIteratorBase; | 918 friend class StackFrameIteratorBase; |
914 }; | 919 }; |
915 | 920 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 int index) const override; | 963 int index) const override; |
959 | 964 |
960 // Determine the code for the frame. | 965 // Determine the code for the frame. |
961 Code* unchecked_code() const override; | 966 Code* unchecked_code() const override; |
962 | 967 |
963 static WasmFrame* cast(StackFrame* frame) { | 968 static WasmFrame* cast(StackFrame* frame) { |
964 DCHECK(frame->is_wasm()); | 969 DCHECK(frame->is_wasm()); |
965 return static_cast<WasmFrame*>(frame); | 970 return static_cast<WasmFrame*>(frame); |
966 } | 971 } |
967 | 972 |
| 973 JSFunction* function() const override; |
| 974 |
968 protected: | 975 protected: |
969 inline explicit WasmFrame(StackFrameIteratorBase* iterator); | 976 inline explicit WasmFrame(StackFrameIteratorBase* iterator); |
970 | 977 |
971 Address GetCallerStackPointer() const override; | 978 Address GetCallerStackPointer() const override; |
972 | 979 |
973 private: | 980 private: |
974 friend class StackFrameIteratorBase; | 981 friend class StackFrameIteratorBase; |
975 }; | 982 }; |
976 | 983 |
977 class WasmToJsFrame : public StubFrame { | 984 class WasmToJsFrame : public StubFrame { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 | 1142 |
1136 // Advance to the frame holding the arguments for the current | 1143 // Advance to the frame holding the arguments for the current |
1137 // frame. This only affects the current frame if it has adapted | 1144 // frame. This only affects the current frame if it has adapted |
1138 // arguments. | 1145 // arguments. |
1139 void AdvanceToArgumentsFrame(); | 1146 void AdvanceToArgumentsFrame(); |
1140 | 1147 |
1141 private: | 1148 private: |
1142 StackFrameIterator iterator_; | 1149 StackFrameIterator iterator_; |
1143 }; | 1150 }; |
1144 | 1151 |
1145 // NOTE: The stack trace frame iterator is an iterator that only | 1152 // NOTE: The stack trace frame iterator is an iterator that only traverse proper |
1146 // traverse proper JavaScript frames; that is JavaScript frames that | 1153 // JavaScript frames that have proper JavaScript functions and WASM frames. |
1147 // have proper JavaScript functions. This excludes the problematic | 1154 // This excludes the problematic functions in runtime.js. |
1148 // functions in runtime.js. | 1155 class StackTraceFrameIterator BASE_EMBEDDED { |
1149 class StackTraceFrameIterator: public JavaScriptFrameIterator { | |
1150 public: | 1156 public: |
1151 explicit StackTraceFrameIterator(Isolate* isolate); | 1157 explicit StackTraceFrameIterator(Isolate* isolate); |
| 1158 bool done() const { return iterator_.done(); } |
1152 void Advance(); | 1159 void Advance(); |
1153 | 1160 |
| 1161 inline StandardFrame* frame() const; |
| 1162 |
| 1163 inline bool is_javascript() const; |
| 1164 inline bool is_wasm() const; |
| 1165 inline JavaScriptFrame* javascript_frame() const; |
| 1166 inline WasmFrame* wasm_frame() const; |
| 1167 |
1154 private: | 1168 private: |
1155 bool IsValidFrame(); | 1169 StackFrameIterator iterator_; |
| 1170 bool IsValidFrame(StackFrame* frame) const; |
1156 }; | 1171 }; |
1157 | 1172 |
1158 | 1173 |
1159 class SafeStackFrameIterator: public StackFrameIteratorBase { | 1174 class SafeStackFrameIterator: public StackFrameIteratorBase { |
1160 public: | 1175 public: |
1161 SafeStackFrameIterator(Isolate* isolate, | 1176 SafeStackFrameIterator(Isolate* isolate, |
1162 Address fp, Address sp, | 1177 Address fp, Address sp, |
1163 Address js_entry_sp); | 1178 Address js_entry_sp); |
1164 | 1179 |
1165 inline StackFrame* frame() const; | 1180 inline StackFrame* frame() const; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1199 | 1214 |
1200 | 1215 |
1201 // Reads all frames on the current stack and copies them into the current | 1216 // Reads all frames on the current stack and copies them into the current |
1202 // zone memory. | 1217 // zone memory. |
1203 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); | 1218 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); |
1204 | 1219 |
1205 } // namespace internal | 1220 } // namespace internal |
1206 } // namespace v8 | 1221 } // namespace v8 |
1207 | 1222 |
1208 #endif // V8_FRAMES_H_ | 1223 #endif // V8_FRAMES_H_ |
OLD | NEW |