| 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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 int code_offset_; | 665 int code_offset_; |
| 666 bool is_constructor_; | 666 bool is_constructor_; |
| 667 }; | 667 }; |
| 668 | 668 |
| 669 class StandardFrame : public StackFrame { | 669 class StandardFrame : public StackFrame { |
| 670 public: | 670 public: |
| 671 // Testers. | 671 // Testers. |
| 672 bool is_standard() const override { return true; } | 672 bool is_standard() const override { return true; } |
| 673 | 673 |
| 674 // Accessors. | 674 // Accessors. |
| 675 inline Object* context() const; | 675 virtual Script* script() const; |
| 676 virtual Object* context() const; |
| 676 | 677 |
| 677 // Access the expressions in the stack frame including locals. | 678 // Access the expressions in the stack frame including locals. |
| 678 inline Object* GetExpression(int index) const; | 679 inline Object* GetExpression(int index) const; |
| 679 inline void SetExpression(int index, Object* value); | 680 inline void SetExpression(int index, Object* value); |
| 680 int ComputeExpressionsCount() const; | 681 int ComputeExpressionsCount() const; |
| 681 | 682 |
| 683 // Access the parameters. |
| 684 virtual Object* GetParameter(int index) const; |
| 685 virtual int ComputeParametersCount() const; |
| 686 |
| 682 void SetCallerFp(Address caller_fp) override; | 687 void SetCallerFp(Address caller_fp) override; |
| 683 | 688 |
| 689 // Check if this frame is a constructor frame invoked through 'new'. |
| 690 virtual bool IsConstructor() const; |
| 691 |
| 684 static StandardFrame* cast(StackFrame* frame) { | 692 static StandardFrame* cast(StackFrame* frame) { |
| 685 DCHECK(frame->is_standard()); | 693 DCHECK(frame->is_standard()); |
| 686 return static_cast<StandardFrame*>(frame); | 694 return static_cast<StandardFrame*>(frame); |
| 687 } | 695 } |
| 688 | 696 |
| 689 protected: | 697 protected: |
| 690 inline explicit StandardFrame(StackFrameIteratorBase* iterator); | 698 inline explicit StandardFrame(StackFrameIteratorBase* iterator); |
| 691 | 699 |
| 692 void ComputeCallerState(State* state) const override; | 700 void ComputeCallerState(State* state) const override; |
| 693 | 701 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 Type type() const override { return JAVA_SCRIPT; } | 739 Type type() const override { return JAVA_SCRIPT; } |
| 732 | 740 |
| 733 // Build a list with summaries for this frame including all inlined frames. | 741 // Build a list with summaries for this frame including all inlined frames. |
| 734 virtual void Summarize( | 742 virtual void Summarize( |
| 735 List<FrameSummary>* frames, | 743 List<FrameSummary>* frames, |
| 736 FrameSummary::Mode mode = FrameSummary::kExactSummary) const; | 744 FrameSummary::Mode mode = FrameSummary::kExactSummary) const; |
| 737 | 745 |
| 738 // Accessors. | 746 // Accessors. |
| 739 virtual JSFunction* function() const; | 747 virtual JSFunction* function() const; |
| 740 virtual Object* receiver() const; | 748 virtual Object* receiver() const; |
| 749 Object* context() const override; |
| 750 Script* script() const override; |
| 741 | 751 |
| 742 inline void set_receiver(Object* value); | 752 inline void set_receiver(Object* value); |
| 743 | 753 |
| 744 // Access the parameters. | 754 // Access the parameters. |
| 745 inline Address GetParameterSlot(int index) const; | 755 inline Address GetParameterSlot(int index) const; |
| 746 inline Object* GetParameter(int index) const; | 756 Object* GetParameter(int index) const override; |
| 747 inline int ComputeParametersCount() const { | 757 int ComputeParametersCount() const override; |
| 748 return GetNumberOfIncomingArguments(); | |
| 749 } | |
| 750 | 758 |
| 751 // Access the operand stack. | 759 // Access the operand stack. |
| 752 inline Address GetOperandSlot(int index) const; | 760 inline Address GetOperandSlot(int index) const; |
| 753 inline Object* GetOperand(int index) const; | 761 inline Object* GetOperand(int index) const; |
| 754 inline int ComputeOperandsCount() const; | 762 inline int ComputeOperandsCount() const; |
| 755 | 763 |
| 756 // Generator support to preserve operand stack. | 764 // Generator support to preserve operand stack. |
| 757 void SaveOperandStack(FixedArray* store) const; | 765 void SaveOperandStack(FixedArray* store) const; |
| 758 | 766 |
| 759 // Debugger access. | 767 // Debugger access. |
| 760 void SetParameterValue(int index, Object* value) const; | 768 void SetParameterValue(int index, Object* value) const; |
| 761 | 769 |
| 762 // Check if this frame is a constructor frame invoked through 'new'. | 770 // Check if this frame is a constructor frame invoked through 'new'. |
| 763 bool IsConstructor() const; | 771 bool IsConstructor() const override; |
| 764 | 772 |
| 765 // Determines whether this frame includes inlined activations. To get details | 773 // Determines whether this frame includes inlined activations. To get details |
| 766 // about the inlined frames use {GetFunctions} and {Summarize}. | 774 // about the inlined frames use {GetFunctions} and {Summarize}. |
| 767 bool HasInlinedFrames() const; | 775 bool HasInlinedFrames() const; |
| 768 | 776 |
| 769 // Check if this frame has "adapted" arguments in the sense that the | 777 // Check if this frame has "adapted" arguments in the sense that the |
| 770 // actual passed arguments are available in an arguments adaptor | 778 // actual passed arguments are available in an arguments adaptor |
| 771 // frame below it on the stack. | 779 // frame below it on the stack. |
| 772 inline bool has_adapted_arguments() const; | 780 inline bool has_adapted_arguments() const; |
| 773 int GetArgumentsLength() const; | 781 int GetArgumentsLength() const; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 // GC support. | 971 // GC support. |
| 964 void Iterate(ObjectVisitor* v) const override; | 972 void Iterate(ObjectVisitor* v) const override; |
| 965 | 973 |
| 966 // Printing support. | 974 // Printing support. |
| 967 void Print(StringStream* accumulator, PrintMode mode, | 975 void Print(StringStream* accumulator, PrintMode mode, |
| 968 int index) const override; | 976 int index) const override; |
| 969 | 977 |
| 970 // Determine the code for the frame. | 978 // Determine the code for the frame. |
| 971 Code* unchecked_code() const override; | 979 Code* unchecked_code() const override; |
| 972 | 980 |
| 973 Object* wasm_obj(); | 981 // Accessors. |
| 974 uint32_t function_index(); | 982 Object* wasm_obj() const; |
| 983 uint32_t function_index() const; |
| 984 Script* script() const override; |
| 975 | 985 |
| 976 static WasmFrame* cast(StackFrame* frame) { | 986 static WasmFrame* cast(StackFrame* frame) { |
| 977 DCHECK(frame->is_wasm()); | 987 DCHECK(frame->is_wasm()); |
| 978 return static_cast<WasmFrame*>(frame); | 988 return static_cast<WasmFrame*>(frame); |
| 979 } | 989 } |
| 980 | 990 |
| 981 protected: | 991 protected: |
| 982 inline explicit WasmFrame(StackFrameIteratorBase* iterator); | 992 inline explicit WasmFrame(StackFrameIteratorBase* iterator); |
| 983 | 993 |
| 984 Address GetCallerStackPointer() const override; | 994 Address GetCallerStackPointer() const override; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 private: | 1164 private: |
| 1155 StackFrameIterator iterator_; | 1165 StackFrameIterator iterator_; |
| 1156 }; | 1166 }; |
| 1157 | 1167 |
| 1158 // NOTE: The stack trace frame iterator is an iterator that only traverse proper | 1168 // NOTE: The stack trace frame iterator is an iterator that only traverse proper |
| 1159 // JavaScript frames that have proper JavaScript functions and WASM frames. | 1169 // JavaScript frames that have proper JavaScript functions and WASM frames. |
| 1160 // This excludes the problematic functions in runtime.js. | 1170 // This excludes the problematic functions in runtime.js. |
| 1161 class StackTraceFrameIterator BASE_EMBEDDED { | 1171 class StackTraceFrameIterator BASE_EMBEDDED { |
| 1162 public: | 1172 public: |
| 1163 explicit StackTraceFrameIterator(Isolate* isolate); | 1173 explicit StackTraceFrameIterator(Isolate* isolate); |
| 1174 StackTraceFrameIterator(Isolate* isolate, StackFrame::Id id); |
| 1164 bool done() const { return iterator_.done(); } | 1175 bool done() const { return iterator_.done(); } |
| 1165 void Advance(); | 1176 void Advance(); |
| 1166 | 1177 |
| 1167 inline StandardFrame* frame() const; | 1178 inline StandardFrame* frame() const; |
| 1168 | 1179 |
| 1169 inline bool is_javascript() const; | 1180 inline bool is_javascript() const; |
| 1170 inline bool is_wasm() const; | 1181 inline bool is_wasm() const; |
| 1171 inline JavaScriptFrame* javascript_frame() const; | 1182 inline JavaScriptFrame* javascript_frame() const; |
| 1172 inline WasmFrame* wasm_frame() const; | 1183 inline WasmFrame* wasm_frame() const; |
| 1173 | 1184 |
| 1185 // Advance to the frame holding the arguments for the current |
| 1186 // frame. This only affects the current frame if it is a javascript frame and |
| 1187 // has adapted arguments. |
| 1188 void AdvanceToArgumentsFrame(); |
| 1189 |
| 1174 private: | 1190 private: |
| 1175 StackFrameIterator iterator_; | 1191 StackFrameIterator iterator_; |
| 1176 bool IsValidFrame(StackFrame* frame) const; | 1192 bool IsValidFrame(StackFrame* frame) const; |
| 1177 }; | 1193 }; |
| 1178 | 1194 |
| 1179 | 1195 |
| 1180 class SafeStackFrameIterator: public StackFrameIteratorBase { | 1196 class SafeStackFrameIterator: public StackFrameIteratorBase { |
| 1181 public: | 1197 public: |
| 1182 SafeStackFrameIterator(Isolate* isolate, | 1198 SafeStackFrameIterator(Isolate* isolate, |
| 1183 Address fp, Address sp, | 1199 Address fp, Address sp, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 | 1236 |
| 1221 | 1237 |
| 1222 // Reads all frames on the current stack and copies them into the current | 1238 // Reads all frames on the current stack and copies them into the current |
| 1223 // zone memory. | 1239 // zone memory. |
| 1224 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); | 1240 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); |
| 1225 | 1241 |
| 1226 } // namespace internal | 1242 } // namespace internal |
| 1227 } // namespace v8 | 1243 } // namespace v8 |
| 1228 | 1244 |
| 1229 #endif // V8_FRAMES_H_ | 1245 #endif // V8_FRAMES_H_ |
| OLD | NEW |