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(); |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 void Print(); | 611 void Print(); |
611 | 612 |
612 private: | 613 private: |
613 Handle<Object> receiver_; | 614 Handle<Object> receiver_; |
614 Handle<JSFunction> function_; | 615 Handle<JSFunction> function_; |
615 Handle<AbstractCode> abstract_code_; | 616 Handle<AbstractCode> abstract_code_; |
616 int code_offset_; | 617 int code_offset_; |
617 bool is_constructor_; | 618 bool is_constructor_; |
618 }; | 619 }; |
619 | 620 |
620 | 621 class JavaScriptFrame : public StandardFrame { |
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 }; |
844 | 866 |
845 class InternalFrame: public StandardFrame { | 867 class InternalFrame: public StandardFrame { |
846 public: | 868 public: |
847 Type type() const override { return INTERNAL; } | 869 Type type() const override { return INTERNAL; } |
848 | 870 |
849 // Garbage collection support. | 871 // Garbage collection support. |
850 void Iterate(ObjectVisitor* v) const override; | 872 void Iterate(ObjectVisitor* v) const override; |
851 | 873 |
852 // Determine the code for the frame. | 874 // Determine the code for the frame. |
853 Code* unchecked_code() const override; | 875 Code* unchecked_code() const override; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 } | 989 } |
968 void Advance(); | 990 void Advance(); |
969 | 991 |
970 private: | 992 private: |
971 // Go back to the first frame. | 993 // Go back to the first frame. |
972 void Reset(ThreadLocalTop* top); | 994 void Reset(ThreadLocalTop* top); |
973 | 995 |
974 DISALLOW_COPY_AND_ASSIGN(StackFrameIterator); | 996 DISALLOW_COPY_AND_ASSIGN(StackFrameIterator); |
975 }; | 997 }; |
976 | 998 |
977 | |
978 // Iterator that supports iterating through all JavaScript frames. | 999 // Iterator that supports iterating through all JavaScript frames. |
979 class JavaScriptFrameIterator BASE_EMBEDDED { | 1000 class JavaScriptFrameIterator BASE_EMBEDDED { |
980 public: | 1001 public: |
981 inline explicit JavaScriptFrameIterator(Isolate* isolate); | 1002 inline explicit JavaScriptFrameIterator(Isolate* isolate); |
982 inline JavaScriptFrameIterator(Isolate* isolate, ThreadLocalTop* top); | 1003 inline JavaScriptFrameIterator(Isolate* isolate, ThreadLocalTop* top); |
983 // Skip frames until the frame with the given id is reached. | 1004 // Skip frames until the frame with the given id is reached. |
984 JavaScriptFrameIterator(Isolate* isolate, StackFrame::Id id); | 1005 JavaScriptFrameIterator(Isolate* isolate, StackFrame::Id id); |
985 | 1006 |
986 inline JavaScriptFrame* frame() const; | 1007 inline JavaScriptFrame* frame() const; |
987 | 1008 |
988 bool done() const { return iterator_.done(); } | 1009 bool done() const { return iterator_.done(); } |
989 void Advance(); | 1010 void Advance(); |
990 | 1011 |
991 // Advance to the frame holding the arguments for the current | 1012 // Advance to the frame holding the arguments for the current |
992 // frame. This only affects the current frame if it has adapted | 1013 // frame. This only affects the current frame if it has adapted |
993 // arguments. | 1014 // arguments. |
994 void AdvanceToArgumentsFrame(); | 1015 void AdvanceToArgumentsFrame(); |
995 | 1016 |
996 private: | 1017 private: |
997 StackFrameIterator iterator_; | 1018 StackFrameIterator iterator_; |
998 }; | 1019 }; |
999 | 1020 |
1000 | |
1001 // NOTE: The stack trace frame iterator is an iterator that only | 1021 // NOTE: The stack trace frame iterator is an iterator that only |
1002 // traverse proper JavaScript frames; that is JavaScript frames that | 1022 // traverse proper JavaScript frames; that is JavaScript frames that |
1003 // have proper JavaScript functions. This excludes the problematic | 1023 // have proper JavaScript functions. This excludes the problematic |
1004 // functions in runtime.js. | 1024 // functions in runtime.js. |
1005 class StackTraceFrameIterator: public JavaScriptFrameIterator { | 1025 class StackTraceFrameIterator: public JavaScriptFrameIterator { |
1006 public: | 1026 public: |
1007 explicit StackTraceFrameIterator(Isolate* isolate); | 1027 explicit StackTraceFrameIterator(Isolate* isolate); |
1008 void Advance(); | 1028 void Advance(); |
1009 | 1029 |
1010 private: | 1030 private: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 | 1075 |
1056 | 1076 |
1057 // Reads all frames on the current stack and copies them into the current | 1077 // Reads all frames on the current stack and copies them into the current |
1058 // zone memory. | 1078 // zone memory. |
1059 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); | 1079 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); |
1060 | 1080 |
1061 } // namespace internal | 1081 } // namespace internal |
1062 } // namespace v8 | 1082 } // namespace v8 |
1063 | 1083 |
1064 #endif // V8_FRAMES_H_ | 1084 #endif // V8_FRAMES_H_ |
OLD | NEW |