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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 private: | 96 private: |
97 DISALLOW_IMPLICIT_CONSTRUCTORS(StackHandler); | 97 DISALLOW_IMPLICIT_CONSTRUCTORS(StackHandler); |
98 }; | 98 }; |
99 | 99 |
100 #define STACK_FRAME_TYPE_LIST(V) \ | 100 #define STACK_FRAME_TYPE_LIST(V) \ |
101 V(ENTRY, EntryFrame) \ | 101 V(ENTRY, EntryFrame) \ |
102 V(ENTRY_CONSTRUCT, EntryConstructFrame) \ | 102 V(ENTRY_CONSTRUCT, EntryConstructFrame) \ |
103 V(EXIT, ExitFrame) \ | 103 V(EXIT, ExitFrame) \ |
104 V(JAVA_SCRIPT, JavaScriptFrame) \ | 104 V(JAVA_SCRIPT, JavaScriptFrame) \ |
105 V(OPTIMIZED, OptimizedFrame) \ | 105 V(OPTIMIZED, OptimizedFrame) \ |
106 V(WASM, WasmFrame) \ | 106 V(WASM_COMPILED, WasmCompiledFrame) \ |
107 V(WASM_TO_JS, WasmToJsFrame) \ | 107 V(WASM_TO_JS, WasmToJsFrame) \ |
108 V(JS_TO_WASM, JsToWasmFrame) \ | 108 V(JS_TO_WASM, JsToWasmFrame) \ |
| 109 V(WASM_INTERPRETED, WasmInterpretedFrame) \ |
109 V(INTERPRETED, InterpretedFrame) \ | 110 V(INTERPRETED, InterpretedFrame) \ |
110 V(STUB, StubFrame) \ | 111 V(STUB, StubFrame) \ |
111 V(STUB_FAILURE_TRAMPOLINE, StubFailureTrampolineFrame) \ | 112 V(STUB_FAILURE_TRAMPOLINE, StubFailureTrampolineFrame) \ |
112 V(INTERNAL, InternalFrame) \ | 113 V(INTERNAL, InternalFrame) \ |
113 V(CONSTRUCT, ConstructFrame) \ | 114 V(CONSTRUCT, ConstructFrame) \ |
114 V(ARGUMENTS_ADAPTOR, ArgumentsAdaptorFrame) \ | 115 V(ARGUMENTS_ADAPTOR, ArgumentsAdaptorFrame) \ |
115 V(BUILTIN, BuiltinFrame) | 116 V(BUILTIN, BuiltinFrame) |
116 | 117 |
117 // Every pointer in a frame has a slot id. On 32-bit platforms, doubles consume | 118 // Every pointer in a frame has a slot id. On 32-bit platforms, doubles consume |
118 // two slots. | 119 // two slots. |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 this->iterator_ = NULL; | 410 this->iterator_ = NULL; |
410 this->isolate_ = original.isolate_; | 411 this->isolate_ = original.isolate_; |
411 } | 412 } |
412 | 413 |
413 // Type testers. | 414 // Type testers. |
414 bool is_entry() const { return type() == ENTRY; } | 415 bool is_entry() const { return type() == ENTRY; } |
415 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; } | 416 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; } |
416 bool is_exit() const { return type() == EXIT; } | 417 bool is_exit() const { return type() == EXIT; } |
417 bool is_optimized() const { return type() == OPTIMIZED; } | 418 bool is_optimized() const { return type() == OPTIMIZED; } |
418 bool is_interpreted() const { return type() == INTERPRETED; } | 419 bool is_interpreted() const { return type() == INTERPRETED; } |
419 bool is_wasm() const { return type() == WASM; } | 420 bool is_wasm_compiled() const { return type() == WASM_COMPILED; } |
| 421 bool is_wasm_interpreted() const { return type() == WASM_INTERPRETED; } |
420 bool is_wasm_to_js() const { return type() == WASM_TO_JS; } | 422 bool is_wasm_to_js() const { return type() == WASM_TO_JS; } |
421 bool is_js_to_wasm() const { return type() == JS_TO_WASM; } | 423 bool is_js_to_wasm() const { return type() == JS_TO_WASM; } |
422 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } | 424 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } |
423 bool is_builtin() const { return type() == BUILTIN; } | 425 bool is_builtin() const { return type() == BUILTIN; } |
424 bool is_internal() const { return type() == INTERNAL; } | 426 bool is_internal() const { return type() == INTERNAL; } |
425 bool is_stub_failure_trampoline() const { | 427 bool is_stub_failure_trampoline() const { |
426 return type() == STUB_FAILURE_TRAMPOLINE; | 428 return type() == STUB_FAILURE_TRAMPOLINE; |
427 } | 429 } |
428 bool is_construct() const { return type() == CONSTRUCT; } | 430 bool is_construct() const { return type() == CONSTRUCT; } |
429 virtual bool is_standard() const { return false; } | 431 virtual bool is_standard() const { return false; } |
430 | 432 |
431 bool is_java_script() const { | 433 bool is_java_script() const { |
432 Type type = this->type(); | 434 Type type = this->type(); |
433 return (type == JAVA_SCRIPT) || (type == OPTIMIZED) || | 435 return (type == JAVA_SCRIPT) || (type == OPTIMIZED) || |
434 (type == INTERPRETED) || (type == BUILTIN); | 436 (type == INTERPRETED) || (type == BUILTIN); |
435 } | 437 } |
| 438 bool is_wasm() const { |
| 439 Type type = this->type(); |
| 440 return type == WASM_COMPILED || type == WASM_INTERPRETED; |
| 441 } |
436 | 442 |
437 // Accessors. | 443 // Accessors. |
438 Address sp() const { return state_.sp; } | 444 Address sp() const { return state_.sp; } |
439 Address fp() const { return state_.fp; } | 445 Address fp() const { return state_.fp; } |
440 Address caller_sp() const { return GetCallerStackPointer(); } | 446 Address caller_sp() const { return GetCallerStackPointer(); } |
441 | 447 |
442 // If this frame is optimized and was dynamically aligned return its old | 448 // If this frame is optimized and was dynamically aligned return its old |
443 // unaligned frame pointer. When the frame is deoptimized its FP will shift | 449 // unaligned frame pointer. When the frame is deoptimized its FP will shift |
444 // up one word and become unaligned. | 450 // up one word and become unaligned. |
445 Address UnpaddedFP() const; | 451 Address UnpaddedFP() const; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 inline explicit ExitFrame(StackFrameIteratorBase* iterator); | 642 inline explicit ExitFrame(StackFrameIteratorBase* iterator); |
637 | 643 |
638 Address GetCallerStackPointer() const override; | 644 Address GetCallerStackPointer() const override; |
639 | 645 |
640 private: | 646 private: |
641 void ComputeCallerState(State* state) const override; | 647 void ComputeCallerState(State* state) const override; |
642 | 648 |
643 friend class StackFrameIteratorBase; | 649 friend class StackFrameIteratorBase; |
644 }; | 650 }; |
645 | 651 |
646 class JavaScriptFrame; | 652 class StandardFrame; |
647 | 653 |
648 class FrameSummary BASE_EMBEDDED { | 654 class FrameSummary BASE_EMBEDDED { |
649 public: | 655 public: |
650 // Mode for JavaScriptFrame::Summarize. Exact summary is required to produce | 656 // Mode for StandardFrame::Summarize. Exact summary is required to produce |
651 // an exact stack trace. It will trigger an assertion failure if that is not | 657 // an exact stack trace. It will trigger an assertion failure if that is not |
652 // possible, e.g., because of missing deoptimization information. The | 658 // possible, e.g., because of missing deoptimization information. The |
653 // approximate mode should produce a summary even without deoptimization | 659 // approximate mode should produce a summary even without deoptimization |
654 // information, but it might miss frames. | 660 // information, but it might miss frames. |
655 enum Mode { kExactSummary, kApproximateSummary }; | 661 enum Mode { kExactSummary, kApproximateSummary }; |
| 662 enum Flags { kNone = 0, kIsConstructor = 1 << 0, kIsWasm = 1 << 1 }; |
656 | 663 |
| 664 // Constructor for JavaScript frame summaries. |
657 FrameSummary(Object* receiver, JSFunction* function, | 665 FrameSummary(Object* receiver, JSFunction* function, |
658 AbstractCode* abstract_code, int code_offset, | 666 AbstractCode* abstract_code, int code_offset, |
659 bool is_constructor, Mode mode = kExactSummary); | 667 bool is_constructor, Mode mode = kExactSummary); |
| 668 // Constructor for Wasm frame summaries. |
| 669 FrameSummary(Object* wasm_object, int function_index, |
| 670 AbstractCode* abstract_code, int code_offset, |
| 671 Mode mode = kExactSummary); |
660 | 672 |
661 static FrameSummary GetFirst(JavaScriptFrame* frame); | 673 static FrameSummary GetFirst(StandardFrame* frame); |
| 674 static FrameSummary GetLast(StandardFrame* frame); |
662 | 675 |
663 Handle<Object> receiver() { return receiver_; } | 676 inline Handle<Object> receiver(); |
664 Handle<JSFunction> function() { return function_; } | 677 inline Handle<Object> wasm_object(); |
| 678 inline Handle<JSFunction> function(); |
| 679 Script* script(); |
| 680 inline int wasm_function_index(); |
665 Handle<AbstractCode> abstract_code() { return abstract_code_; } | 681 Handle<AbstractCode> abstract_code() { return abstract_code_; } |
666 int code_offset() { return code_offset_; } | 682 int code_offset() { return code_offset_; } |
667 bool is_constructor() { return is_constructor_; } | 683 bool is_constructor() { return flags & kIsConstructor; } |
| 684 inline bool is_subject_to_debugging(); |
| 685 |
| 686 bool is_wasm() { return flags & kIsWasm; } |
| 687 bool is_javascript() { return !(flags & kIsWasm); } |
668 | 688 |
669 void Print(); | 689 void Print(); |
670 | 690 |
671 private: | 691 private: |
672 Handle<Object> receiver_; | 692 Handle<Object> receiver_; |
673 Handle<JSFunction> function_; | 693 Handle<Object> function_; |
674 Handle<AbstractCode> abstract_code_; | 694 Handle<AbstractCode> abstract_code_; |
675 int code_offset_; | 695 int code_offset_; |
676 bool is_constructor_; | 696 Flags flags; |
677 }; | 697 }; |
678 | 698 |
679 class StandardFrame : public StackFrame { | 699 class StandardFrame : public StackFrame { |
680 public: | 700 public: |
681 // Testers. | 701 // Testers. |
682 bool is_standard() const override { return true; } | 702 bool is_standard() const override { return true; } |
683 | 703 |
684 // Accessors. | 704 // Accessors. |
685 virtual Object* receiver() const; | 705 virtual Object* receiver() const; |
686 virtual Script* script() const; | 706 virtual Script* script() const; |
687 virtual Object* context() const; | 707 virtual Object* context() const; |
| 708 virtual Object* debug_info(bool create) const; |
688 | 709 |
689 // Access the expressions in the stack frame including locals. | 710 // Access the expressions in the stack frame including locals. |
690 inline Object* GetExpression(int index) const; | 711 inline Object* GetExpression(int index) const; |
691 inline void SetExpression(int index, Object* value); | 712 inline void SetExpression(int index, Object* value); |
692 int ComputeExpressionsCount() const; | 713 int ComputeExpressionsCount() const; |
693 | 714 |
694 // Access the parameters. | 715 // Access the parameters. |
695 virtual Object* GetParameter(int index) const; | 716 virtual Object* GetParameter(int index) const; |
696 virtual int ComputeParametersCount() const; | 717 virtual int ComputeParametersCount() const; |
697 | 718 |
698 void SetCallerFp(Address caller_fp) override; | 719 void SetCallerFp(Address caller_fp) override; |
699 | 720 |
700 // Check if this frame is a constructor frame invoked through 'new'. | 721 // Check if this frame is a constructor frame invoked through 'new'. |
701 virtual bool IsConstructor() const; | 722 virtual bool IsConstructor() const; |
702 | 723 |
| 724 // Build a list with summaries for this frame including all inlined frames. |
| 725 virtual void Summarize( |
| 726 List<FrameSummary>* frames, |
| 727 FrameSummary::Mode mode = FrameSummary::kExactSummary) const; |
| 728 |
703 static StandardFrame* cast(StackFrame* frame) { | 729 static StandardFrame* cast(StackFrame* frame) { |
704 DCHECK(frame->is_standard()); | 730 DCHECK(frame->is_standard()); |
705 return static_cast<StandardFrame*>(frame); | 731 return static_cast<StandardFrame*>(frame); |
706 } | 732 } |
707 | 733 |
708 protected: | 734 protected: |
709 inline explicit StandardFrame(StackFrameIteratorBase* iterator); | 735 inline explicit StandardFrame(StackFrameIteratorBase* iterator); |
710 | 736 |
711 void ComputeCallerState(State* state) const override; | 737 void ComputeCallerState(State* state) const override; |
712 | 738 |
(...skipping 29 matching lines...) Expand all Loading... |
742 | 768 |
743 private: | 769 private: |
744 friend class StackFrame; | 770 friend class StackFrame; |
745 friend class SafeStackFrameIterator; | 771 friend class SafeStackFrameIterator; |
746 }; | 772 }; |
747 | 773 |
748 class JavaScriptFrame : public StandardFrame { | 774 class JavaScriptFrame : public StandardFrame { |
749 public: | 775 public: |
750 Type type() const override { return JAVA_SCRIPT; } | 776 Type type() const override { return JAVA_SCRIPT; } |
751 | 777 |
752 // Build a list with summaries for this frame including all inlined frames. | 778 void Summarize( |
753 virtual void Summarize( | |
754 List<FrameSummary>* frames, | 779 List<FrameSummary>* frames, |
755 FrameSummary::Mode mode = FrameSummary::kExactSummary) const; | 780 FrameSummary::Mode mode = FrameSummary::kExactSummary) const override; |
756 | 781 |
757 // Accessors. | 782 // Accessors. |
758 virtual JSFunction* function() const; | 783 virtual JSFunction* function() const; |
759 Object* receiver() const override; | 784 Object* receiver() const override; |
760 Object* context() const override; | 785 Object* context() const override; |
761 Script* script() const override; | 786 Script* script() const override; |
| 787 Object* debug_info(bool create) const override; |
762 | 788 |
763 inline void set_receiver(Object* value); | 789 inline void set_receiver(Object* value); |
764 | 790 |
765 // Access the parameters. | 791 // Access the parameters. |
766 inline Address GetParameterSlot(int index) const; | 792 inline Address GetParameterSlot(int index) const; |
767 Object* GetParameter(int index) const override; | 793 Object* GetParameter(int index) const override; |
768 int ComputeParametersCount() const override; | 794 int ComputeParametersCount() const override; |
769 | 795 |
770 // Access the operand stack. | 796 // Access the operand stack. |
771 inline Address GetOperandSlot(int index) const; | 797 inline Address GetOperandSlot(int index) const; |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 inline explicit BuiltinFrame(StackFrameIteratorBase* iterator); | 1017 inline explicit BuiltinFrame(StackFrameIteratorBase* iterator); |
992 | 1018 |
993 int GetNumberOfIncomingArguments() const final; | 1019 int GetNumberOfIncomingArguments() const final; |
994 | 1020 |
995 private: | 1021 private: |
996 friend class StackFrameIteratorBase; | 1022 friend class StackFrameIteratorBase; |
997 }; | 1023 }; |
998 | 1024 |
999 class WasmFrame : public StandardFrame { | 1025 class WasmFrame : public StandardFrame { |
1000 public: | 1026 public: |
1001 Type type() const override { return WASM; } | |
1002 | |
1003 // GC support. | 1027 // GC support. |
1004 void Iterate(ObjectVisitor* v) const override; | 1028 void Iterate(ObjectVisitor* v) const override; |
1005 | 1029 |
1006 // Printing support. | 1030 // Printing support. |
1007 void Print(StringStream* accumulator, PrintMode mode, | 1031 void Print(StringStream* accumulator, PrintMode mode, |
1008 int index) const override; | 1032 int index) const override; |
1009 | 1033 |
1010 // Determine the code for the frame. | 1034 // Determine the code for the frame. |
1011 Code* unchecked_code() const override; | 1035 Code* unchecked_code() const override; |
1012 | 1036 |
1013 // Accessors. | 1037 // Accessors. |
1014 Object* wasm_obj() const; | 1038 virtual Object* wasm_obj() const = 0; |
1015 uint32_t function_index() const; | |
1016 Script* script() const override; | |
1017 | 1039 |
1018 static WasmFrame* cast(StackFrame* frame) { | 1040 static WasmFrame* cast(StackFrame* frame) { |
1019 DCHECK(frame->is_wasm()); | 1041 DCHECK(frame->is_wasm_compiled() || frame->is_wasm_interpreted()); |
1020 return static_cast<WasmFrame*>(frame); | 1042 return static_cast<WasmFrame*>(frame); |
1021 } | 1043 } |
1022 | 1044 |
1023 protected: | 1045 protected: |
1024 inline explicit WasmFrame(StackFrameIteratorBase* iterator); | 1046 inline explicit WasmFrame(StackFrameIteratorBase* iterator); |
1025 | 1047 |
1026 Address GetCallerStackPointer() const override; | 1048 Address GetCallerStackPointer() const override; |
1027 | 1049 |
1028 private: | 1050 private: |
1029 friend class StackFrameIteratorBase; | 1051 friend class StackFrameIteratorBase; |
1030 }; | 1052 }; |
1031 | 1053 |
| 1054 class WasmCompiledFrame : public WasmFrame { |
| 1055 public: |
| 1056 Type type() const override { return WASM_COMPILED; } |
| 1057 |
| 1058 // Accessors. |
| 1059 Object* wasm_obj() const override; |
| 1060 uint32_t function_index() const; |
| 1061 Script* script() const override; |
| 1062 Object* debug_info(bool create) const override; |
| 1063 |
| 1064 void Summarize( |
| 1065 List<FrameSummary>* frames, |
| 1066 FrameSummary::Mode mode = FrameSummary::kExactSummary) const override; |
| 1067 |
| 1068 static WasmCompiledFrame* cast(StackFrame* frame) { |
| 1069 DCHECK(frame->is_wasm_compiled()); |
| 1070 return static_cast<WasmCompiledFrame*>(frame); |
| 1071 } |
| 1072 |
| 1073 protected: |
| 1074 inline explicit WasmCompiledFrame(StackFrameIteratorBase* iterator); |
| 1075 |
| 1076 private: |
| 1077 friend class StackFrameIteratorBase; |
| 1078 }; |
| 1079 |
| 1080 class WasmInterpretedFrame : public WasmFrame { |
| 1081 public: |
| 1082 Type type() const override { return WASM_INTERPRETED; } |
| 1083 |
| 1084 // Accessors. |
| 1085 Object* wasm_obj() const override; |
| 1086 // Return the debug info for the top-most interpreted function. |
| 1087 Object* debug_info(bool create) const override; |
| 1088 |
| 1089 static WasmInterpretedFrame* cast(StackFrame* frame) { |
| 1090 DCHECK(frame->is_wasm_interpreted()); |
| 1091 return static_cast<WasmInterpretedFrame*>(frame); |
| 1092 } |
| 1093 |
| 1094 void Summarize( |
| 1095 List<FrameSummary>* frames, |
| 1096 FrameSummary::Mode mode = FrameSummary::kExactSummary) const override; |
| 1097 |
| 1098 protected: |
| 1099 inline explicit WasmInterpretedFrame(StackFrameIteratorBase* iterator); |
| 1100 |
| 1101 private: |
| 1102 friend class StackFrameIteratorBase; |
| 1103 }; |
| 1104 |
1032 class WasmToJsFrame : public StubFrame { | 1105 class WasmToJsFrame : public StubFrame { |
1033 public: | 1106 public: |
1034 Type type() const override { return WASM_TO_JS; } | 1107 Type type() const override { return WASM_TO_JS; } |
1035 | 1108 |
1036 protected: | 1109 protected: |
1037 inline explicit WasmToJsFrame(StackFrameIteratorBase* iterator); | 1110 inline explicit WasmToJsFrame(StackFrameIteratorBase* iterator); |
1038 | 1111 |
1039 private: | 1112 private: |
1040 friend class StackFrameIteratorBase; | 1113 friend class StackFrameIteratorBase; |
1041 }; | 1114 }; |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 | 1341 |
1269 | 1342 |
1270 // Reads all frames on the current stack and copies them into the current | 1343 // Reads all frames on the current stack and copies them into the current |
1271 // zone memory. | 1344 // zone memory. |
1272 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); | 1345 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); |
1273 | 1346 |
1274 } // namespace internal | 1347 } // namespace internal |
1275 } // namespace v8 | 1348 } // namespace v8 |
1276 | 1349 |
1277 #endif // V8_FRAMES_H_ | 1350 #endif // V8_FRAMES_H_ |
OLD | NEW |