| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // Get the next stack handler in the chain. | 90 // Get the next stack handler in the chain. |
| 91 inline StackHandler* next() const; | 91 inline StackHandler* next() const; |
| 92 | 92 |
| 93 // Conversion support. | 93 // Conversion support. |
| 94 static inline StackHandler* FromAddress(Address address); | 94 static inline StackHandler* FromAddress(Address address); |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 DISALLOW_IMPLICIT_CONSTRUCTORS(StackHandler); | 97 DISALLOW_IMPLICIT_CONSTRUCTORS(StackHandler); |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 | |
| 101 #define STACK_FRAME_TYPE_LIST(V) \ | 100 #define STACK_FRAME_TYPE_LIST(V) \ |
| 102 V(ENTRY, EntryFrame) \ | 101 V(ENTRY, EntryFrame) \ |
| 103 V(ENTRY_CONSTRUCT, EntryConstructFrame) \ | 102 V(ENTRY_CONSTRUCT, EntryConstructFrame) \ |
| 104 V(EXIT, ExitFrame) \ | 103 V(EXIT, ExitFrame) \ |
| 105 V(JAVA_SCRIPT, JavaScriptFrame) \ | 104 V(JAVA_SCRIPT, JavaScriptFrame) \ |
| 106 V(OPTIMIZED, OptimizedFrame) \ | 105 V(OPTIMIZED, OptimizedFrame) \ |
| 106 V(WASM, WasmFrame) \ |
| 107 V(INTERPRETED, InterpretedFrame) \ | 107 V(INTERPRETED, InterpretedFrame) \ |
| 108 V(STUB, StubFrame) \ | 108 V(STUB, StubFrame) \ |
| 109 V(STUB_FAILURE_TRAMPOLINE, StubFailureTrampolineFrame) \ | 109 V(STUB_FAILURE_TRAMPOLINE, StubFailureTrampolineFrame) \ |
| 110 V(INTERNAL, InternalFrame) \ | 110 V(INTERNAL, InternalFrame) \ |
| 111 V(CONSTRUCT, ConstructFrame) \ | 111 V(CONSTRUCT, ConstructFrame) \ |
| 112 V(ARGUMENTS_ADAPTOR, ArgumentsAdaptorFrame) | 112 V(ARGUMENTS_ADAPTOR, ArgumentsAdaptorFrame) |
| 113 | 113 |
| 114 // Every pointer in a frame has a slot id. On 32-bit platforms, doubles consume | 114 // Every pointer in a frame has a slot id. On 32-bit platforms, doubles consume |
| 115 // two slots. | 115 // two slots. |
| 116 // | 116 // |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 this->iterator_ = NULL; | 303 this->iterator_ = NULL; |
| 304 this->isolate_ = original.isolate_; | 304 this->isolate_ = original.isolate_; |
| 305 } | 305 } |
| 306 | 306 |
| 307 // Type testers. | 307 // Type testers. |
| 308 bool is_entry() const { return type() == ENTRY; } | 308 bool is_entry() const { return type() == ENTRY; } |
| 309 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; } | 309 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; } |
| 310 bool is_exit() const { return type() == EXIT; } | 310 bool is_exit() const { return type() == EXIT; } |
| 311 bool is_optimized() const { return type() == OPTIMIZED; } | 311 bool is_optimized() const { return type() == OPTIMIZED; } |
| 312 bool is_interpreted() const { return type() == INTERPRETED; } | 312 bool is_interpreted() const { return type() == INTERPRETED; } |
| 313 bool is_wasm() const { return type() == WASM; } |
| 313 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } | 314 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } |
| 314 bool is_internal() const { return type() == INTERNAL; } | 315 bool is_internal() const { return type() == INTERNAL; } |
| 315 bool is_stub_failure_trampoline() const { | 316 bool is_stub_failure_trampoline() const { |
| 316 return type() == STUB_FAILURE_TRAMPOLINE; | 317 return type() == STUB_FAILURE_TRAMPOLINE; |
| 317 } | 318 } |
| 318 bool is_construct() const { return type() == CONSTRUCT; } | 319 bool is_construct() const { return type() == CONSTRUCT; } |
| 319 virtual bool is_standard() const { return false; } | 320 virtual bool is_standard() const { return false; } |
| 320 | 321 |
| 321 bool is_java_script() const { | 322 bool is_java_script() const { |
| 322 Type type = this->type(); | 323 Type type = this->type(); |
| 323 return (type == JAVA_SCRIPT) || (type == OPTIMIZED) || | 324 return (type == JAVA_SCRIPT) || (type == OPTIMIZED) || |
| 324 (type == INTERPRETED); | 325 (type == INTERPRETED); |
| 325 } | 326 } |
| 326 | 327 |
| 328 bool is_visible() const { |
| 329 Type type = this->type(); |
| 330 return is_java_script() || (type == WASM); |
| 331 } |
| 332 |
| 327 // Accessors. | 333 // Accessors. |
| 328 Address sp() const { return state_.sp; } | 334 Address sp() const { return state_.sp; } |
| 329 Address fp() const { return state_.fp; } | 335 Address fp() const { return state_.fp; } |
| 330 Address caller_sp() const { return GetCallerStackPointer(); } | 336 Address caller_sp() const { return GetCallerStackPointer(); } |
| 331 | 337 |
| 332 // If this frame is optimized and was dynamically aligned return its old | 338 // If this frame is optimized and was dynamically aligned return its old |
| 333 // unaligned frame pointer. When the frame is deoptimized its FP will shift | 339 // unaligned frame pointer. When the frame is deoptimized its FP will shift |
| 334 // up one word and become unaligned. | 340 // up one word and become unaligned. |
| 335 Address UnpaddedFP() const; | 341 Address UnpaddedFP() const; |
| 336 | 342 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 void Print(); | 616 void Print(); |
| 611 | 617 |
| 612 private: | 618 private: |
| 613 Handle<Object> receiver_; | 619 Handle<Object> receiver_; |
| 614 Handle<JSFunction> function_; | 620 Handle<JSFunction> function_; |
| 615 Handle<AbstractCode> abstract_code_; | 621 Handle<AbstractCode> abstract_code_; |
| 616 int code_offset_; | 622 int code_offset_; |
| 617 bool is_constructor_; | 623 bool is_constructor_; |
| 618 }; | 624 }; |
| 619 | 625 |
| 626 class VisibleFrame : public StandardFrame { |
| 627 public: |
| 628 // Build a list with summaries for this frame including all inlined frames. |
| 629 virtual void Summarize(List<FrameSummary>* frames) = 0; |
| 620 | 630 |
| 621 class JavaScriptFrame: public StandardFrame { | 631 static VisibleFrame* cast(StackFrame* frame) { |
| 632 DCHECK(frame->is_visible()); |
| 633 return static_cast<VisibleFrame*>(frame); |
| 634 } |
| 635 |
| 636 protected: |
| 637 inline explicit VisibleFrame(StackFrameIteratorBase* iterator); |
| 638 |
| 639 private: |
| 640 friend class StackFrameIteratorBase; |
| 641 }; |
| 642 |
| 643 class JavaScriptFrame : public VisibleFrame { |
| 622 public: | 644 public: |
| 623 Type type() const override { return JAVA_SCRIPT; } | 645 Type type() const override { return JAVA_SCRIPT; } |
| 624 | 646 |
| 625 // Accessors. | 647 // Accessors. |
| 626 inline JSFunction* function() const; | 648 inline JSFunction* function() const; |
| 627 inline Object* receiver() const; | 649 inline Object* receiver() const; |
| 628 inline void set_receiver(Object* value); | 650 inline void set_receiver(Object* value); |
| 629 | 651 |
| 630 // Access the parameters. | 652 // Access the parameters. |
| 631 inline Address GetParameterSlot(int index) const; | 653 inline Address GetParameterSlot(int index) const; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 void Print(StringStream* accumulator, PrintMode mode, | 688 void Print(StringStream* accumulator, PrintMode mode, |
| 667 int index) const override; | 689 int index) const override; |
| 668 | 690 |
| 669 // Determine the code for the frame. | 691 // Determine the code for the frame. |
| 670 Code* unchecked_code() const override; | 692 Code* unchecked_code() const override; |
| 671 | 693 |
| 672 // Return a list with JSFunctions of this frame. | 694 // Return a list with JSFunctions of this frame. |
| 673 virtual void GetFunctions(List<JSFunction*>* functions) const; | 695 virtual void GetFunctions(List<JSFunction*>* functions) const; |
| 674 | 696 |
| 675 // Build a list with summaries for this frame including all inlined frames. | 697 // Build a list with summaries for this frame including all inlined frames. |
| 676 virtual void Summarize(List<FrameSummary>* frames); | 698 void Summarize(List<FrameSummary>* frames) override; |
| 677 | 699 |
| 678 // Lookup exception handler for current {pc}, returns -1 if none found. Also | 700 // Lookup exception handler for current {pc}, returns -1 if none found. Also |
| 679 // returns data associated with the handler site specific to the frame type: | 701 // returns data associated with the handler site specific to the frame type: |
| 680 // - JavaScriptFrame : Data is the stack depth at entry of the try-block. | 702 // - JavaScriptFrame : Data is the stack depth at entry of the try-block. |
| 681 // - OptimizedFrame : Data is the stack slot count of the entire frame. | 703 // - OptimizedFrame : Data is the stack slot count of the entire frame. |
| 682 // - InterpretedFrame: Data is the register index holding the context. | 704 // - InterpretedFrame: Data is the register index holding the context. |
| 683 virtual int LookupExceptionHandlerInTable( | 705 virtual int LookupExceptionHandlerInTable( |
| 684 int* data, HandlerTable::CatchPrediction* prediction); | 706 int* data, HandlerTable::CatchPrediction* prediction); |
| 685 | 707 |
| 686 // Architecture-specific register description. | 708 // Architecture-specific register description. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 inline explicit ArgumentsAdaptorFrame(StackFrameIteratorBase* iterator); | 856 inline explicit ArgumentsAdaptorFrame(StackFrameIteratorBase* iterator); |
| 835 | 857 |
| 836 int GetNumberOfIncomingArguments() const override; | 858 int GetNumberOfIncomingArguments() const override; |
| 837 | 859 |
| 838 Address GetCallerStackPointer() const override; | 860 Address GetCallerStackPointer() const override; |
| 839 | 861 |
| 840 private: | 862 private: |
| 841 friend class StackFrameIteratorBase; | 863 friend class StackFrameIteratorBase; |
| 842 }; | 864 }; |
| 843 | 865 |
| 866 class WasmFrame : public VisibleFrame { |
| 867 public: |
| 868 Type type() const override { return WASM; } |
| 869 |
| 870 // GC support. |
| 871 void Iterate(ObjectVisitor* v) const override; |
| 872 |
| 873 // Printing support. |
| 874 void Print(StringStream* accumulator, PrintMode mode, |
| 875 int index) const override; |
| 876 |
| 877 // Determine the code for the frame. |
| 878 Code* unchecked_code() const override; |
| 879 |
| 880 void Summarize(List<FrameSummary>* frames) override; |
| 881 |
| 882 protected: |
| 883 inline explicit WasmFrame(StackFrameIteratorBase* iterator); |
| 884 |
| 885 Address GetCallerStackPointer() const override; |
| 886 |
| 887 private: |
| 888 friend class StackFrameIteratorBase; |
| 889 }; |
| 844 | 890 |
| 845 class InternalFrame: public StandardFrame { | 891 class InternalFrame: public StandardFrame { |
| 846 public: | 892 public: |
| 847 Type type() const override { return INTERNAL; } | 893 Type type() const override { return INTERNAL; } |
| 848 | 894 |
| 849 // Garbage collection support. | 895 // Garbage collection support. |
| 850 void Iterate(ObjectVisitor* v) const override; | 896 void Iterate(ObjectVisitor* v) const override; |
| 851 | 897 |
| 852 // Determine the code for the frame. | 898 // Determine the code for the frame. |
| 853 Code* unchecked_code() const override; | 899 Code* unchecked_code() const override; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 } | 1013 } |
| 968 void Advance(); | 1014 void Advance(); |
| 969 | 1015 |
| 970 private: | 1016 private: |
| 971 // Go back to the first frame. | 1017 // Go back to the first frame. |
| 972 void Reset(ThreadLocalTop* top); | 1018 void Reset(ThreadLocalTop* top); |
| 973 | 1019 |
| 974 DISALLOW_COPY_AND_ASSIGN(StackFrameIterator); | 1020 DISALLOW_COPY_AND_ASSIGN(StackFrameIterator); |
| 975 }; | 1021 }; |
| 976 | 1022 |
| 1023 // Iterator that supports iterating through all Visible frames. |
| 1024 class VisibleFrameIterator BASE_EMBEDDED { |
| 1025 public: |
| 1026 inline explicit VisibleFrameIterator(Isolate* isolate); |
| 1027 |
| 1028 inline VisibleFrame* frame() const; |
| 1029 |
| 1030 bool done() const { return iterator_.done(); } |
| 1031 void Advance(); |
| 1032 |
| 1033 protected: |
| 1034 struct NoAdvance {}; // Sentinel: construct iterator_, but don't advance it. |
| 1035 inline VisibleFrameIterator(Isolate* isolate, NoAdvance); |
| 1036 inline VisibleFrameIterator(Isolate* isolate, ThreadLocalTop* top, NoAdvance); |
| 1037 StackFrameIterator iterator_; |
| 1038 }; |
| 977 | 1039 |
| 978 // Iterator that supports iterating through all JavaScript frames. | 1040 // Iterator that supports iterating through all JavaScript frames. |
| 979 class JavaScriptFrameIterator BASE_EMBEDDED { | 1041 class JavaScriptFrameIterator : public VisibleFrameIterator { |
| 980 public: | 1042 public: |
| 981 inline explicit JavaScriptFrameIterator(Isolate* isolate); | 1043 inline explicit JavaScriptFrameIterator(Isolate* isolate); |
| 982 inline JavaScriptFrameIterator(Isolate* isolate, ThreadLocalTop* top); | 1044 inline JavaScriptFrameIterator(Isolate* isolate, ThreadLocalTop* top); |
| 983 // Skip frames until the frame with the given id is reached. | 1045 // Skip frames until the frame with the given id is reached. |
| 984 JavaScriptFrameIterator(Isolate* isolate, StackFrame::Id id); | 1046 JavaScriptFrameIterator(Isolate* isolate, StackFrame::Id id); |
| 985 | 1047 |
| 986 inline JavaScriptFrame* frame() const; | 1048 inline JavaScriptFrame* frame() const; |
| 987 | 1049 |
| 988 bool done() const { return iterator_.done(); } | |
| 989 void Advance(); | 1050 void Advance(); |
| 990 | 1051 |
| 991 // Advance to the frame holding the arguments for the current | 1052 // Advance to the frame holding the arguments for the current |
| 992 // frame. This only affects the current frame if it has adapted | 1053 // frame. This only affects the current frame if it has adapted |
| 993 // arguments. | 1054 // arguments. |
| 994 void AdvanceToArgumentsFrame(); | 1055 void AdvanceToArgumentsFrame(); |
| 995 | |
| 996 private: | |
| 997 StackFrameIterator iterator_; | |
| 998 }; | 1056 }; |
| 999 | 1057 |
| 1000 | 1058 |
| 1001 // NOTE: The stack trace frame iterator is an iterator that only | 1059 // NOTE: The stack trace frame iterator is an iterator that only |
| 1002 // traverse proper JavaScript frames; that is JavaScript frames that | 1060 // traverse proper JavaScript frames; that is JavaScript frames that |
| 1003 // have proper JavaScript functions. This excludes the problematic | 1061 // have proper JavaScript functions. This excludes the problematic |
| 1004 // functions in runtime.js. | 1062 // functions in runtime.js. |
| 1005 class StackTraceFrameIterator: public JavaScriptFrameIterator { | 1063 class StackTraceFrameIterator: public JavaScriptFrameIterator { |
| 1006 public: | 1064 public: |
| 1007 explicit StackTraceFrameIterator(Isolate* isolate); | 1065 explicit StackTraceFrameIterator(Isolate* isolate); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 | 1113 |
| 1056 | 1114 |
| 1057 // Reads all frames on the current stack and copies them into the current | 1115 // Reads all frames on the current stack and copies them into the current |
| 1058 // zone memory. | 1116 // zone memory. |
| 1059 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); | 1117 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); |
| 1060 | 1118 |
| 1061 } // namespace internal | 1119 } // namespace internal |
| 1062 } // namespace v8 | 1120 } // namespace v8 |
| 1063 | 1121 |
| 1064 #endif // V8_FRAMES_H_ | 1122 #endif // V8_FRAMES_H_ |
| OLD | NEW |