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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, 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 | 116 |
116 // Every pointer in a frame has a slot id. On 32-bit platforms, doubles consume | 117 // Every pointer in a frame has a slot id. On 32-bit platforms, doubles consume |
117 // two slots. | 118 // two slots. |
118 // | 119 // |
119 // Stack slot indices >= 0 access the callee stack with slot 0 corresponding to | 120 // Stack slot indices >= 0 access the callee stack with slot 0 corresponding to |
120 // the callee's saved return address and 1 corresponding to the saved frame | 121 // the callee's saved return address and 1 corresponding to the saved frame |
121 // pointer. Some frames have additional information stored in the fixed header, | 122 // pointer. Some frames have additional information stored in the fixed header, |
122 // for example JSFunctions store the function context and marker in the fixed | 123 // for example JSFunctions store the function context and marker in the fixed |
123 // header, with slot index 2 corresponding to the current function context and 3 | 124 // header, with slot index 2 corresponding to the current function context and 3 |
124 // corresponding to the frame marker/JSFunction. | 125 // corresponding to the frame marker/JSFunction. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 static const int kFixedSlotCountFromFp = kFixedFrameSizeFromFp / kPointerSize | 274 static const int kFixedSlotCountFromFp = kFixedFrameSizeFromFp / kPointerSize |
274 | 275 |
275 class ArgumentsAdaptorFrameConstants : public TypedFrameConstants { | 276 class ArgumentsAdaptorFrameConstants : public TypedFrameConstants { |
276 public: | 277 public: |
277 // FP-relative. | 278 // FP-relative. |
278 static const int kFunctionOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0); | 279 static const int kFunctionOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0); |
279 static const int kLengthOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1); | 280 static const int kLengthOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1); |
280 DEFINE_TYPED_FRAME_SIZES(2); | 281 DEFINE_TYPED_FRAME_SIZES(2); |
281 }; | 282 }; |
282 | 283 |
| 284 class BuiltinFrameConstants : public TypedFrameConstants { |
| 285 public: |
| 286 // FP-relative. |
| 287 static const int kFunctionOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0); |
| 288 static const int kLengthOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1); |
| 289 DEFINE_TYPED_FRAME_SIZES(2); |
| 290 }; |
| 291 |
283 class InternalFrameConstants : public TypedFrameConstants { | 292 class InternalFrameConstants : public TypedFrameConstants { |
284 public: | 293 public: |
285 // FP-relative. | 294 // FP-relative. |
286 static const int kCodeOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0); | 295 static const int kCodeOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0); |
287 DEFINE_TYPED_FRAME_SIZES(1); | 296 DEFINE_TYPED_FRAME_SIZES(1); |
288 }; | 297 }; |
289 | 298 |
290 class FrameDropperFrameConstants : public InternalFrameConstants { | 299 class FrameDropperFrameConstants : public InternalFrameConstants { |
291 public: | 300 public: |
292 // FP-relative. | 301 // FP-relative. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 // Type testers. | 413 // Type testers. |
405 bool is_entry() const { return type() == ENTRY; } | 414 bool is_entry() const { return type() == ENTRY; } |
406 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; } | 415 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; } |
407 bool is_exit() const { return type() == EXIT; } | 416 bool is_exit() const { return type() == EXIT; } |
408 bool is_optimized() const { return type() == OPTIMIZED; } | 417 bool is_optimized() const { return type() == OPTIMIZED; } |
409 bool is_interpreted() const { return type() == INTERPRETED; } | 418 bool is_interpreted() const { return type() == INTERPRETED; } |
410 bool is_wasm() const { return type() == WASM; } | 419 bool is_wasm() const { return type() == WASM; } |
411 bool is_wasm_to_js() const { return type() == WASM_TO_JS; } | 420 bool is_wasm_to_js() const { return type() == WASM_TO_JS; } |
412 bool is_js_to_wasm() const { return type() == JS_TO_WASM; } | 421 bool is_js_to_wasm() const { return type() == JS_TO_WASM; } |
413 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } | 422 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } |
| 423 bool is_builtin() const { return type() == BUILTIN; } |
414 bool is_internal() const { return type() == INTERNAL; } | 424 bool is_internal() const { return type() == INTERNAL; } |
415 bool is_stub_failure_trampoline() const { | 425 bool is_stub_failure_trampoline() const { |
416 return type() == STUB_FAILURE_TRAMPOLINE; | 426 return type() == STUB_FAILURE_TRAMPOLINE; |
417 } | 427 } |
418 bool is_construct() const { return type() == CONSTRUCT; } | 428 bool is_construct() const { return type() == CONSTRUCT; } |
419 virtual bool is_standard() const { return false; } | 429 virtual bool is_standard() const { return false; } |
420 | 430 |
421 bool is_java_script() const { | 431 bool is_java_script() const { |
422 Type type = this->type(); | 432 Type type = this->type(); |
423 return (type == JAVA_SCRIPT) || (type == OPTIMIZED) || | 433 return (type == JAVA_SCRIPT) || (type == OPTIMIZED) || |
424 (type == INTERPRETED); | 434 (type == INTERPRETED) || (type == BUILTIN); |
425 } | 435 } |
426 | 436 |
427 // Accessors. | 437 // Accessors. |
428 Address sp() const { return state_.sp; } | 438 Address sp() const { return state_.sp; } |
429 Address fp() const { return state_.fp; } | 439 Address fp() const { return state_.fp; } |
430 Address caller_sp() const { return GetCallerStackPointer(); } | 440 Address caller_sp() const { return GetCallerStackPointer(); } |
431 | 441 |
432 // If this frame is optimized and was dynamically aligned return its old | 442 // If this frame is optimized and was dynamically aligned return its old |
433 // unaligned frame pointer. When the frame is deoptimized its FP will shift | 443 // unaligned frame pointer. When the frame is deoptimized its FP will shift |
434 // up one word and become unaligned. | 444 // up one word and become unaligned. |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 void Print(StringStream* accumulator, PrintMode mode, | 953 void Print(StringStream* accumulator, PrintMode mode, |
944 int index) const override; | 954 int index) const override; |
945 | 955 |
946 static int GetLength(Address fp); | 956 static int GetLength(Address fp); |
947 | 957 |
948 protected: | 958 protected: |
949 inline explicit ArgumentsAdaptorFrame(StackFrameIteratorBase* iterator); | 959 inline explicit ArgumentsAdaptorFrame(StackFrameIteratorBase* iterator); |
950 | 960 |
951 int GetNumberOfIncomingArguments() const override; | 961 int GetNumberOfIncomingArguments() const override; |
952 | 962 |
953 Address GetCallerStackPointer() const override; | 963 private: |
| 964 friend class StackFrameIteratorBase; |
| 965 }; |
| 966 |
| 967 // Builtin frames are built for builtins with JavaScript linkage, such as |
| 968 // various standard library functions (i.e. Math.asin, Math.floor, etc.). |
| 969 class BuiltinFrame final : public JavaScriptFrame { |
| 970 public: |
| 971 Type type() const final { return BUILTIN; } |
| 972 |
| 973 static BuiltinFrame* cast(StackFrame* frame) { |
| 974 DCHECK(frame->is_builtin()); |
| 975 return static_cast<BuiltinFrame*>(frame); |
| 976 } |
| 977 |
| 978 // Printing support. |
| 979 void Print(StringStream* accumulator, PrintMode mode, int index) const final; |
| 980 |
| 981 protected: |
| 982 inline explicit BuiltinFrame(StackFrameIteratorBase* iterator); |
| 983 |
| 984 int GetNumberOfIncomingArguments() const final; |
954 | 985 |
955 private: | 986 private: |
956 friend class StackFrameIteratorBase; | 987 friend class StackFrameIteratorBase; |
957 }; | 988 }; |
958 | 989 |
959 class WasmFrame : public StandardFrame { | 990 class WasmFrame : public StandardFrame { |
960 public: | 991 public: |
961 Type type() const override { return WASM; } | 992 Type type() const override { return WASM; } |
962 | 993 |
963 // GC support. | 994 // GC support. |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 | 1251 |
1221 | 1252 |
1222 // Reads all frames on the current stack and copies them into the current | 1253 // Reads all frames on the current stack and copies them into the current |
1223 // zone memory. | 1254 // zone memory. |
1224 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); | 1255 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); |
1225 | 1256 |
1226 } // namespace internal | 1257 } // namespace internal |
1227 } // namespace v8 | 1258 } // namespace v8 |
1228 | 1259 |
1229 #endif // V8_FRAMES_H_ | 1260 #endif // V8_FRAMES_H_ |
OLD | NEW |