1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
---|---|
2 | // for details. All rights reserved. Use of this source code is governed by a |
3 | // BSD-style license that can be found in the LICENSE file. |
4 | |
5 | #ifndef RUNTIME_VM_STACK_FRAME_X64_H_ |
6 | #define RUNTIME_VM_STACK_FRAME_X64_H_ |
7 | |
8 | #if !defined(RUNTIME_VM_STACK_FRAME_H_) |
9 | #error Do not include stack_frame_x64.h directly; use stack_frame.h instead. |
10 | #endif |
11 | |
12 | #include "vm/constants.h" |
13 | |
14 | namespace dart { |
15 | |
16 | /* X64 Dart Frame Layout |
17 | |
18 | | | <- TOS |
19 | Callee frame | ... | |
20 | | saved PP | |
21 | | code object | |
22 | | saved RBP | (RBP of current frame) |
23 | | saved PC | (PC of current frame) |
24 | +--------------------+ |
25 | Current frame | ... T| <- RSP of current frame |
26 | | first local T| |
27 | | caller's PP T| |
28 | | code object T| (current frame's code object) |
29 | | caller's RBP | <- RBP of current frame |
30 | | caller's ret addr | (PC of caller frame) |
31 | +--------------------+ |
32 | Caller frame | last parameter | <- RSP of caller frame |
33 | | ... | |
34 | |
35 | T against a slot indicates it needs to be traversed during GC. |
36 | */ |
37 | |
38 | static constexpr int kDartFrameFixedSize = 4; // PC marker, RBP, PP, PC. |
39 | static constexpr int kSavedPcSlotFromSp = -1; |
40 | |
41 | static constexpr int kFirstObjectSlotFromFp = |
42 | -1; // Used by GC to traverse stack. |
43 | static constexpr int kLastFixedObjectSlotFromFp = -2; |
44 | |
45 | static constexpr int kFirstLocalSlotFromFp = -3; |
46 | static constexpr int kSavedCallerPpSlotFromFp = -2; |
47 | static constexpr int kPcMarkerSlotFromFp = -1; |
48 | static constexpr int kSavedCallerFpSlotFromFp = 0; |
49 | static constexpr int kSavedCallerPcSlotFromFp = 1; |
50 | |
51 | static constexpr int kParamEndSlotFromFp = 1; // One slot past last parameter. |
52 | static constexpr int kCallerSpSlotFromFp = 2; |
53 | static constexpr int kLastParamSlotFromEntrySp = 1; // Skip return address. |
54 | |
55 | // Entry and exit frame layout. |
56 | #if defined(DART_TARGET_OS_WINDOWS) |
57 | static constexpr int kExitLinkSlotFromEntryFp = -33; |
58 | #else |
59 | static constexpr int kExitLinkSlotFromEntryFp = -11; |
60 | #endif // defined(DART_TARGET_OS_WINDOWS) |
61 | |
62 | // For FFI native -> Dart callbacks, the number of stack slots between arguments |
63 | // passed on stack and arguments saved in callback prologue. 2 = return address |
64 | // (1) + saved frame pointer (1). Also add slots for the shadow space, if |
65 | // present. |
66 | // |
67 | // If NativeCallbackTrampolines::Enabled(), then |
68 | // kNativeCallbackTrampolineStackDelta must be added as well. |
69 | constexpr intptr_t kCallbackSlotsBeforeSavedArguments = |
70 | 2 + CallingConventions::kShadowSpaceBytes / kWordSize; |
71 | |
72 | // For FFI calls passing in TypedData, we save it on the stack before entering |
73 | // a Dart frame. This denotes how to get to the backed up typed data. |
74 | static constexpr int kFfiCallerTypedDataSlotFromFp = kCallerSpSlotFromFp; |
75 | |
76 | } // namespace dart |
77 | |
78 | #endif // RUNTIME_VM_STACK_FRAME_X64_H_ |
79 |
Definitions
- kDartFrameFixedSize
- kSavedPcSlotFromSp
- kFirstObjectSlotFromFp
- kLastFixedObjectSlotFromFp
- kFirstLocalSlotFromFp
- kSavedCallerPpSlotFromFp
- kPcMarkerSlotFromFp
- kSavedCallerFpSlotFromFp
- kSavedCallerPcSlotFromFp
- kParamEndSlotFromFp
- kCallerSpSlotFromFp
- kLastParamSlotFromEntrySp
- kExitLinkSlotFromEntryFp
- kCallbackSlotsBeforeSavedArguments
Learn more about Flutter for embedded and desktop on industrialflutter.com