1// Copyright (c) 2018, 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_KBC_H_
6#define RUNTIME_VM_STACK_FRAME_KBC_H_
7
8#include "platform/globals.h"
9
10namespace dart {
11
12/* Kernel Bytecode Frame Layout
13
14IMPORTANT: KBC stack is growing upwards which is different from all other
15architectures. This enables efficient addressing for locals via unsigned index.
16
17 | | <- TOS
18Callee frame | ... |
19 | saved FP | (FP of current frame)
20 | saved PC | (PC of current frame)
21 | code object |
22 | function object |
23 +--------------------+
24Current frame | ... T| <- SP of current frame
25 | ... T|
26 | first local T| <- FP of current frame
27 | caller's FP |
28 | caller's PC |
29 | code object T| (current frame's code object)
30 | function object T| (current frame's function object)
31 +--------------------+
32Caller frame | last parameter | <- SP of caller frame
33 | ... |
34
35 T against a slot indicates it needs to be traversed during GC.
36*/
37
38static const int kKBCDartFrameFixedSize = 4; // Function, Code, PC, FP
39static const int kKBCSavedPcSlotFromSp = 3;
40
41static const int kKBCFirstObjectSlotFromFp = -4; // Used by GC.
42static const int kKBCLastFixedObjectSlotFromFp = -3;
43
44static const int kKBCSavedCallerFpSlotFromFp = -1;
45static const int kKBCSavedCallerPcSlotFromFp = -2;
46static const int kKBCCallerSpSlotFromFp = -kKBCDartFrameFixedSize - 1;
47static const int kKBCPcMarkerSlotFromFp = -3;
48static const int kKBCFunctionSlotFromFp = -4;
49static const int kKBCParamEndSlotFromFp = 4;
50
51// Entry and exit frame layout.
52static const int kKBCEntrySavedSlots = 3;
53static const int kKBCExitLinkSlotFromEntryFp = 0;
54static const int kKBCSavedArgDescSlotFromEntryFp = 1;
55static const int kKBCSavedPpSlotFromEntryFp = 2;
56
57// Value for stack limit that is used to cause an interrupt.
58// Note that on KBC stack is growing upwards so interrupt limit is 0 unlike
59// on all other architectures.
60static const uword kKBCInterruptStackLimit = 0;
61
62} // namespace dart
63
64#endif // RUNTIME_VM_STACK_FRAME_KBC_H_
65