Flutter Engine
The Flutter Engine
stack_frame_riscv.h
Go to the documentation of this file.
1// Copyright (c) 2021, 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_RISCV_H_
6#define RUNTIME_VM_STACK_FRAME_RISCV_H_
7
8#if !defined(RUNTIME_VM_STACK_FRAME_H_)
9#error Do not include stack_frame_riscv.h directly; use stack_frame.h instead.
10#endif
11
12namespace dart {
13
14/* RISC-V Dart Frame Layout
15 | | <- TOS
16Callee frame | ... |
17 | saved PP |
18 | code object |
19 | saved FP | (FP of current frame)
20 | saved PC | (PC of current frame)
21 +--------------------+
22Current frame | ... T| <- SP of current frame
23 | first local T|
24 | caller's PP T|
25 | code object T| (current frame's code object)
26 | caller's FP |
27 | caller's RA | (PC of caller frame)
28 +--------------------+
29Caller frame | last parameter | <- SP of caller frame, FP of current frame
30 | ... |
31
32 T against a slot indicates it needs to be traversed during GC.
33*/
34
35static constexpr int kDartFrameFixedSize = 4; // PP, FP, RA, PC marker.
36static constexpr int kSavedPcSlotFromSp = -1;
37
38static constexpr int kFirstObjectSlotFromFp =
39 -3; // Used by GC to traverse stack.
40static constexpr int kLastFixedObjectSlotFromFp = -4;
41
42static constexpr int kFirstLocalSlotFromFp = -5;
43static constexpr int kSavedCallerPpSlotFromFp = -4;
44static constexpr int kPcMarkerSlotFromFp = -3;
45static constexpr int kSavedCallerFpSlotFromFp = -2;
46static constexpr int kSavedCallerPcSlotFromFp = -1;
47
48static constexpr int kParamEndSlotFromFp = -1; // One slot past last parameter.
49static constexpr int kCallerSpSlotFromFp = 0;
50static constexpr int kLastParamSlotFromEntrySp = 0;
51
52// Entry and exit frame layout.
53#if defined(TARGET_ARCH_RISCV64)
54static constexpr int kExitLinkSlotFromEntryFp = -30;
55#elif defined(TARGET_ARCH_RISCV32)
56static constexpr int kExitLinkSlotFromEntryFp = -42;
57#endif
60
61// For FFI native -> Dart callbacks, this is the number of stack slots between
62// arguments passed on stack and arguments saved in callback prologue.
63//
64// 2 = return address (1) + saved frame pointer (1).
65//
66// If NativeCallbackTrampolines::Enabled(), then
67// kNativeCallbackTrampolineStackDelta must be added as well.
68constexpr intptr_t kCallbackSlotsBeforeSavedArguments = 2;
69
70// For FFI calls passing in TypedData, we save it on the stack before entering
71// a Dart frame. This denotes how to get to the backed up typed data.
73
74} // namespace dart
75
76#endif // RUNTIME_VM_STACK_FRAME_RISCV_H_
Definition: dart_vm.cc:33
static constexpr int kExitLinkSlotFromEntryFp
static constexpr int kSavedCallerPcSlotFromFp
static constexpr int kLastParamSlotFromEntrySp
static constexpr int kFirstObjectSlotFromFp
static constexpr int kDartFrameFixedSize
static constexpr int kFfiCallerTypedDataSlotFromFp
static constexpr int kSavedCallerFpSlotFromFp
static constexpr int kParamEndSlotFromFp
static constexpr int kCallerSpSlotFromFp
static constexpr int kSavedPcSlotFromSp
const int kAbiPreservedCpuRegCount
const int kAbiPreservedFpuRegCount
static constexpr int kPcMarkerSlotFromFp
static constexpr int kFirstLocalSlotFromFp
static constexpr int kSavedCallerPpSlotFromFp
static constexpr int kLastFixedObjectSlotFromFp
COMPILE_ASSERT(kUnreachableReference==WeakTable::kNoValue)
constexpr intptr_t kCallbackSlotsBeforeSavedArguments