| 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 |
| 100 #define STACK_FRAME_TYPE_LIST(V) \ | 101 #define STACK_FRAME_TYPE_LIST(V) \ |
| 101 V(ENTRY, EntryFrame) \ | 102 V(ENTRY, EntryFrame) \ |
| 102 V(ENTRY_CONSTRUCT, EntryConstructFrame) \ | 103 V(ENTRY_CONSTRUCT, EntryConstructFrame) \ |
| 103 V(EXIT, ExitFrame) \ | 104 V(EXIT, ExitFrame) \ |
| 104 V(JAVA_SCRIPT, JavaScriptFrame) \ | 105 V(JAVA_SCRIPT, JavaScriptFrame) \ |
| 105 V(OPTIMIZED, OptimizedFrame) \ | 106 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; } | |
| 314 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } | 313 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } |
| 315 bool is_internal() const { return type() == INTERNAL; } | 314 bool is_internal() const { return type() == INTERNAL; } |
| 316 bool is_stub_failure_trampoline() const { | 315 bool is_stub_failure_trampoline() const { |
| 317 return type() == STUB_FAILURE_TRAMPOLINE; | 316 return type() == STUB_FAILURE_TRAMPOLINE; |
| 318 } | 317 } |
| 319 bool is_construct() const { return type() == CONSTRUCT; } | 318 bool is_construct() const { return type() == CONSTRUCT; } |
| 320 virtual bool is_standard() const { return false; } | 319 virtual bool is_standard() const { return false; } |
| 321 | 320 |
| 322 bool is_java_script() const { | 321 bool is_java_script() const { |
| 323 Type type = this->type(); | 322 Type type = this->type(); |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 void Print(); | 610 void Print(); |
| 612 | 611 |
| 613 private: | 612 private: |
| 614 Handle<Object> receiver_; | 613 Handle<Object> receiver_; |
| 615 Handle<JSFunction> function_; | 614 Handle<JSFunction> function_; |
| 616 Handle<AbstractCode> abstract_code_; | 615 Handle<AbstractCode> abstract_code_; |
| 617 int code_offset_; | 616 int code_offset_; |
| 618 bool is_constructor_; | 617 bool is_constructor_; |
| 619 }; | 618 }; |
| 620 | 619 |
| 621 class JavaScriptFrame : public StandardFrame { | 620 |
| 621 class JavaScriptFrame: public StandardFrame { |
| 622 public: | 622 public: |
| 623 Type type() const override { return JAVA_SCRIPT; } | 623 Type type() const override { return JAVA_SCRIPT; } |
| 624 | 624 |
| 625 // Accessors. | 625 // Accessors. |
| 626 inline JSFunction* function() const; | 626 inline JSFunction* function() const; |
| 627 inline Object* receiver() const; | 627 inline Object* receiver() const; |
| 628 inline void set_receiver(Object* value); | 628 inline void set_receiver(Object* value); |
| 629 | 629 |
| 630 // Access the parameters. | 630 // Access the parameters. |
| 631 inline Address GetParameterSlot(int index) const; | 631 inline Address GetParameterSlot(int index) const; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 inline explicit ArgumentsAdaptorFrame(StackFrameIteratorBase* iterator); | 834 inline explicit ArgumentsAdaptorFrame(StackFrameIteratorBase* iterator); |
| 835 | 835 |
| 836 int GetNumberOfIncomingArguments() const override; | 836 int GetNumberOfIncomingArguments() const override; |
| 837 | 837 |
| 838 Address GetCallerStackPointer() const override; | 838 Address GetCallerStackPointer() const override; |
| 839 | 839 |
| 840 private: | 840 private: |
| 841 friend class StackFrameIteratorBase; | 841 friend class StackFrameIteratorBase; |
| 842 }; | 842 }; |
| 843 | 843 |
| 844 class WasmFrame : public StandardFrame { | |
| 845 public: | |
| 846 Type type() const override { return WASM; } | |
| 847 | |
| 848 // GC support. | |
| 849 void Iterate(ObjectVisitor* v) const override; | |
| 850 | |
| 851 // Printing support. | |
| 852 void Print(StringStream* accumulator, PrintMode mode, | |
| 853 int index) const override; | |
| 854 | |
| 855 // Determine the code for the frame. | |
| 856 Code* unchecked_code() const override; | |
| 857 | |
| 858 protected: | |
| 859 inline explicit WasmFrame(StackFrameIteratorBase* iterator); | |
| 860 | |
| 861 Address GetCallerStackPointer() const override; | |
| 862 | |
| 863 private: | |
| 864 friend class StackFrameIteratorBase; | |
| 865 }; | |
| 866 | 844 |
| 867 class InternalFrame: public StandardFrame { | 845 class InternalFrame: public StandardFrame { |
| 868 public: | 846 public: |
| 869 Type type() const override { return INTERNAL; } | 847 Type type() const override { return INTERNAL; } |
| 870 | 848 |
| 871 // Garbage collection support. | 849 // Garbage collection support. |
| 872 void Iterate(ObjectVisitor* v) const override; | 850 void Iterate(ObjectVisitor* v) const override; |
| 873 | 851 |
| 874 // Determine the code for the frame. | 852 // Determine the code for the frame. |
| 875 Code* unchecked_code() const override; | 853 Code* unchecked_code() const override; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 } | 967 } |
| 990 void Advance(); | 968 void Advance(); |
| 991 | 969 |
| 992 private: | 970 private: |
| 993 // Go back to the first frame. | 971 // Go back to the first frame. |
| 994 void Reset(ThreadLocalTop* top); | 972 void Reset(ThreadLocalTop* top); |
| 995 | 973 |
| 996 DISALLOW_COPY_AND_ASSIGN(StackFrameIterator); | 974 DISALLOW_COPY_AND_ASSIGN(StackFrameIterator); |
| 997 }; | 975 }; |
| 998 | 976 |
| 977 |
| 999 // Iterator that supports iterating through all JavaScript frames. | 978 // Iterator that supports iterating through all JavaScript frames. |
| 1000 class JavaScriptFrameIterator BASE_EMBEDDED { | 979 class JavaScriptFrameIterator BASE_EMBEDDED { |
| 1001 public: | 980 public: |
| 1002 inline explicit JavaScriptFrameIterator(Isolate* isolate); | 981 inline explicit JavaScriptFrameIterator(Isolate* isolate); |
| 1003 inline JavaScriptFrameIterator(Isolate* isolate, ThreadLocalTop* top); | 982 inline JavaScriptFrameIterator(Isolate* isolate, ThreadLocalTop* top); |
| 1004 // Skip frames until the frame with the given id is reached. | 983 // Skip frames until the frame with the given id is reached. |
| 1005 JavaScriptFrameIterator(Isolate* isolate, StackFrame::Id id); | 984 JavaScriptFrameIterator(Isolate* isolate, StackFrame::Id id); |
| 1006 | 985 |
| 1007 inline JavaScriptFrame* frame() const; | 986 inline JavaScriptFrame* frame() const; |
| 1008 | 987 |
| 1009 bool done() const { return iterator_.done(); } | 988 bool done() const { return iterator_.done(); } |
| 1010 void Advance(); | 989 void Advance(); |
| 1011 | 990 |
| 1012 // Advance to the frame holding the arguments for the current | 991 // Advance to the frame holding the arguments for the current |
| 1013 // frame. This only affects the current frame if it has adapted | 992 // frame. This only affects the current frame if it has adapted |
| 1014 // arguments. | 993 // arguments. |
| 1015 void AdvanceToArgumentsFrame(); | 994 void AdvanceToArgumentsFrame(); |
| 1016 | 995 |
| 1017 private: | 996 private: |
| 1018 StackFrameIterator iterator_; | 997 StackFrameIterator iterator_; |
| 1019 }; | 998 }; |
| 1020 | 999 |
| 1000 |
| 1021 // NOTE: The stack trace frame iterator is an iterator that only | 1001 // NOTE: The stack trace frame iterator is an iterator that only |
| 1022 // traverse proper JavaScript frames; that is JavaScript frames that | 1002 // traverse proper JavaScript frames; that is JavaScript frames that |
| 1023 // have proper JavaScript functions. This excludes the problematic | 1003 // have proper JavaScript functions. This excludes the problematic |
| 1024 // functions in runtime.js. | 1004 // functions in runtime.js. |
| 1025 class StackTraceFrameIterator: public JavaScriptFrameIterator { | 1005 class StackTraceFrameIterator: public JavaScriptFrameIterator { |
| 1026 public: | 1006 public: |
| 1027 explicit StackTraceFrameIterator(Isolate* isolate); | 1007 explicit StackTraceFrameIterator(Isolate* isolate); |
| 1028 void Advance(); | 1008 void Advance(); |
| 1029 | 1009 |
| 1030 private: | 1010 private: |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 | 1055 |
| 1076 | 1056 |
| 1077 // Reads all frames on the current stack and copies them into the current | 1057 // Reads all frames on the current stack and copies them into the current |
| 1078 // zone memory. | 1058 // zone memory. |
| 1079 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); | 1059 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); |
| 1080 | 1060 |
| 1081 } // namespace internal | 1061 } // namespace internal |
| 1082 } // namespace v8 | 1062 } // namespace v8 |
| 1083 | 1063 |
| 1084 #endif // V8_FRAMES_H_ | 1064 #endif // V8_FRAMES_H_ |
| OLD | NEW |