Chromium Code Reviews| 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 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_TO_INTERPRETER, WasmToInterpreterFrame) \ | |
|
titzer
2017/01/10 18:54:56
Can we name this WASM_INTERPRETER_ENTRY?
Clemens Hammacher
2017/01/11 08:39:15
Renamed
- Code::WASM_TO_INTERPRETER to Code::WASM_
| |
| 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 Loading... | |
| 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_to_interpreter() const { return type() == WASM_TO_INTERPRETER; } | |
|
titzer
2017/01/10 18:54:56
same here.
Clemens Hammacher
2017/01/11 08:39:15
Done.
| |
| 469 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } | 471 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } |
| 470 bool is_builtin() const { return type() == BUILTIN; } | 472 bool is_builtin() const { return type() == BUILTIN; } |
| 471 bool is_internal() const { return type() == INTERNAL; } | 473 bool is_internal() const { return type() == INTERNAL; } |
| 472 bool is_stub_failure_trampoline() const { | 474 bool is_stub_failure_trampoline() const { |
| 473 return type() == STUB_FAILURE_TRAMPOLINE; | 475 return type() == STUB_FAILURE_TRAMPOLINE; |
| 474 } | 476 } |
| 475 bool is_construct() const { return type() == CONSTRUCT; } | 477 bool is_construct() const { return type() == CONSTRUCT; } |
| 476 bool is_builtin_exit() const { return type() == BUILTIN_EXIT; } | 478 bool is_builtin_exit() const { return type() == BUILTIN_EXIT; } |
| 477 virtual bool is_standard() const { return false; } | 479 virtual bool is_standard() const { return false; } |
| 478 | 480 |
| 479 bool is_java_script() const { | 481 bool is_java_script() const { |
| 480 Type type = this->type(); | 482 Type type = this->type(); |
| 481 return (type == JAVA_SCRIPT) || (type == OPTIMIZED) || | 483 return (type == JAVA_SCRIPT) || (type == OPTIMIZED) || |
| 482 (type == INTERPRETED) || (type == BUILTIN); | 484 (type == INTERPRETED) || (type == BUILTIN); |
| 483 } | 485 } |
| 486 bool is_wasm() const { | |
| 487 Type type = this->type(); | |
| 488 return type == WASM_COMPILED || type == WASM_TO_INTERPRETER; | |
| 489 } | |
| 484 | 490 |
| 485 // Accessors. | 491 // Accessors. |
| 486 Address sp() const { return state_.sp; } | 492 Address sp() const { return state_.sp; } |
| 487 Address fp() const { return state_.fp; } | 493 Address fp() const { return state_.fp; } |
| 488 Address callee_pc() const { | 494 Address callee_pc() const { |
| 489 return state_.callee_pc_address ? *state_.callee_pc_address : nullptr; | 495 return state_.callee_pc_address ? *state_.callee_pc_address : nullptr; |
| 490 } | 496 } |
| 491 Address caller_sp() const { return GetCallerStackPointer(); } | 497 Address caller_sp() const { return GetCallerStackPointer(); } |
| 492 | 498 |
| 493 // If this frame is optimized and was dynamically aligned return its old | 499 // If this frame is optimized and was dynamically aligned return its old |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 722 int ComputeParametersCount() const; | 728 int ComputeParametersCount() const; |
| 723 | 729 |
| 724 inline Object* receiver_slot_object() const; | 730 inline Object* receiver_slot_object() const; |
| 725 inline Object* argc_slot_object() const; | 731 inline Object* argc_slot_object() const; |
| 726 inline Object* target_slot_object() const; | 732 inline Object* target_slot_object() const; |
| 727 inline Object* new_target_slot_object() const; | 733 inline Object* new_target_slot_object() const; |
| 728 | 734 |
| 729 friend class StackFrameIteratorBase; | 735 friend class StackFrameIteratorBase; |
| 730 }; | 736 }; |
| 731 | 737 |
| 732 class JavaScriptFrame; | 738 class StandardFrame; |
| 733 | 739 |
| 734 class FrameSummary BASE_EMBEDDED { | 740 class FrameSummary BASE_EMBEDDED { |
| 735 public: | 741 public: |
| 736 // Mode for JavaScriptFrame::Summarize. Exact summary is required to produce | 742 // 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 | 743 // an exact stack trace. It will trigger an assertion failure if that is not |
| 738 // possible, e.g., because of missing deoptimization information. The | 744 // possible, e.g., because of missing deoptimization information. The |
| 739 // approximate mode should produce a summary even without deoptimization | 745 // approximate mode should produce a summary even without deoptimization |
| 740 // information, but it might miss frames. | 746 // information, but it might miss frames. |
| 741 enum Mode { kExactSummary, kApproximateSummary }; | 747 enum Mode { kExactSummary, kApproximateSummary }; |
| 742 | 748 |
| 743 FrameSummary(Object* receiver, JSFunction* function, | 749 FrameSummary(Object* receiver, JSFunction* function, |
| 744 AbstractCode* abstract_code, int code_offset, | 750 AbstractCode* abstract_code, int code_offset, |
| 745 bool is_constructor, Mode mode = kExactSummary); | 751 bool is_constructor, Mode mode = kExactSummary); |
| 746 | 752 |
| 747 static FrameSummary GetFirst(JavaScriptFrame* frame); | 753 static FrameSummary GetFirst(StandardFrame* frame); |
| 748 | 754 |
| 749 Handle<Object> receiver() const { return receiver_; } | 755 Handle<Object> receiver() const { return receiver_; } |
| 750 Handle<JSFunction> function() const { return function_; } | 756 Handle<JSFunction> function() const { return function_; } |
| 751 Handle<AbstractCode> abstract_code() const { return abstract_code_; } | 757 Handle<AbstractCode> abstract_code() const { return abstract_code_; } |
| 752 int code_offset() const { return code_offset_; } | 758 int code_offset() const { return code_offset_; } |
| 753 bool is_constructor() const { return is_constructor_; } | 759 bool is_constructor() const { return is_constructor_; } |
| 754 | 760 |
| 755 void Print(); | 761 void Print(); |
| 756 | 762 |
| 757 private: | 763 private: |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 780 | 786 |
| 781 // Access the parameters. | 787 // Access the parameters. |
| 782 virtual Object* GetParameter(int index) const; | 788 virtual Object* GetParameter(int index) const; |
| 783 virtual int ComputeParametersCount() const; | 789 virtual int ComputeParametersCount() const; |
| 784 | 790 |
| 785 void SetCallerFp(Address caller_fp) override; | 791 void SetCallerFp(Address caller_fp) override; |
| 786 | 792 |
| 787 // Check if this frame is a constructor frame invoked through 'new'. | 793 // Check if this frame is a constructor frame invoked through 'new'. |
| 788 virtual bool IsConstructor() const; | 794 virtual bool IsConstructor() const; |
| 789 | 795 |
| 796 // Build a list with summaries for this frame including all inlined frames. | |
| 797 virtual void Summarize( | |
| 798 List<FrameSummary>* frames, | |
| 799 FrameSummary::Mode mode = FrameSummary::kExactSummary) const; | |
| 800 | |
| 790 static StandardFrame* cast(StackFrame* frame) { | 801 static StandardFrame* cast(StackFrame* frame) { |
| 791 DCHECK(frame->is_standard()); | 802 DCHECK(frame->is_standard()); |
| 792 return static_cast<StandardFrame*>(frame); | 803 return static_cast<StandardFrame*>(frame); |
| 793 } | 804 } |
| 794 | 805 |
| 795 protected: | 806 protected: |
| 796 inline explicit StandardFrame(StackFrameIteratorBase* iterator); | 807 inline explicit StandardFrame(StackFrameIteratorBase* iterator); |
| 797 | 808 |
| 798 void ComputeCallerState(State* state) const override; | 809 void ComputeCallerState(State* state) const override; |
| 799 | 810 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 829 | 840 |
| 830 private: | 841 private: |
| 831 friend class StackFrame; | 842 friend class StackFrame; |
| 832 friend class SafeStackFrameIterator; | 843 friend class SafeStackFrameIterator; |
| 833 }; | 844 }; |
| 834 | 845 |
| 835 class JavaScriptFrame : public StandardFrame { | 846 class JavaScriptFrame : public StandardFrame { |
| 836 public: | 847 public: |
| 837 Type type() const override { return JAVA_SCRIPT; } | 848 Type type() const override { return JAVA_SCRIPT; } |
| 838 | 849 |
| 839 // Build a list with summaries for this frame including all inlined frames. | 850 void Summarize( |
| 840 virtual void Summarize( | |
| 841 List<FrameSummary>* frames, | 851 List<FrameSummary>* frames, |
| 842 FrameSummary::Mode mode = FrameSummary::kExactSummary) const; | 852 FrameSummary::Mode mode = FrameSummary::kExactSummary) const override; |
| 843 | 853 |
| 844 // Accessors. | 854 // Accessors. |
| 845 virtual JSFunction* function() const; | 855 virtual JSFunction* function() const; |
| 846 Object* receiver() const override; | 856 Object* receiver() const override; |
| 847 Object* context() const override; | 857 Object* context() const override; |
| 848 Script* script() const override; | 858 Script* script() const override; |
| 849 | 859 |
| 850 inline void set_receiver(Object* value); | 860 inline void set_receiver(Object* value); |
| 851 | 861 |
| 852 // Access the parameters. | 862 // Access the parameters. |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1084 protected: | 1094 protected: |
| 1085 inline explicit BuiltinFrame(StackFrameIteratorBase* iterator); | 1095 inline explicit BuiltinFrame(StackFrameIteratorBase* iterator); |
| 1086 | 1096 |
| 1087 int GetNumberOfIncomingArguments() const final; | 1097 int GetNumberOfIncomingArguments() const final; |
| 1088 void PrintFrameKind(StringStream* accumulator) const override; | 1098 void PrintFrameKind(StringStream* accumulator) const override; |
| 1089 | 1099 |
| 1090 private: | 1100 private: |
| 1091 friend class StackFrameIteratorBase; | 1101 friend class StackFrameIteratorBase; |
| 1092 }; | 1102 }; |
| 1093 | 1103 |
| 1094 class WasmFrame : public StandardFrame { | 1104 class WasmCompiledFrame : public StandardFrame { |
| 1095 public: | 1105 public: |
| 1096 Type type() const override { return WASM; } | 1106 Type type() const override { return WASM_COMPILED; } |
| 1097 | 1107 |
| 1098 // GC support. | 1108 // GC support. |
| 1099 void Iterate(ObjectVisitor* v) const override; | 1109 void Iterate(ObjectVisitor* v) const override; |
| 1100 | 1110 |
| 1101 // Printing support. | 1111 // Printing support. |
| 1102 void Print(StringStream* accumulator, PrintMode mode, | 1112 void Print(StringStream* accumulator, PrintMode mode, |
| 1103 int index) const override; | 1113 int index) const override; |
| 1104 | 1114 |
| 1105 // Lookup exception handler for current {pc}, returns -1 if none found. Also | 1115 // Lookup exception handler for current {pc}, returns -1 if none found. Also |
| 1106 // returns the stack slot count of the entire frame. | 1116 // returns the stack slot count of the entire frame. |
| 1107 int LookupExceptionHandlerInTable(int* data); | 1117 int LookupExceptionHandlerInTable(int* data); |
| 1108 | 1118 |
| 1109 // Determine the code for the frame. | 1119 // Determine the code for the frame. |
| 1110 Code* unchecked_code() const override; | 1120 Code* unchecked_code() const override; |
| 1111 | 1121 |
| 1112 // Accessors. | 1122 // Accessors. |
| 1113 WasmInstanceObject* wasm_instance() const; | 1123 WasmInstanceObject* wasm_instance() const; |
| 1114 uint32_t function_index() const; | 1124 uint32_t function_index() const; |
| 1115 Script* script() const override; | 1125 Script* script() const override; |
| 1116 int position() const override; | 1126 int position() const override; |
| 1117 bool at_to_number_conversion() const; | 1127 bool at_to_number_conversion() const; |
| 1118 | 1128 |
| 1119 static WasmFrame* cast(StackFrame* frame) { | 1129 void Summarize(List<FrameSummary>* frames, |
| 1120 DCHECK(frame->is_wasm()); | 1130 FrameSummary::Mode mode) const override; |
| 1121 return static_cast<WasmFrame*>(frame); | 1131 |
| 1132 static WasmCompiledFrame* cast(StackFrame* frame) { | |
| 1133 DCHECK(frame->is_wasm_compiled()); | |
| 1134 return static_cast<WasmCompiledFrame*>(frame); | |
| 1122 } | 1135 } |
| 1123 | 1136 |
| 1124 protected: | 1137 protected: |
| 1125 inline explicit WasmFrame(StackFrameIteratorBase* iterator); | 1138 inline explicit WasmCompiledFrame(StackFrameIteratorBase* iterator); |
| 1126 | 1139 |
| 1127 Address GetCallerStackPointer() const override; | 1140 Address GetCallerStackPointer() const override; |
| 1128 | 1141 |
| 1142 private: | |
| 1143 friend class StackFrameIteratorBase; | |
| 1144 }; | |
| 1145 | |
| 1146 class WasmToInterpreterFrame : public StandardFrame { | |
| 1147 public: | |
| 1148 Type type() const override { return WASM_TO_INTERPRETER; } | |
| 1149 | |
| 1150 // GC support. | |
| 1151 void Iterate(ObjectVisitor* v) const override; | |
| 1152 | |
| 1153 // Printing support. | |
| 1154 void Print(StringStream* accumulator, PrintMode mode, | |
| 1155 int index) const override; | |
| 1156 | |
| 1157 void Summarize( | |
| 1158 List<FrameSummary>* frames, | |
| 1159 FrameSummary::Mode mode = FrameSummary::kExactSummary) const override; | |
| 1160 | |
| 1161 // Determine the code for the frame. | |
| 1162 Code* unchecked_code() const override; | |
| 1163 | |
| 1164 // Accessors. | |
| 1165 WasmInstanceObject* wasm_instance() const; | |
| 1166 Script* script() const override; | |
| 1167 int position() const override; | |
| 1168 | |
| 1169 static WasmToInterpreterFrame* cast(StackFrame* frame) { | |
| 1170 DCHECK(frame->is_wasm_to_interpreter()); | |
| 1171 return static_cast<WasmToInterpreterFrame*>(frame); | |
| 1172 } | |
| 1173 | |
| 1174 protected: | |
| 1175 inline explicit WasmToInterpreterFrame(StackFrameIteratorBase* iterator); | |
| 1176 | |
| 1177 Address GetCallerStackPointer() const override; | |
| 1178 | |
| 1129 private: | 1179 private: |
| 1130 friend class StackFrameIteratorBase; | 1180 friend class StackFrameIteratorBase; |
| 1131 }; | 1181 }; |
| 1132 | 1182 |
| 1133 class WasmToJsFrame : public StubFrame { | 1183 class WasmToJsFrame : public StubFrame { |
| 1134 public: | 1184 public: |
| 1135 Type type() const override { return WASM_TO_JS; } | 1185 Type type() const override { return WASM_TO_JS; } |
| 1136 | 1186 |
| 1137 protected: | 1187 protected: |
| 1138 inline explicit WasmToJsFrame(StackFrameIteratorBase* iterator); | 1188 inline explicit WasmToJsFrame(StackFrameIteratorBase* iterator); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1306 explicit StackTraceFrameIterator(Isolate* isolate); | 1356 explicit StackTraceFrameIterator(Isolate* isolate); |
| 1307 StackTraceFrameIterator(Isolate* isolate, StackFrame::Id id); | 1357 StackTraceFrameIterator(Isolate* isolate, StackFrame::Id id); |
| 1308 bool done() const { return iterator_.done(); } | 1358 bool done() const { return iterator_.done(); } |
| 1309 void Advance(); | 1359 void Advance(); |
| 1310 | 1360 |
| 1311 inline StandardFrame* frame() const; | 1361 inline StandardFrame* frame() const; |
| 1312 | 1362 |
| 1313 inline bool is_javascript() const; | 1363 inline bool is_javascript() const; |
| 1314 inline bool is_wasm() const; | 1364 inline bool is_wasm() const; |
| 1315 inline JavaScriptFrame* javascript_frame() const; | 1365 inline JavaScriptFrame* javascript_frame() const; |
| 1316 inline WasmFrame* wasm_frame() const; | 1366 // TODO(clemensh): Remove / refactor this for general wasm frames |
| 1367 // (compiled/interpreted). | |
| 1368 inline WasmCompiledFrame* wasm_compiled_frame() const; | |
| 1317 | 1369 |
| 1318 // Advance to the frame holding the arguments for the current | 1370 // 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 | 1371 // frame. This only affects the current frame if it is a javascript frame and |
| 1320 // has adapted arguments. | 1372 // has adapted arguments. |
| 1321 void AdvanceToArgumentsFrame(); | 1373 void AdvanceToArgumentsFrame(); |
| 1322 | 1374 |
| 1323 private: | 1375 private: |
| 1324 StackFrameIterator iterator_; | 1376 StackFrameIterator iterator_; |
| 1325 bool IsValidFrame(StackFrame* frame) const; | 1377 bool IsValidFrame(StackFrame* frame) const; |
| 1326 }; | 1378 }; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1369 | 1421 |
| 1370 | 1422 |
| 1371 // Reads all frames on the current stack and copies them into the current | 1423 // Reads all frames on the current stack and copies them into the current |
| 1372 // zone memory. | 1424 // zone memory. |
| 1373 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); | 1425 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); |
| 1374 | 1426 |
| 1375 } // namespace internal | 1427 } // namespace internal |
| 1376 } // namespace v8 | 1428 } // namespace v8 |
| 1377 | 1429 |
| 1378 #endif // V8_FRAMES_H_ | 1430 #endif // V8_FRAMES_H_ |
| OLD | NEW |