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 27 matching lines...) Expand all Loading... | |
771 // Printing support. | 777 // Printing support. |
772 void Print(StringStream* accumulator, PrintMode mode, | 778 void Print(StringStream* accumulator, PrintMode mode, |
773 int index) const override; | 779 int index) const override; |
774 | 780 |
775 // Determine the code for the frame. | 781 // Determine the code for the frame. |
776 Code* unchecked_code() const override; | 782 Code* unchecked_code() const override; |
777 | 783 |
778 // Return a list with JSFunctions of this frame. | 784 // Return a list with JSFunctions of this frame. |
779 virtual void GetFunctions(List<JSFunction*>* functions) const; | 785 virtual void GetFunctions(List<JSFunction*>* functions) const; |
780 | 786 |
781 // Build a list with summaries for this frame including all inlined frames. | 787 void Summarize(List<FrameSummary>* frames) const override; |
782 virtual void Summarize(List<FrameSummary>* frames); | |
783 | 788 |
784 // Lookup exception handler for current {pc}, returns -1 if none found. Also | 789 // Lookup exception handler for current {pc}, returns -1 if none found. Also |
785 // returns data associated with the handler site specific to the frame type: | 790 // returns data associated with the handler site specific to the frame type: |
786 // - JavaScriptFrame : Data is the stack depth at entry of the try-block. | 791 // - JavaScriptFrame : Data is the stack depth at entry of the try-block. |
787 // - OptimizedFrame : Data is the stack slot count of the entire frame. | 792 // - OptimizedFrame : Data is the stack slot count of the entire frame. |
788 // - InterpretedFrame: Data is the register index holding the context. | 793 // - InterpretedFrame: Data is the register index holding the context. |
789 virtual int LookupExceptionHandlerInTable( | 794 virtual int LookupExceptionHandlerInTable( |
790 int* data, HandlerTable::CatchPrediction* prediction); | 795 int* data, HandlerTable::CatchPrediction* prediction); |
791 | 796 |
792 // Architecture-specific register description. | 797 // Architecture-specific register description. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
850 Type type() const override { return OPTIMIZED; } | 855 Type type() const override { return OPTIMIZED; } |
851 | 856 |
852 // GC support. | 857 // GC support. |
853 void Iterate(ObjectVisitor* v) const override; | 858 void Iterate(ObjectVisitor* v) const override; |
854 | 859 |
855 // Return a list with JSFunctions of this frame. | 860 // Return a list with JSFunctions of this frame. |
856 // The functions are ordered bottom-to-top (i.e. functions.last() | 861 // The functions are ordered bottom-to-top (i.e. functions.last() |
857 // is the top-most activation) | 862 // is the top-most activation) |
858 void GetFunctions(List<JSFunction*>* functions) const override; | 863 void GetFunctions(List<JSFunction*>* functions) const override; |
859 | 864 |
860 void Summarize(List<FrameSummary>* frames) override; | 865 void Summarize(List<FrameSummary>* frames) const override; |
861 | 866 |
862 // Lookup exception handler for current {pc}, returns -1 if none found. | 867 // Lookup exception handler for current {pc}, returns -1 if none found. |
863 int LookupExceptionHandlerInTable( | 868 int LookupExceptionHandlerInTable( |
864 int* data, HandlerTable::CatchPrediction* prediction) override; | 869 int* data, HandlerTable::CatchPrediction* prediction) override; |
865 | 870 |
866 DeoptimizationInputData* GetDeoptimizationData(int* deopt_index) const; | 871 DeoptimizationInputData* GetDeoptimizationData(int* deopt_index) const; |
867 | 872 |
868 static int StackSlotOffsetRelativeToFp(int slot_index); | 873 static int StackSlotOffsetRelativeToFp(int slot_index); |
869 | 874 |
870 protected: | 875 protected: |
(...skipping 25 matching lines...) Expand all Loading... | |
896 Object* GetBytecodeArray() const; | 901 Object* GetBytecodeArray() const; |
897 | 902 |
898 // Updates the frame's BytecodeArray with |bytecode_array|. Used by the | 903 // Updates the frame's BytecodeArray with |bytecode_array|. Used by the |
899 // debugger to swap execution onto a BytecodeArray patched with breakpoints. | 904 // debugger to swap execution onto a BytecodeArray patched with breakpoints. |
900 void PatchBytecodeArray(Object* bytecode_array); | 905 void PatchBytecodeArray(Object* bytecode_array); |
901 | 906 |
902 // Access to the interpreter register file for this frame. | 907 // Access to the interpreter register file for this frame. |
903 Object* GetInterpreterRegister(int register_index) const; | 908 Object* GetInterpreterRegister(int register_index) const; |
904 | 909 |
905 // Build a list with summaries for this frame including all inlined frames. | 910 // Build a list with summaries for this frame including all inlined frames. |
906 void Summarize(List<FrameSummary>* frames) override; | 911 void Summarize(List<FrameSummary>* frames) const override; |
907 | 912 |
908 protected: | 913 protected: |
909 inline explicit InterpretedFrame(StackFrameIteratorBase* iterator); | 914 inline explicit InterpretedFrame(StackFrameIteratorBase* iterator); |
910 | 915 |
911 Address GetExpressionAddress(int n) const override; | 916 Address GetExpressionAddress(int n) const override; |
912 | 917 |
913 private: | 918 private: |
914 friend class StackFrameIteratorBase; | 919 friend class StackFrameIteratorBase; |
915 }; | 920 }; |
916 | 921 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
959 int index) const override; | 964 int index) const override; |
960 | 965 |
961 // Determine the code for the frame. | 966 // Determine the code for the frame. |
962 Code* unchecked_code() const override; | 967 Code* unchecked_code() const override; |
963 | 968 |
964 static WasmFrame* cast(StackFrame* frame) { | 969 static WasmFrame* cast(StackFrame* frame) { |
965 DCHECK(frame->is_wasm()); | 970 DCHECK(frame->is_wasm()); |
966 return static_cast<WasmFrame*>(frame); | 971 return static_cast<WasmFrame*>(frame); |
967 } | 972 } |
968 | 973 |
974 JSFunction* function() const override; | |
975 | |
969 protected: | 976 protected: |
970 inline explicit WasmFrame(StackFrameIteratorBase* iterator); | 977 inline explicit WasmFrame(StackFrameIteratorBase* iterator); |
971 | 978 |
972 Address GetCallerStackPointer() const override; | 979 Address GetCallerStackPointer() const override; |
973 | 980 |
974 private: | 981 private: |
975 friend class StackFrameIteratorBase; | 982 friend class StackFrameIteratorBase; |
976 }; | 983 }; |
977 | 984 |
978 class WasmToJsFrame : public StubFrame { | 985 class WasmToJsFrame : public StubFrame { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1136 | 1143 |
1137 // Advance to the frame holding the arguments for the current | 1144 // Advance to the frame holding the arguments for the current |
1138 // frame. This only affects the current frame if it has adapted | 1145 // frame. This only affects the current frame if it has adapted |
1139 // arguments. | 1146 // arguments. |
1140 void AdvanceToArgumentsFrame(); | 1147 void AdvanceToArgumentsFrame(); |
1141 | 1148 |
1142 private: | 1149 private: |
1143 StackFrameIterator iterator_; | 1150 StackFrameIterator iterator_; |
1144 }; | 1151 }; |
1145 | 1152 |
1146 // NOTE: The stack trace frame iterator is an iterator that only | 1153 // NOTE: The stack trace frame iterator is an iterator that only traverse proper |
1147 // traverse proper JavaScript frames; that is JavaScript frames that | 1154 // JavaScript frames (that have proper JavaScript functions) and WASM frames. |
titzer
2016/04/06 09:53:23
parens not necessary here
Clemens Hammacher
2016/04/06 10:18:29
Acknowledged.
| |
1148 // have proper JavaScript functions. This excludes the problematic | 1155 // This excludes the problematic functions in runtime.js. |
1149 // functions in runtime.js. | 1156 class StackTraceFrameIterator BASE_EMBEDDED { |
1150 class StackTraceFrameIterator: public JavaScriptFrameIterator { | |
1151 public: | 1157 public: |
1152 explicit StackTraceFrameIterator(Isolate* isolate); | 1158 explicit StackTraceFrameIterator(Isolate* isolate); |
1159 bool done() const { return iterator_.done(); } | |
1153 void Advance(); | 1160 void Advance(); |
1154 | 1161 |
1162 inline StandardFrame* frame() const; | |
1163 | |
1164 inline bool isJS() const; | |
1165 inline bool isWasm() const; | |
1166 inline JavaScriptFrame* jsFrame() const; | |
1167 inline WasmFrame* wasmFrame() const; | |
1168 | |
1155 private: | 1169 private: |
1156 bool IsValidFrame(); | 1170 StackFrameIterator iterator_; |
1171 bool IsValidFrame(StackFrame* frame) const; | |
1157 }; | 1172 }; |
1158 | 1173 |
1159 | 1174 |
1160 class SafeStackFrameIterator: public StackFrameIteratorBase { | 1175 class SafeStackFrameIterator: public StackFrameIteratorBase { |
1161 public: | 1176 public: |
1162 SafeStackFrameIterator(Isolate* isolate, | 1177 SafeStackFrameIterator(Isolate* isolate, |
1163 Address fp, Address sp, | 1178 Address fp, Address sp, |
1164 Address js_entry_sp); | 1179 Address js_entry_sp); |
1165 | 1180 |
1166 inline StackFrame* frame() const; | 1181 inline StackFrame* frame() const; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1200 | 1215 |
1201 | 1216 |
1202 // Reads all frames on the current stack and copies them into the current | 1217 // Reads all frames on the current stack and copies them into the current |
1203 // zone memory. | 1218 // zone memory. |
1204 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); | 1219 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); |
1205 | 1220 |
1206 } // namespace internal | 1221 } // namespace internal |
1207 } // namespace v8 | 1222 } // namespace v8 |
1208 | 1223 |
1209 #endif // V8_FRAMES_H_ | 1224 #endif // V8_FRAMES_H_ |
OLD | NEW |