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
14namespace dart {
15
16/* X64 Dart Frame Layout
17
18 | | <- TOS
19Callee frame | ... |
20 | saved PP |
21 | code object |
22 | saved RBP | (RBP of current frame)
23 | saved PC | (PC of current frame)
24 +--------------------+
25Current 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 +--------------------+
32Caller frame | last parameter | <- RSP of caller frame
33 | ... |
34
35 T against a slot indicates it needs to be traversed during GC.
36*/
37
38static const int kDartFrameFixedSize = 4; // PC marker, RBP, PP, PC.
39static const int kSavedPcSlotFromSp = -1;
40
41static const int kFirstObjectSlotFromFp = -1; // Used by GC to traverse stack.
42static const int kLastFixedObjectSlotFromFp = -2;
43
44static const int kFirstLocalSlotFromFp = -3;
45static const int kSavedCallerPpSlotFromFp = -2;
46static const int kPcMarkerSlotFromFp = -1;
47static const int kSavedCallerFpSlotFromFp = 0;
48static const int kSavedCallerPcSlotFromFp = 1;
49
50static const int kParamEndSlotFromFp = 1; // One slot past last parameter.
51static const int kCallerSpSlotFromFp = 2;
52static const int kLastParamSlotFromEntrySp = 1; // Skip return address.
53
54// Entry and exit frame layout.
55#if defined(TARGET_OS_WINDOWS)
56static const int kExitLinkSlotFromEntryFp = -33;
57#else
58static const int kExitLinkSlotFromEntryFp = -11;
59#endif // defined(TARGET_OS_WINDOWS)
60
61// For FFI native -> Dart callbacks, the number of stack slots between arguments
62// passed on stack and arguments saved in callback prologue. 2 = return adddress
63// (1) + saved frame pointer (1). Also add slots for the shadow space, if
64// present.
65//
66// If NativeCallbackTrampolines::Enabled(), then
67// kNativeCallbackTrampolineStackDelta must be added as well.
68constexpr intptr_t kCallbackSlotsBeforeSavedArguments =
69 2 + CallingConventions::kShadowSpaceBytes / kWordSize;
70
71} // namespace dart
72
73#endif // RUNTIME_VM_STACK_FRAME_X64_H_
74