| 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/flags.h" | 9 #include "src/flags.h" |
| 10 #include "src/handles.h" | 10 #include "src/handles.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // Get the next stack handler in the chain. | 91 // Get the next stack handler in the chain. |
| 92 inline StackHandler* next() const; | 92 inline StackHandler* next() const; |
| 93 | 93 |
| 94 // Conversion support. | 94 // Conversion support. |
| 95 static inline StackHandler* FromAddress(Address address); | 95 static inline StackHandler* FromAddress(Address address); |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 DISALLOW_IMPLICIT_CONSTRUCTORS(StackHandler); | 98 DISALLOW_IMPLICIT_CONSTRUCTORS(StackHandler); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 #define STACK_FRAME_TYPE_LIST(V) \ | 101 #define STACK_FRAME_TYPE_LIST(V) \ |
| 102 V(ENTRY, EntryFrame) \ | 102 V(ENTRY, EntryFrame) \ |
| 103 V(ENTRY_CONSTRUCT, EntryConstructFrame) \ | 103 V(ENTRY_CONSTRUCT, EntryConstructFrame) \ |
| 104 V(EXIT, ExitFrame) \ | 104 V(EXIT, ExitFrame) \ |
| 105 V(JAVA_SCRIPT, JavaScriptFrame) \ | 105 V(JAVA_SCRIPT, JavaScriptFrame) \ |
| 106 V(OPTIMIZED, OptimizedFrame) \ | 106 V(OPTIMIZED, OptimizedFrame) \ |
| 107 V(WASM_COMPILED, WasmCompiledFrame) \ | 107 V(WASM_COMPILED, WasmCompiledFrame) \ |
| 108 V(WASM_TO_JS, WasmToJsFrame) \ | 108 V(WASM_TO_JS, WasmToJsFrame) \ |
| 109 V(JS_TO_WASM, JsToWasmFrame) \ | 109 V(JS_TO_WASM, JsToWasmFrame) \ |
| 110 V(WASM_INTERPRETER_ENTRY, WasmInterpreterEntryFrame) \ | 110 V(WASM_INTERPRETER_ENTRY, WasmInterpreterEntryFrame) \ |
| 111 V(INTERPRETED, InterpretedFrame) \ | 111 V(INTERPRETED, InterpretedFrame) \ |
| 112 V(STUB, StubFrame) \ | 112 V(STUB, StubFrame) \ |
| 113 V(STUB_FAILURE_TRAMPOLINE, StubFailureTrampolineFrame) \ | 113 V(STUB_FAILURE_TRAMPOLINE, StubFailureTrampolineFrame) \ |
| 114 V(INTERNAL, InternalFrame) \ | 114 V(BUILTIN_CONTINUATION, BuiltinContinuationFrame) \ |
| 115 V(CONSTRUCT, ConstructFrame) \ | 115 V(JAVA_SCRIPT_BUILTIN_CONTINUATION, JavaScriptBuiltinContinuationFrame) \ |
| 116 V(ARGUMENTS_ADAPTOR, ArgumentsAdaptorFrame) \ | 116 V(INTERNAL, InternalFrame) \ |
| 117 V(BUILTIN, BuiltinFrame) \ | 117 V(CONSTRUCT, ConstructFrame) \ |
| 118 V(ARGUMENTS_ADAPTOR, ArgumentsAdaptorFrame) \ |
| 119 V(BUILTIN, BuiltinFrame) \ |
| 118 V(BUILTIN_EXIT, BuiltinExitFrame) | 120 V(BUILTIN_EXIT, BuiltinExitFrame) |
| 119 | 121 |
| 120 // Every pointer in a frame has a slot id. On 32-bit platforms, doubles consume | 122 // Every pointer in a frame has a slot id. On 32-bit platforms, doubles consume |
| 121 // two slots. | 123 // two slots. |
| 122 // | 124 // |
| 123 // Stack slot indices >= 0 access the callee stack with slot 0 corresponding to | 125 // Stack slot indices >= 0 access the callee stack with slot 0 corresponding to |
| 124 // the callee's saved return address and 1 corresponding to the saved frame | 126 // the callee's saved return address and 1 corresponding to the saved frame |
| 125 // pointer. Some frames have additional information stored in the fixed header, | 127 // pointer. Some frames have additional information stored in the fixed header, |
| 126 // for example JSFunctions store the function context and marker in the fixed | 128 // for example JSFunctions store the function context and marker in the fixed |
| 127 // header, with slot index 2 corresponding to the current function context and 3 | 129 // header, with slot index 2 corresponding to the current function context and 3 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 public: | 354 public: |
| 353 // FP-relative. | 355 // FP-relative. |
| 354 static const int kContextOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0); | 356 static const int kContextOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0); |
| 355 static const int kLengthOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1); | 357 static const int kLengthOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1); |
| 356 static const int kConstructorOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(2); | 358 static const int kConstructorOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(2); |
| 357 static const int kNewTargetOrImplicitReceiverOffset = | 359 static const int kNewTargetOrImplicitReceiverOffset = |
| 358 TYPED_FRAME_PUSHED_VALUE_OFFSET(3); | 360 TYPED_FRAME_PUSHED_VALUE_OFFSET(3); |
| 359 DEFINE_TYPED_FRAME_SIZES(4); | 361 DEFINE_TYPED_FRAME_SIZES(4); |
| 360 }; | 362 }; |
| 361 | 363 |
| 364 class BuiltinContinuationFrameConstants : public TypedFrameConstants { |
| 365 public: |
| 366 // FP-relative. |
| 367 static const int kFunctionOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0); |
| 368 static const int kBuiltinOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1); |
| 369 static const int kArgCOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(2); |
| 370 DEFINE_TYPED_FRAME_SIZES(2); |
| 371 }; |
| 372 |
| 362 class StubFailureTrampolineFrameConstants : public InternalFrameConstants { | 373 class StubFailureTrampolineFrameConstants : public InternalFrameConstants { |
| 363 public: | 374 public: |
| 364 static const int kArgumentsArgumentsOffset = | 375 static const int kArgumentsArgumentsOffset = |
| 365 TYPED_FRAME_PUSHED_VALUE_OFFSET(0); | 376 TYPED_FRAME_PUSHED_VALUE_OFFSET(0); |
| 366 static const int kArgumentsLengthOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1); | 377 static const int kArgumentsLengthOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1); |
| 367 static const int kArgumentsPointerOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(2); | 378 static const int kArgumentsPointerOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(2); |
| 368 static const int kFixedHeaderBottomOffset = kArgumentsPointerOffset; | 379 static const int kFixedHeaderBottomOffset = kArgumentsPointerOffset; |
| 369 DEFINE_TYPED_FRAME_SIZES(3); | 380 DEFINE_TYPED_FRAME_SIZES(3); |
| 370 }; | 381 }; |
| 371 | 382 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 bool is_js_to_wasm() const { return type() == JS_TO_WASM; } | 529 bool is_js_to_wasm() const { return type() == JS_TO_WASM; } |
| 519 bool is_wasm_interpreter_entry() const { | 530 bool is_wasm_interpreter_entry() const { |
| 520 return type() == WASM_INTERPRETER_ENTRY; | 531 return type() == WASM_INTERPRETER_ENTRY; |
| 521 } | 532 } |
| 522 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } | 533 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } |
| 523 bool is_builtin() const { return type() == BUILTIN; } | 534 bool is_builtin() const { return type() == BUILTIN; } |
| 524 bool is_internal() const { return type() == INTERNAL; } | 535 bool is_internal() const { return type() == INTERNAL; } |
| 525 bool is_stub_failure_trampoline() const { | 536 bool is_stub_failure_trampoline() const { |
| 526 return type() == STUB_FAILURE_TRAMPOLINE; | 537 return type() == STUB_FAILURE_TRAMPOLINE; |
| 527 } | 538 } |
| 539 bool is_builtin_continuation() const { |
| 540 return type() == BUILTIN_CONTINUATION; |
| 541 } |
| 542 bool is_java_script_builtin_continuation() const { |
| 543 return type() == JAVA_SCRIPT_BUILTIN_CONTINUATION; |
| 544 } |
| 528 bool is_construct() const { return type() == CONSTRUCT; } | 545 bool is_construct() const { return type() == CONSTRUCT; } |
| 529 bool is_builtin_exit() const { return type() == BUILTIN_EXIT; } | 546 bool is_builtin_exit() const { return type() == BUILTIN_EXIT; } |
| 530 virtual bool is_standard() const { return false; } | 547 virtual bool is_standard() const { return false; } |
| 531 | 548 |
| 532 bool is_java_script() const { | 549 bool is_java_script() const { |
| 533 Type type = this->type(); | 550 Type type = this->type(); |
| 534 return (type == JAVA_SCRIPT) || (type == OPTIMIZED) || | 551 return (type == JAVA_SCRIPT) || (type == OPTIMIZED) || |
| 535 (type == INTERPRETED) || (type == BUILTIN); | 552 (type == INTERPRETED) || (type == BUILTIN) || |
| 553 (type == JAVA_SCRIPT_BUILTIN_CONTINUATION); |
| 536 } | 554 } |
| 537 bool is_wasm() const { | 555 bool is_wasm() const { |
| 538 Type type = this->type(); | 556 Type type = this->type(); |
| 539 return type == WASM_COMPILED || type == WASM_INTERPRETER_ENTRY; | 557 return type == WASM_COMPILED || type == WASM_INTERPRETER_ENTRY; |
| 540 } | 558 } |
| 541 | 559 |
| 542 // Accessors. | 560 // Accessors. |
| 543 Address sp() const { return state_.sp; } | 561 Address sp() const { return state_.sp; } |
| 544 Address fp() const { return state_.fp; } | 562 Address fp() const { return state_.fp; } |
| 545 Address callee_pc() const { | 563 Address callee_pc() const { |
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1453 return static_cast<ConstructFrame*>(frame); | 1471 return static_cast<ConstructFrame*>(frame); |
| 1454 } | 1472 } |
| 1455 | 1473 |
| 1456 protected: | 1474 protected: |
| 1457 inline explicit ConstructFrame(StackFrameIteratorBase* iterator); | 1475 inline explicit ConstructFrame(StackFrameIteratorBase* iterator); |
| 1458 | 1476 |
| 1459 private: | 1477 private: |
| 1460 friend class StackFrameIteratorBase; | 1478 friend class StackFrameIteratorBase; |
| 1461 }; | 1479 }; |
| 1462 | 1480 |
| 1481 class BuiltinContinuationFrame : public InternalFrame { |
| 1482 public: |
| 1483 Type type() const override { return BUILTIN_CONTINUATION; } |
| 1484 |
| 1485 static BuiltinContinuationFrame* cast(StackFrame* frame) { |
| 1486 DCHECK(frame->is_builtin_continuation()); |
| 1487 return static_cast<BuiltinContinuationFrame*>(frame); |
| 1488 } |
| 1489 |
| 1490 protected: |
| 1491 inline explicit BuiltinContinuationFrame(StackFrameIteratorBase* iterator); |
| 1492 |
| 1493 private: |
| 1494 friend class StackFrameIteratorBase; |
| 1495 }; |
| 1496 |
| 1497 class JavaScriptBuiltinContinuationFrame : public JavaScriptFrame { |
| 1498 public: |
| 1499 Type type() const override { return JAVA_SCRIPT_BUILTIN_CONTINUATION; } |
| 1500 |
| 1501 static JavaScriptBuiltinContinuationFrame* cast(StackFrame* frame) { |
| 1502 DCHECK(frame->is_java_script_builtin_continuation()); |
| 1503 return static_cast<JavaScriptBuiltinContinuationFrame*>(frame); |
| 1504 } |
| 1505 |
| 1506 int ComputeParametersCount() const override; |
| 1507 |
| 1508 protected: |
| 1509 inline explicit JavaScriptBuiltinContinuationFrame( |
| 1510 StackFrameIteratorBase* iterator); |
| 1511 |
| 1512 private: |
| 1513 friend class StackFrameIteratorBase; |
| 1514 }; |
| 1463 | 1515 |
| 1464 class StackFrameIteratorBase BASE_EMBEDDED { | 1516 class StackFrameIteratorBase BASE_EMBEDDED { |
| 1465 public: | 1517 public: |
| 1466 Isolate* isolate() const { return isolate_; } | 1518 Isolate* isolate() const { return isolate_; } |
| 1467 | 1519 |
| 1468 bool done() const { return frame_ == NULL; } | 1520 bool done() const { return frame_ == NULL; } |
| 1469 | 1521 |
| 1470 protected: | 1522 protected: |
| 1471 // An iterator that iterates over a given thread's stack. | 1523 // An iterator that iterates over a given thread's stack. |
| 1472 StackFrameIteratorBase(Isolate* isolate, bool can_access_heap_objects); | 1524 StackFrameIteratorBase(Isolate* isolate, bool can_access_heap_objects); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1605 | 1657 |
| 1606 | 1658 |
| 1607 // Reads all frames on the current stack and copies them into the current | 1659 // Reads all frames on the current stack and copies them into the current |
| 1608 // zone memory. | 1660 // zone memory. |
| 1609 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); | 1661 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); |
| 1610 | 1662 |
| 1611 } // namespace internal | 1663 } // namespace internal |
| 1612 } // namespace v8 | 1664 } // namespace v8 |
| 1613 | 1665 |
| 1614 #endif // V8_FRAMES_H_ | 1666 #endif // V8_FRAMES_H_ |
| OLD | NEW |