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 constexpr int kDartFrameFixedSize = 4; // PC marker, RBP, PP, PC.
39static constexpr int kSavedPcSlotFromSp = -1;
40
41static constexpr int kFirstObjectSlotFromFp =
42 -1; // Used by GC to traverse stack.
43static constexpr int kLastFixedObjectSlotFromFp = -2;
44
45static constexpr int kFirstLocalSlotFromFp = -3;
46static constexpr int kSavedCallerPpSlotFromFp = -2;
47static constexpr int kPcMarkerSlotFromFp = -1;
48static constexpr int kSavedCallerFpSlotFromFp = 0;
49static constexpr int kSavedCallerPcSlotFromFp = 1;
50
51static constexpr int kParamEndSlotFromFp = 1; // One slot past last parameter.
52static constexpr int kCallerSpSlotFromFp = 2;
53static constexpr int kLastParamSlotFromEntrySp = 1; // Skip return address.
54
55// Entry and exit frame layout.
56#if defined(DART_TARGET_OS_WINDOWS)
57static constexpr int kExitLinkSlotFromEntryFp = -33;
58#else
59static 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.
69constexpr 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.
74static constexpr int kFfiCallerTypedDataSlotFromFp = kCallerSpSlotFromFp;
75
76} // namespace dart
77
78#endif // RUNTIME_VM_STACK_FRAME_X64_H_
79

Provided by KDAB

Privacy Policy
Learn more about Flutter for embedded and desktop on industrialflutter.com

source code of dart_sdk/runtime/vm/stack_frame_x64.h