| 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 | |
| 10 | namespace dart { |
| 11 | |
| 12 | /* Kernel Bytecode Frame Layout |
| 13 | |
| 14 | IMPORTANT: KBC stack is growing upwards which is different from all other |
| 15 | architectures. This enables efficient addressing for locals via unsigned index. |
| 16 | |
| 17 | | | <- TOS |
| 18 | Callee frame | ... | |
| 19 | | saved FP | (FP of current frame) |
| 20 | | saved PC | (PC of current frame) |
| 21 | | code object | |
| 22 | | function object | |
| 23 | +--------------------+ |
| 24 | Current 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 | +--------------------+ |
| 32 | Caller frame | last parameter | <- SP of caller frame |
| 33 | | ... | |
| 34 | |
| 35 | T against a slot indicates it needs to be traversed during GC. |
| 36 | */ |
| 37 | |
| 38 | static const int kKBCDartFrameFixedSize = 4; // Function, Code, PC, FP |
| 39 | static const int kKBCSavedPcSlotFromSp = 3; |
| 40 | |
| 41 | static const int kKBCFirstObjectSlotFromFp = -4; // Used by GC. |
| 42 | static const int kKBCLastFixedObjectSlotFromFp = -3; |
| 43 | |
| 44 | static const int kKBCSavedCallerFpSlotFromFp = -1; |
| 45 | static const int kKBCSavedCallerPcSlotFromFp = -2; |
| 46 | static const int kKBCCallerSpSlotFromFp = -kKBCDartFrameFixedSize - 1; |
| 47 | static const int kKBCPcMarkerSlotFromFp = -3; |
| 48 | static const int kKBCFunctionSlotFromFp = -4; |
| 49 | static const int kKBCParamEndSlotFromFp = 4; |
| 50 | |
| 51 | // Entry and exit frame layout. |
| 52 | static const int kKBCEntrySavedSlots = 3; |
| 53 | static const int kKBCExitLinkSlotFromEntryFp = 0; |
| 54 | static const int kKBCSavedArgDescSlotFromEntryFp = 1; |
| 55 | static 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. |
| 60 | static const uword kKBCInterruptStackLimit = 0; |
| 61 | |
| 62 | } // namespace dart |
| 63 | |
| 64 | #endif // RUNTIME_VM_STACK_FRAME_KBC_H_ |
| 65 | |