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

Side by Side Diff: src/frames.h

Issue 2090723005: [builtins] New frame type for exits to C++ builtins (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 V(OPTIMIZED, OptimizedFrame) \ 105 V(OPTIMIZED, OptimizedFrame) \
106 V(WASM, WasmFrame) \ 106 V(WASM, WasmFrame) \
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(INTERPRETED, InterpretedFrame) \ 109 V(INTERPRETED, InterpretedFrame) \
110 V(STUB, StubFrame) \ 110 V(STUB, StubFrame) \
111 V(STUB_FAILURE_TRAMPOLINE, StubFailureTrampolineFrame) \ 111 V(STUB_FAILURE_TRAMPOLINE, StubFailureTrampolineFrame) \
112 V(INTERNAL, InternalFrame) \ 112 V(INTERNAL, InternalFrame) \
113 V(CONSTRUCT, ConstructFrame) \ 113 V(CONSTRUCT, ConstructFrame) \
114 V(ARGUMENTS_ADAPTOR, ArgumentsAdaptorFrame) \ 114 V(ARGUMENTS_ADAPTOR, ArgumentsAdaptorFrame) \
115 V(BUILTIN, BuiltinFrame) 115 V(BUILTIN, BuiltinFrame) \
116 V(BUILTIN_EXIT, BuiltinExitFrame)
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.
119 // 120 //
120 // Stack slot indices >= 0 access the callee stack with slot 0 corresponding to 121 // Stack slot indices >= 0 access the callee stack with slot 0 corresponding to
121 // the callee's saved return address and 1 corresponding to the saved frame 122 // the callee's saved return address and 1 corresponding to the saved frame
122 // pointer. Some frames have additional information stored in the fixed header, 123 // pointer. Some frames have additional information stored in the fixed header,
123 // for example JSFunctions store the function context and marker in the fixed 124 // for example JSFunctions store the function context and marker in the fixed
124 // header, with slot index 2 corresponding to the current function context and 3 125 // header, with slot index 2 corresponding to the current function context and 3
125 // corresponding to the frame marker/JSFunction. 126 // corresponding to the frame marker/JSFunction.
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 bool is_wasm() const { return type() == WASM; } 420 bool is_wasm() const { return type() == WASM; }
420 bool is_wasm_to_js() const { return type() == WASM_TO_JS; } 421 bool is_wasm_to_js() const { return type() == WASM_TO_JS; }
421 bool is_js_to_wasm() const { return type() == JS_TO_WASM; } 422 bool is_js_to_wasm() const { return type() == JS_TO_WASM; }
422 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } 423 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; }
423 bool is_builtin() const { return type() == BUILTIN; } 424 bool is_builtin() const { return type() == BUILTIN; }
424 bool is_internal() const { return type() == INTERNAL; } 425 bool is_internal() const { return type() == INTERNAL; }
425 bool is_stub_failure_trampoline() const { 426 bool is_stub_failure_trampoline() const {
426 return type() == STUB_FAILURE_TRAMPOLINE; 427 return type() == STUB_FAILURE_TRAMPOLINE;
427 } 428 }
428 bool is_construct() const { return type() == CONSTRUCT; } 429 bool is_construct() const { return type() == CONSTRUCT; }
430 bool is_builtin_exit() const { return type() == BUILTIN_EXIT; }
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 }
436 438
437 // Accessors. 439 // Accessors.
438 Address sp() const { return state_.sp; } 440 Address sp() const { return state_.sp; }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 static ExitFrame* cast(StackFrame* frame) { 625 static ExitFrame* cast(StackFrame* frame) {
624 DCHECK(frame->is_exit()); 626 DCHECK(frame->is_exit());
625 return static_cast<ExitFrame*>(frame); 627 return static_cast<ExitFrame*>(frame);
626 } 628 }
627 629
628 // Compute the state and type of an exit frame given a frame 630 // Compute the state and type of an exit frame given a frame
629 // pointer. Used when constructing the first stack frame seen by an 631 // pointer. Used when constructing the first stack frame seen by an
630 // iterator and the frames following entry frames. 632 // iterator and the frames following entry frames.
631 static Type GetStateForFramePointer(Address fp, State* state); 633 static Type GetStateForFramePointer(Address fp, State* state);
632 static Address ComputeStackPointer(Address fp); 634 static Address ComputeStackPointer(Address fp);
635 static StackFrame::Type ComputeFrameType(Address fp);
633 static void FillState(Address fp, Address sp, State* state); 636 static void FillState(Address fp, Address sp, State* state);
634 637
635 protected: 638 protected:
636 inline explicit ExitFrame(StackFrameIteratorBase* iterator); 639 inline explicit ExitFrame(StackFrameIteratorBase* iterator);
637 640
638 Address GetCallerStackPointer() const override; 641 Address GetCallerStackPointer() const override;
639 642
640 private: 643 private:
641 void ComputeCallerState(State* state) const override; 644 void ComputeCallerState(State* state) const override;
642 645
643 friend class StackFrameIteratorBase; 646 friend class StackFrameIteratorBase;
644 }; 647 };
645 648
649 // Builtin exit frames are a special case of exit frames, which are used
650 // whenever C++ builtins (e.g., Math.acos) are called. Their main purpose is
651 // to allow such builtins to appear in stack traces.
652 class BuiltinExitFrame : public ExitFrame {
653 public:
654 Type type() const override { return BUILTIN_EXIT; }
655
656 static BuiltinExitFrame* cast(StackFrame* frame) {
657 DCHECK(frame->is_builtin_exit());
658 return static_cast<BuiltinExitFrame*>(frame);
659 }
660
661 virtual JSFunction* function() const;
662
663 protected:
664 inline explicit BuiltinExitFrame(StackFrameIteratorBase* iterator);
665
666 private:
667 // The function is stored after the original args for every builtin
668 // exit frame.
669 static const int kFunctionOffset = 3 * kPointerSize;
670
671 inline Object* function_slot_object() const;
672
673 friend class StackFrameIteratorBase;
674 };
675
646 class JavaScriptFrame; 676 class JavaScriptFrame;
647 677
648 class FrameSummary BASE_EMBEDDED { 678 class FrameSummary BASE_EMBEDDED {
649 public: 679 public:
650 // Mode for JavaScriptFrame::Summarize. Exact summary is required to produce 680 // Mode for JavaScriptFrame::Summarize. Exact summary is required to produce
651 // an exact stack trace. It will trigger an assertion failure if that is not 681 // an exact stack trace. It will trigger an assertion failure if that is not
652 // possible, e.g., because of missing deoptimization information. The 682 // possible, e.g., because of missing deoptimization information. The
653 // approximate mode should produce a summary even without deoptimization 683 // approximate mode should produce a summary even without deoptimization
654 // information, but it might miss frames. 684 // information, but it might miss frames.
655 enum Mode { kExactSummary, kApproximateSummary }; 685 enum Mode { kExactSummary, kApproximateSummary };
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 class StackTraceFrameIterator BASE_EMBEDDED { 1222 class StackTraceFrameIterator BASE_EMBEDDED {
1193 public: 1223 public:
1194 explicit StackTraceFrameIterator(Isolate* isolate); 1224 explicit StackTraceFrameIterator(Isolate* isolate);
1195 bool done() const { return iterator_.done(); } 1225 bool done() const { return iterator_.done(); }
1196 void Advance(); 1226 void Advance();
1197 1227
1198 inline StandardFrame* frame() const; 1228 inline StandardFrame* frame() const;
1199 1229
1200 inline bool is_javascript() const; 1230 inline bool is_javascript() const;
1201 inline bool is_wasm() const; 1231 inline bool is_wasm() const;
1232 inline bool is_builtin_exit() const;
1202 inline JavaScriptFrame* javascript_frame() const; 1233 inline JavaScriptFrame* javascript_frame() const;
1203 inline WasmFrame* wasm_frame() const; 1234 inline WasmFrame* wasm_frame() const;
1235 inline BuiltinExitFrame* builtin_exit_frame() const;
1204 1236
1205 private: 1237 private:
1206 StackFrameIterator iterator_; 1238 StackFrameIterator iterator_;
1207 bool IsValidFrame(StackFrame* frame) const; 1239 bool IsValidFrame(StackFrame* frame) const;
1208 }; 1240 };
1209 1241
1210 1242
1211 class SafeStackFrameIterator: public StackFrameIteratorBase { 1243 class SafeStackFrameIterator: public StackFrameIteratorBase {
1212 public: 1244 public:
1213 SafeStackFrameIterator(Isolate* isolate, 1245 SafeStackFrameIterator(Isolate* isolate,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 1283
1252 1284
1253 // Reads all frames on the current stack and copies them into the current 1285 // Reads all frames on the current stack and copies them into the current
1254 // zone memory. 1286 // zone memory.
1255 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); 1287 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone);
1256 1288
1257 } // namespace internal 1289 } // namespace internal
1258 } // namespace v8 1290 } // namespace v8
1259 1291
1260 #endif // V8_FRAMES_H_ 1292 #endif // V8_FRAMES_H_
OLDNEW
« src/builtins.h ('K') | « src/external-reference-table.cc ('k') | src/frames.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698