Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: src/frames.h

Issue 2623773004: [wasm] Introduce WasmToInterpreterFrame (Closed)
Patch Set: Renaming Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/debug/debug-frames.h ('k') | src/frames.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
90 private: 90 private:
91 DISALLOW_IMPLICIT_CONSTRUCTORS(StackHandler); 91 DISALLOW_IMPLICIT_CONSTRUCTORS(StackHandler);
92 }; 92 };
93 93
94 #define STACK_FRAME_TYPE_LIST(V) \ 94 #define STACK_FRAME_TYPE_LIST(V) \
95 V(ENTRY, EntryFrame) \ 95 V(ENTRY, EntryFrame) \
96 V(ENTRY_CONSTRUCT, EntryConstructFrame) \ 96 V(ENTRY_CONSTRUCT, EntryConstructFrame) \
97 V(EXIT, ExitFrame) \ 97 V(EXIT, ExitFrame) \
98 V(JAVA_SCRIPT, JavaScriptFrame) \ 98 V(JAVA_SCRIPT, JavaScriptFrame) \
99 V(OPTIMIZED, OptimizedFrame) \ 99 V(OPTIMIZED, OptimizedFrame) \
100 V(WASM, WasmFrame) \ 100 V(WASM_COMPILED, WasmCompiledFrame) \
101 V(WASM_TO_JS, WasmToJsFrame) \ 101 V(WASM_TO_JS, WasmToJsFrame) \
102 V(JS_TO_WASM, JsToWasmFrame) \ 102 V(JS_TO_WASM, JsToWasmFrame) \
103 V(WASM_INTERPRETER_ENTRY, WasmInterpreterEntryFrame) \
103 V(INTERPRETED, InterpretedFrame) \ 104 V(INTERPRETED, InterpretedFrame) \
104 V(STUB, StubFrame) \ 105 V(STUB, StubFrame) \
105 V(STUB_FAILURE_TRAMPOLINE, StubFailureTrampolineFrame) \ 106 V(STUB_FAILURE_TRAMPOLINE, StubFailureTrampolineFrame) \
106 V(INTERNAL, InternalFrame) \ 107 V(INTERNAL, InternalFrame) \
107 V(CONSTRUCT, ConstructFrame) \ 108 V(CONSTRUCT, ConstructFrame) \
108 V(ARGUMENTS_ADAPTOR, ArgumentsAdaptorFrame) \ 109 V(ARGUMENTS_ADAPTOR, ArgumentsAdaptorFrame) \
109 V(BUILTIN, BuiltinFrame) \ 110 V(BUILTIN, BuiltinFrame) \
110 V(BUILTIN_EXIT, BuiltinExitFrame) 111 V(BUILTIN_EXIT, BuiltinExitFrame)
111 112
112 // Every pointer in a frame has a slot id. On 32-bit platforms, doubles consume 113 // Every pointer in a frame has a slot id. On 32-bit platforms, doubles consume
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 this->iterator_ = NULL; 457 this->iterator_ = NULL;
457 this->isolate_ = original.isolate_; 458 this->isolate_ = original.isolate_;
458 } 459 }
459 460
460 // Type testers. 461 // Type testers.
461 bool is_entry() const { return type() == ENTRY; } 462 bool is_entry() const { return type() == ENTRY; }
462 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; } 463 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; }
463 bool is_exit() const { return type() == EXIT; } 464 bool is_exit() const { return type() == EXIT; }
464 bool is_optimized() const { return type() == OPTIMIZED; } 465 bool is_optimized() const { return type() == OPTIMIZED; }
465 bool is_interpreted() const { return type() == INTERPRETED; } 466 bool is_interpreted() const { return type() == INTERPRETED; }
466 bool is_wasm() const { return type() == WASM; } 467 bool is_wasm_compiled() const { return type() == WASM_COMPILED; }
467 bool is_wasm_to_js() const { return type() == WASM_TO_JS; } 468 bool is_wasm_to_js() const { return type() == WASM_TO_JS; }
468 bool is_js_to_wasm() const { return type() == JS_TO_WASM; } 469 bool is_js_to_wasm() const { return type() == JS_TO_WASM; }
470 bool is_wasm_interpreter_entry() const {
471 return type() == WASM_INTERPRETER_ENTRY;
472 }
469 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } 473 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; }
470 bool is_builtin() const { return type() == BUILTIN; } 474 bool is_builtin() const { return type() == BUILTIN; }
471 bool is_internal() const { return type() == INTERNAL; } 475 bool is_internal() const { return type() == INTERNAL; }
472 bool is_stub_failure_trampoline() const { 476 bool is_stub_failure_trampoline() const {
473 return type() == STUB_FAILURE_TRAMPOLINE; 477 return type() == STUB_FAILURE_TRAMPOLINE;
474 } 478 }
475 bool is_construct() const { return type() == CONSTRUCT; } 479 bool is_construct() const { return type() == CONSTRUCT; }
476 bool is_builtin_exit() const { return type() == BUILTIN_EXIT; } 480 bool is_builtin_exit() const { return type() == BUILTIN_EXIT; }
477 virtual bool is_standard() const { return false; } 481 virtual bool is_standard() const { return false; }
478 482
479 bool is_java_script() const { 483 bool is_java_script() const {
480 Type type = this->type(); 484 Type type = this->type();
481 return (type == JAVA_SCRIPT) || (type == OPTIMIZED) || 485 return (type == JAVA_SCRIPT) || (type == OPTIMIZED) ||
482 (type == INTERPRETED) || (type == BUILTIN); 486 (type == INTERPRETED) || (type == BUILTIN);
483 } 487 }
488 bool is_wasm() const {
489 Type type = this->type();
490 return type == WASM_COMPILED || type == WASM_INTERPRETER_ENTRY;
491 }
484 492
485 // Accessors. 493 // Accessors.
486 Address sp() const { return state_.sp; } 494 Address sp() const { return state_.sp; }
487 Address fp() const { return state_.fp; } 495 Address fp() const { return state_.fp; }
488 Address callee_pc() const { 496 Address callee_pc() const {
489 return state_.callee_pc_address ? *state_.callee_pc_address : nullptr; 497 return state_.callee_pc_address ? *state_.callee_pc_address : nullptr;
490 } 498 }
491 Address caller_sp() const { return GetCallerStackPointer(); } 499 Address caller_sp() const { return GetCallerStackPointer(); }
492 500
493 // If this frame is optimized and was dynamically aligned return its old 501 // If this frame is optimized and was dynamically aligned return its old
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 int ComputeParametersCount() const; 730 int ComputeParametersCount() const;
723 731
724 inline Object* receiver_slot_object() const; 732 inline Object* receiver_slot_object() const;
725 inline Object* argc_slot_object() const; 733 inline Object* argc_slot_object() const;
726 inline Object* target_slot_object() const; 734 inline Object* target_slot_object() const;
727 inline Object* new_target_slot_object() const; 735 inline Object* new_target_slot_object() const;
728 736
729 friend class StackFrameIteratorBase; 737 friend class StackFrameIteratorBase;
730 }; 738 };
731 739
732 class JavaScriptFrame; 740 class StandardFrame;
733 741
734 class FrameSummary BASE_EMBEDDED { 742 class FrameSummary BASE_EMBEDDED {
735 public: 743 public:
736 // Mode for JavaScriptFrame::Summarize. Exact summary is required to produce 744 // Mode for JavaScriptFrame::Summarize. Exact summary is required to produce
737 // an exact stack trace. It will trigger an assertion failure if that is not 745 // an exact stack trace. It will trigger an assertion failure if that is not
738 // possible, e.g., because of missing deoptimization information. The 746 // possible, e.g., because of missing deoptimization information. The
739 // approximate mode should produce a summary even without deoptimization 747 // approximate mode should produce a summary even without deoptimization
740 // information, but it might miss frames. 748 // information, but it might miss frames.
741 enum Mode { kExactSummary, kApproximateSummary }; 749 enum Mode { kExactSummary, kApproximateSummary };
742 750
743 FrameSummary(Object* receiver, JSFunction* function, 751 FrameSummary(Object* receiver, JSFunction* function,
744 AbstractCode* abstract_code, int code_offset, 752 AbstractCode* abstract_code, int code_offset,
745 bool is_constructor, Mode mode = kExactSummary); 753 bool is_constructor, Mode mode = kExactSummary);
746 754
747 static FrameSummary GetFirst(JavaScriptFrame* frame); 755 static FrameSummary GetFirst(StandardFrame* frame);
748 756
749 Handle<Object> receiver() const { return receiver_; } 757 Handle<Object> receiver() const { return receiver_; }
750 Handle<JSFunction> function() const { return function_; } 758 Handle<JSFunction> function() const { return function_; }
751 Handle<AbstractCode> abstract_code() const { return abstract_code_; } 759 Handle<AbstractCode> abstract_code() const { return abstract_code_; }
752 int code_offset() const { return code_offset_; } 760 int code_offset() const { return code_offset_; }
753 bool is_constructor() const { return is_constructor_; } 761 bool is_constructor() const { return is_constructor_; }
754 762
755 void Print(); 763 void Print();
756 764
757 private: 765 private:
(...skipping 22 matching lines...) Expand all
780 788
781 // Access the parameters. 789 // Access the parameters.
782 virtual Object* GetParameter(int index) const; 790 virtual Object* GetParameter(int index) const;
783 virtual int ComputeParametersCount() const; 791 virtual int ComputeParametersCount() const;
784 792
785 void SetCallerFp(Address caller_fp) override; 793 void SetCallerFp(Address caller_fp) override;
786 794
787 // Check if this frame is a constructor frame invoked through 'new'. 795 // Check if this frame is a constructor frame invoked through 'new'.
788 virtual bool IsConstructor() const; 796 virtual bool IsConstructor() const;
789 797
798 // Build a list with summaries for this frame including all inlined frames.
799 virtual void Summarize(
800 List<FrameSummary>* frames,
801 FrameSummary::Mode mode = FrameSummary::kExactSummary) const;
802
790 static StandardFrame* cast(StackFrame* frame) { 803 static StandardFrame* cast(StackFrame* frame) {
791 DCHECK(frame->is_standard()); 804 DCHECK(frame->is_standard());
792 return static_cast<StandardFrame*>(frame); 805 return static_cast<StandardFrame*>(frame);
793 } 806 }
794 807
795 protected: 808 protected:
796 inline explicit StandardFrame(StackFrameIteratorBase* iterator); 809 inline explicit StandardFrame(StackFrameIteratorBase* iterator);
797 810
798 void ComputeCallerState(State* state) const override; 811 void ComputeCallerState(State* state) const override;
799 812
(...skipping 29 matching lines...) Expand all
829 842
830 private: 843 private:
831 friend class StackFrame; 844 friend class StackFrame;
832 friend class SafeStackFrameIterator; 845 friend class SafeStackFrameIterator;
833 }; 846 };
834 847
835 class JavaScriptFrame : public StandardFrame { 848 class JavaScriptFrame : public StandardFrame {
836 public: 849 public:
837 Type type() const override { return JAVA_SCRIPT; } 850 Type type() const override { return JAVA_SCRIPT; }
838 851
839 // Build a list with summaries for this frame including all inlined frames. 852 void Summarize(
840 virtual void Summarize(
841 List<FrameSummary>* frames, 853 List<FrameSummary>* frames,
842 FrameSummary::Mode mode = FrameSummary::kExactSummary) const; 854 FrameSummary::Mode mode = FrameSummary::kExactSummary) const override;
843 855
844 // Accessors. 856 // Accessors.
845 virtual JSFunction* function() const; 857 virtual JSFunction* function() const;
846 Object* receiver() const override; 858 Object* receiver() const override;
847 Object* context() const override; 859 Object* context() const override;
848 Script* script() const override; 860 Script* script() const override;
849 861
850 inline void set_receiver(Object* value); 862 inline void set_receiver(Object* value);
851 863
852 // Access the parameters. 864 // Access the parameters.
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 protected: 1096 protected:
1085 inline explicit BuiltinFrame(StackFrameIteratorBase* iterator); 1097 inline explicit BuiltinFrame(StackFrameIteratorBase* iterator);
1086 1098
1087 int GetNumberOfIncomingArguments() const final; 1099 int GetNumberOfIncomingArguments() const final;
1088 void PrintFrameKind(StringStream* accumulator) const override; 1100 void PrintFrameKind(StringStream* accumulator) const override;
1089 1101
1090 private: 1102 private:
1091 friend class StackFrameIteratorBase; 1103 friend class StackFrameIteratorBase;
1092 }; 1104 };
1093 1105
1094 class WasmFrame : public StandardFrame { 1106 class WasmCompiledFrame : public StandardFrame {
1095 public: 1107 public:
1096 Type type() const override { return WASM; } 1108 Type type() const override { return WASM_COMPILED; }
1097 1109
1098 // GC support. 1110 // GC support.
1099 void Iterate(ObjectVisitor* v) const override; 1111 void Iterate(ObjectVisitor* v) const override;
1100 1112
1101 // Printing support. 1113 // Printing support.
1102 void Print(StringStream* accumulator, PrintMode mode, 1114 void Print(StringStream* accumulator, PrintMode mode,
1103 int index) const override; 1115 int index) const override;
1104 1116
1105 // Lookup exception handler for current {pc}, returns -1 if none found. Also 1117 // Lookup exception handler for current {pc}, returns -1 if none found. Also
1106 // returns the stack slot count of the entire frame. 1118 // returns the stack slot count of the entire frame.
1107 int LookupExceptionHandlerInTable(int* data); 1119 int LookupExceptionHandlerInTable(int* data);
1108 1120
1109 // Determine the code for the frame. 1121 // Determine the code for the frame.
1110 Code* unchecked_code() const override; 1122 Code* unchecked_code() const override;
1111 1123
1112 // Accessors. 1124 // Accessors.
1113 WasmInstanceObject* wasm_instance() const; 1125 WasmInstanceObject* wasm_instance() const;
1114 uint32_t function_index() const; 1126 uint32_t function_index() const;
1115 Script* script() const override; 1127 Script* script() const override;
1116 int position() const override; 1128 int position() const override;
1117 bool at_to_number_conversion() const; 1129 bool at_to_number_conversion() const;
1118 1130
1119 static WasmFrame* cast(StackFrame* frame) { 1131 void Summarize(List<FrameSummary>* frames,
1120 DCHECK(frame->is_wasm()); 1132 FrameSummary::Mode mode) const override;
1121 return static_cast<WasmFrame*>(frame); 1133
1134 static WasmCompiledFrame* cast(StackFrame* frame) {
1135 DCHECK(frame->is_wasm_compiled());
1136 return static_cast<WasmCompiledFrame*>(frame);
1122 } 1137 }
1123 1138
1124 protected: 1139 protected:
1125 inline explicit WasmFrame(StackFrameIteratorBase* iterator); 1140 inline explicit WasmCompiledFrame(StackFrameIteratorBase* iterator);
1126 1141
1127 Address GetCallerStackPointer() const override; 1142 Address GetCallerStackPointer() const override;
1128 1143
1144 private:
1145 friend class StackFrameIteratorBase;
1146 };
1147
1148 class WasmInterpreterEntryFrame : public StandardFrame {
1149 public:
1150 Type type() const override { return WASM_INTERPRETER_ENTRY; }
1151
1152 // GC support.
1153 void Iterate(ObjectVisitor* v) const override;
1154
1155 // Printing support.
1156 void Print(StringStream* accumulator, PrintMode mode,
1157 int index) const override;
1158
1159 void Summarize(
1160 List<FrameSummary>* frames,
1161 FrameSummary::Mode mode = FrameSummary::kExactSummary) const override;
1162
1163 // Determine the code for the frame.
1164 Code* unchecked_code() const override;
1165
1166 // Accessors.
1167 WasmInstanceObject* wasm_instance() const;
1168 Script* script() const override;
1169 int position() const override;
1170
1171 static WasmInterpreterEntryFrame* cast(StackFrame* frame) {
1172 DCHECK(frame->is_wasm_interpreter_entry());
1173 return static_cast<WasmInterpreterEntryFrame*>(frame);
1174 }
1175
1176 protected:
1177 inline explicit WasmInterpreterEntryFrame(StackFrameIteratorBase* iterator);
1178
1179 Address GetCallerStackPointer() const override;
1180
1129 private: 1181 private:
1130 friend class StackFrameIteratorBase; 1182 friend class StackFrameIteratorBase;
1131 }; 1183 };
1132 1184
1133 class WasmToJsFrame : public StubFrame { 1185 class WasmToJsFrame : public StubFrame {
1134 public: 1186 public:
1135 Type type() const override { return WASM_TO_JS; } 1187 Type type() const override { return WASM_TO_JS; }
1136 1188
1137 protected: 1189 protected:
1138 inline explicit WasmToJsFrame(StackFrameIteratorBase* iterator); 1190 inline explicit WasmToJsFrame(StackFrameIteratorBase* iterator);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 explicit StackTraceFrameIterator(Isolate* isolate); 1358 explicit StackTraceFrameIterator(Isolate* isolate);
1307 StackTraceFrameIterator(Isolate* isolate, StackFrame::Id id); 1359 StackTraceFrameIterator(Isolate* isolate, StackFrame::Id id);
1308 bool done() const { return iterator_.done(); } 1360 bool done() const { return iterator_.done(); }
1309 void Advance(); 1361 void Advance();
1310 1362
1311 inline StandardFrame* frame() const; 1363 inline StandardFrame* frame() const;
1312 1364
1313 inline bool is_javascript() const; 1365 inline bool is_javascript() const;
1314 inline bool is_wasm() const; 1366 inline bool is_wasm() const;
1315 inline JavaScriptFrame* javascript_frame() const; 1367 inline JavaScriptFrame* javascript_frame() const;
1316 inline WasmFrame* wasm_frame() const; 1368 // TODO(clemensh): Remove / refactor this for general wasm frames
1369 // (compiled/interpreted).
1370 inline WasmCompiledFrame* wasm_compiled_frame() const;
1317 1371
1318 // Advance to the frame holding the arguments for the current 1372 // Advance to the frame holding the arguments for the current
1319 // frame. This only affects the current frame if it is a javascript frame and 1373 // frame. This only affects the current frame if it is a javascript frame and
1320 // has adapted arguments. 1374 // has adapted arguments.
1321 void AdvanceToArgumentsFrame(); 1375 void AdvanceToArgumentsFrame();
1322 1376
1323 private: 1377 private:
1324 StackFrameIterator iterator_; 1378 StackFrameIterator iterator_;
1325 bool IsValidFrame(StackFrame* frame) const; 1379 bool IsValidFrame(StackFrame* frame) const;
1326 }; 1380 };
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 1423
1370 1424
1371 // Reads all frames on the current stack and copies them into the current 1425 // Reads all frames on the current stack and copies them into the current
1372 // zone memory. 1426 // zone memory.
1373 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); 1427 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone);
1374 1428
1375 } // namespace internal 1429 } // namespace internal
1376 } // namespace v8 1430 } // namespace v8
1377 1431
1378 #endif // V8_FRAMES_H_ 1432 #endif // V8_FRAMES_H_
OLDNEW
« no previous file with comments | « src/debug/debug-frames.h ('k') | src/frames.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698